The _handleReturn function is responsible for finalizing the withdrawal process by calculating the amount of funds to return to the user and transferring the funds. However, the function does not adequately handle the case where the remaining collateral balance is insufficient to cover the user's share of the withdrawal. This could lead to incorrect calculations potentially resulting in financial losses for users.
The _handleReturn function calculates the withdrawal amount as:
If the remaining collateral balance is insufficient to cover the user's share (e.g., balanceBeforeWithdrawal * shares / totalShares > collateralToken.balanceOf(address(this))), the calculation of amount will be incorrect, also if withdrawn exceeds the current collateral balance, balanceBeforeWithdrawal will be negative, leading to underflow.
Example: If collateralToken.balanceOf(address(this)) is 1,000 USDC and withdrawn is 1,500 USDC, balanceBeforeWithdrawal will underflow, resulting in unexpected behavior.
Users may receive incorrect amounts, leading to financial losses. For example, a user might receive less than their fair share due to truncation or underflow.
Manual Review
Add a check to ensure that withdrawn does not exceed the current collateral balance.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.