The addMigratedUnderlying function in the UnripeFacet is vulnerable to front-running attacks due to the ERC20 approval mechanism. A malicious user can exploit this by observing approval transactions and quickly using up the approved tokens before the intended transaction, causing it to fail. This issue can lead to financial exploitation, transaction failures, and increased gas costs.
Step-by-Step Exploitation by a Malicious User:
1: User Sets Approval:
The user approves 100 tokens to be spent by a contract.
2: Malicious User Observes the Approval:
The malicious user monitors the blockchain for approval transactions.
3: Front-Running the Intended Transaction:
The malicious user submits a transaction to use up the approved tokens before the user's intended transaction is executed. This is often done by setting a higher gas price to ensure their transaction is processed first.
4: User’s Transaction Fails:
When the user’s intended transaction is processed, it fails due to insufficient allowance
Front-running transactions can deplete the approved token amount, causing subsequent transactions to fail due to insufficient allowance.
The protocol may experience financial losses due to the manipulation of token allowances and unauthorized transfers, reducing the overall token supply and liquidity.
Users may lose their tokens due to unauthorized transfers, resulting in direct financial losses and reduced trust in the protocol.
Manual Review
To mitigate this issue, the contract should be enhanced with additional checks and mechanisms. Here’s how it can be implemented:
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.