In the TokenManager::tillIn
function, the msg.value
is checked against the _amount
parameter to ensure that sufficient funds have been sent for the transaction. However, if the msg.value
exceeds _amount
, the excess funds are not refunded and remain stuck in the contract. This issue can arise due to mistakenly sent funds or sudden changes in fees. Consequently, the excess funds become trapped in the contract PreMarket.
The issue arises from the following code in the TokenManager::tillIn
function:
In this code snippet, the function checks if the sent msg.value
is less than the required _amount
, reverting the transaction if it is. However, there is no mechanism to handle cases where msg.value
is greater than _amount
. As a result, the excess funds are not refunded to the sender and remain stuck in the contract PreMarket
.
There are several cases when msg.value > _amount
:
User Error: A user may accidentally send more funds than required, resulting in excess funds being trapped.
Fee Rate Changes: If the fee rate changes just before the user’s transaction, less value might be required, leaving the excess funds in the contract.
The absence of a refund mechanism in TokenManager::tillIn
leads to a scenario where any excess funds sent by the user are permanently trapped in the contract, effectively removing them from the user’s control. The vulnerability can result in a significant amount of ETH being permanently locked in the PreMarket contract due to user error or changes in fee rates. This creates a financial loss for users and reduces trust in the contract’s design.
Manual
Implement a Refund Mechanism: Modify the TokenManager::tillIn
function to include a refund mechanism that returns any excess funds to the sender:
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.