The UpliftOnlyExample contract allows the sender to add liquidity to the pools more than 100 times. As it can be seen in the code snippet below, the addLiquidityProportional function of the contract allows the sender to add liquidity to the pools. Indeed the function does check that sender can add liquidity to the pools only limited number of time. The expectation was to limit senders upto 100 times to add liquidity to the pool. However, due to an oversight, the contract allows the sender to add liquidity to the pools more than 100 times at least one more time. This could make the contract vulnerable to DDoS attacks by 1%. The attacker could add liquidity to the pools more than 100 times and disrupt the contract's intended functionality.
see the code snippet below:
UpliftOnlyExample.sol::addLiquidityProportional:
The issue is technical and the code snippet is self-explanatory.
The following code snippet demonstrates how the contract could be exploited to add liquidity to the pool more than 100 times:
Steps to reproduce:
Go to the test folder inside pool-hooks folder then -> foundry folder -> UpliftExample.t.sol
Add the following test snippet just below the setUp function in the UpliftExample.t.sol file:
Now run the test cases using the following command: (Make sure you are in the pool-hooks directory)
As we can see in the output, the contract allows the sender to add liquidity to the pool more than 100 times.
The sender can add liquidity to the pool more than 100 times.
The contract is vulnerable to DDoS attacks by 1%.
A malicious actor who've knowledge to this vulnerability could add liquidity to the pool more than 100 times exactly 101 times and could gain the advantage of 1% DDoS attack in all the pools, that's why it's should be considered as a Medium issue.
Another reason to consider this issue as a Medium issue is that, each time a user adds liquidity to the pool, the contract will mint a new NFT token for the user, and if the user adds liquidity to the pool more than 100 times, the contract will mint more than 100 NFT tokens for the user and afterwards user could transfer the excess NFT token to another user.
Moreover, if that user leaks the oversight to the other users, then there would be chain of corrupt users i.e.,
User A adds liquidity to the pool more than 100 times.
User A transfers the excess NFT tokens to User B.
User B adds liquidity to the pool more than 100 times.
User B transfers the excess NFT tokens to User C.
User C adds liquidity to the pool more than 100 times.
User C transfers the excess NFT tokens to User D.
And so on.
Foundry (Framework)
Manual Review
The solution is simple and straightforward. The contract should limit the sender to add liquidity to the pools only 100 times. The following code snippet demonstrates the solution:
The above solution limits the sender to add liquidity to the pools only 100 times. Therefore, enhancing the security of the contract.
Only 1 more NFT won’t have any impact. Informational.
Only 1 more NFT won’t have any impact. Informational.
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.