The scenario involves two users, User1 and User2, interacting with a smart contract that handles deposits and refunds of ERC20 tokens (e.g., WBTC). User1 deposits 1 WBTC, and then User2 back-runs with a higher deposit of 2 WBTC. After both deposits, User2 attempts to refund the entire balance of the contract, and both users end up with an equal amount of WBTC (2 WBTC), effectively splitting the contract's balance.
Back-running Attack: User2 is able to front-run the contract by depositing a larger amount than User1, and then exploiting a refund mechanism to take more funds than their deposit.
Refund Mechanism Flaw: The refund logic appears to refund the full contract balance without properly verifying or distinguishing the individual user’s balance. As a result, both User1 and User2 receive an equal portion of the refunded amount, even though they deposited different amounts.
State Mismanagement: The system incorrectly allocates the entire contract balance to User2, but User1’s balance should have been refunded separately based on their own deposit, not the entire contract balance.
Users will not receive the correct refund amount.
Foundry
Here is the POC:
Output is following
The refund logic need to be worked on so that the balance for respective user can be updated accordingly.
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.