The afterUpdate
function in the UpliftOnlyExample
contract allows unlimited position transfers to a target address, enabling a DOS attack that can prevent users from removing liquidity or transferring their legitimate positions.
In the UpliftOnlyExample
contract, the afterUpdate
function is responsible for handling position transfers between addresses. When a position is transferred, it adds the position's fee data to the recipient's array:
The vulnerability lies in the fact that there is no limit on how many positions can be transferred to a single address. An attacker can exploit this by:
Waiting for a user to create a legitimate position
Creating multiple small (dust) positions
Transferring all these dust positions to the target user's address
When the victim tries to remove liquidity or transfer their legitimate position, the contract must iterate through all positions to process the request. With enough dust positions, this operation will consume more gas than the block limit allows, causing the transaction to revert.
DOS - Users can be permanently prevented from removing liquidity or transferring their positions, effectively locking their funds in the protocol. This attack is relatively inexpensive to execute since it only requires creating multiple small positions.
Manual Review
Implement a maximum limit on the number of positions that can be held by a single address:
This change ensures that no address can accumulate enough positions to cause gas-related DOS attacks while still allowing legitimate users to manage a reasonable number of positions.
Likelihood: Medium/High, anyone can receive an unlimited NFT number but will cost creation of LP tokens and sending them. Impact: Low/Medium, DoS the afterUpdate and addLiquidityProportional but will be mitigable on-chain because a lot of those NFT can be burn easily in onAfterRemoveLiquidity.
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.