The removeLiquidity function relies on the wTokenToCollateralToken mapping to determine the correct collateral token for withdrawal. However, this mapping can be updated by another transaction before execution completes, allowing an attacker to swap the collateral token before execution completes, allowing an attacker to swap the collateral token and cause users to receive an unintended assets.
Users submits a transaction to call _removeLiquidity.
Attacker detects the pending transaction and quickly updates _wTokenToCollateralToken for that pool.
User's transaction executes, using the attackers's modified collateral token instead of the original one.
Users will withdraw a different collateral as expected
If the swapped collateral token is worthless or illiquid, the user losses funds.
Exploitable by front-running in mempool transaction
Manual Review
Store the collateral token before executing withdrawal and validate that it remains unchanged before using it.
example implementation
Consider making wTokenToCollateralToken after initial registration.
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.