The tillIn
function fails to handle scenarios where the msg.value
sent with the transaction exceeds the required amount. This leads to the loss of any excess msg.value
that users might send accidentally. The issue can be mitigated by either refunding the excess msg.value
or reverting the transaction if the msg.value
is unexpectedly high.
In the tillIn
function, the contract expects the msg.value
to be exactly equal to the _amount
when dealing with native tokens. The function checks if msg.value
is less than _amount
and reverts if so. However, it does not account for the possibility that msg.value
could be greater than _amount
, leading to a situation where any extra msg.value
is lost.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L56-L103
Users who accidentally send more than the required msg.value
will lose the excess amount permanently. If a user sends more msg.value
than required, the excess amount is neither refunded nor accounted for, leading to its permanent loss.
Manual review
Refund Excess msg.value
: Implement logic to refund any excess msg.value
to the sender if the amount provided is greater than _amount
. This ensures that users do not lose funds unintentionally.
Revert Transactions with Excess msg.value
: Alternatively, revert the transaction if msg.value
exceeds _amount
. This approach prevents any accidental overpayment and encourages users to send the correct amount.
Invalid, these are by default, invalid based on codehawks [general guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). The check implemented is simply a sufficiency check, it is users responsibility to only send an appropriate amount of native tokens where amount == msg.value when native token is intended to be used as collateral (which will subsequently be deposited as wrapped token). All excess ETH can be rescued using the `Rescuable.sol` contract. > Users sending ETH/native tokens > If contracts allow users to send tokens acc111identally.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.