Hijack token pool by burning liquidity token
The Pool contract allows any user to burn their liquidity tokens without withdrawing the underlying assets, which can reduce the total supply to 1. An attacker can then deposit a large amount and receive zero liquidity tokens due to rounding, effectively locking others out from obtaining LP tokens.
Submitted by jonah1005
Pool allows users to burn lp tokens without withdrawing the tokens. This allows the hacker to mutate the pools’ rate to a point that no one can get any lp token anymore (even if depositing token).
The liquidity tokens are calculated at Utils:calcLiquidityUnits
// units = ((P (t B + T b))/(2 T B)) * slipAdjustment
// P * (part1 + part2) / (part3) * slipAdjustment
uint slipAdjustment = getSlipAdustment(b, B, t, T);
uint part1 = t*(B);
uint part2 = T*(b);
uint part3 = T*(B)*(2);
uint _units = (P * (part1 + (part2))) / (part3);
return _units * slipAdjustment / one; // Divide by 10**18
where P stands for totalSupply of current Pool. If P is too small (e.g, 1) then all the units would be rounding to 0.
Since any person can create a Pool at PoolFactory, hackers can create a Pool and burn his lp and set totalSupply to 1. He will be the only person who owns the Pool’s lp from now on. Pool’s burn logic and Utils’ lp token formula.
Here’s a script of a user depositing 1M token to a pool where totalSupply equals 1
dai_pool.functions.burn(init_amount-1).transact()
print('total supply', dai_pool.functions.totalSupply().call())
dai.functions.transfer(dai_pool.address, 1000000 * 10**18).transact()
dai_pool.functions.addForMember(user).transact()
print('lp received from depositing 1M dai: ', dai_pool.functions.balanceOf(user).call())
Output:
total supply 1
lp received from depositing 1M dai: 0
Recommend removing burn or restrict it to privileged users only.
verifyfirst (Spartan) confirmed:
We agree to this issue and will restrict access to burn in the pool contract. We have already proposed adding a 1 week withdraw coolOff for all users per pool from the genesis of creation. Users can only add liquidity within this period.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the burn function allows reducing total supply without proportional withdrawal, and the liquidity calculation rounds down to zero when total supply is very small.
Impact
An attacker can permanently prevent any new liquidity from receiving LP tokens in a pool they create, effectively locking out other users.
What the attacker needed
Ability to create a pool; some initial liquidity to burn
The fix
The burn function should be removed or restricted to privileged users only.
How it was found
- Create a pool via PoolFactory.
- Burn almost all LP tokens to set totalSupply to 1.
- Deposit a large amount of tokens into the pool.
- Observe that zero LP tokens are received.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Liquidity tokens represent a share of a pool of assets. The pool calculates how many new tokens to give you based on the total supply. If the total supply is very small, the calculation can round down to zero, so you get nothing for your deposit. The bug lets someone shrink the total supply to 1, so everyone else gets zero tokens when they deposit.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.