The function UpliftOnlyExample::afterUpdate
does not validate the length of the poolsFeeData[_to]
array before appending new entries. This allows attackers to send multiple NFTs to a victim, artificially inflating the poolsFeeData
array. Consequently, the victim may face:
Gas Limit Issues: Unable to remove liquidity or transfer their LP NFTs due to excessive gas costs or block gas limit.
Operational Restrictions: Unable to add liquidity if the pool's poolsFeeData
length exceeds predefined limits.
The afterUpdate
function appends entries to the poolsFeeData
array for the recipient (_to
) without checking its length. Here's the problematic code:
An attacker can exploit this by repeatedly transferring NFTs to the victim. This grows the poolsFeeData
array to an unmanageable size, making operations like removing liquidity or transferring LP NFTs prohibitively expensive due to gas costs or the block gas limit.
The attacker generates multiple LP NFTs with negligible value.
They transfer these NFTs to the victim, increasing the poolsFeeData
array for the victim’s address.
When the victim tries to:
Remove liquidity or transfer LP NFTs, the transaction fails due to excessive gas costs.
Add liquidity, the transaction fails if poolsFeeData
length exceeds protocol-defined limits.
This vulnerability can result in a permanent denial of service for the victim, rendering their LP NFTs unusable and their liquidity inaccessible.
There are two test functions here, in one of them bob adds liquidty and withdraws it, in the other one alice sends multiple nfts after bobs deposit and then bob tries to remove liquidty. Here, there are two records of gas consumption.
Log:
Manual review
Add Length Validation: Implement a maximum allowed length for poolsFeeData
to prevent uncontrolled growth.
Authorization for NFT Transfers: Require explicit authorization from the recipient (_to
) before accepting LP NFTs from a sender.
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.