Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Invalid

Loss of Excess `msg.value` in `tillIn` Function Due to Lack of Refund or Revert Mechanism

Summary

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.

Vulnerability Details

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.

if (_tokenAddress == wrappedNativeToken) {
/**
* @dev token is native token
* @notice check msg value
* @dev if msg value is less than _amount, revert
* @dev wrap native token and transfer to capital pool
*/
if (msg.value < _amount) {
revert Errors.NotEnoughMsgValue(msg.value, _amount);
}
IWrappedNativeToken(wrappedNativeToken).deposit{value: _amount}();
_safe_transfer(wrappedNativeToken, capitalPoolAddr, _amount);
}

https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L56-L103

Impact

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.

Tools Used

Manual review

Recommendations

  1. 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.

  2. 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.

if (msg.value != _amount) {
revert Errors.InvalidMsgValue(msg.value, _amount);
}
Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[invalid] finding-TokenManager-tillin-excess

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.