Closed sherlock-admin2 closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid because { watson didn't explain how the exploit or issue might look like}
Invalid, user input error not valid based on sherlock rules.
- User input validation: User input validation to prevent user mistakes is not considered a valid issue.
millietez
medium
Sent native ether will not be recorded in the contract
Summary
Sent native ether will not be recorded in the contract.
Vulnerability Detail
The
DepositStableCoinToDealer
contract accepts ether in the form of wrapped ether (wETH). ThedepositStableCoin
function checks the conditionasset == weth && msg.value == amount
in line 43 https://github.com/JOJOexchange/smart-contract-EVM/blob/aca8529979caa9e99ea48948645e041925731ef4/src/DepositStableCoinToDealer.sol#L43If the value of
asset
is not equal toweth
, thedeposit
call will not be executed. However, the user can still sendmsg.value
, and the function will proceed to invoke thesafeTransferFrom
method, which is used to transfer ERC-20 tokens from the sender to the contract.From the user's perspective, if they make a mistake in specifying the asset or amount and accidentally send native Ether, they may assume that the contract will handle it in the same way as the transfer of an ERC-20 token. However, the sent native ether will not be recorded in the contract. This could result in a loss of funds, as the contract will not be notified of the transfer of native Ether.
Impact
The complexity of detecting unintentional transfers and the potential loss of funds for the sender.
Code Snippet
https://github.com/JOJOexchange/smart-contract-EVM/blob/aca8529979caa9e99ea48948645e041925731ef4/src/DepositStableCoinToDealer.sol#L43
Tool used
Manual Review
Recommendation
Add a check for the absence of
msg.value
. Ifasset != weth
, thenmsg.value
should be equal to zero.