Denial of service
On the first deposit into a new token pair, the pool sets total liquidity units to the native deposit amount, which can be as low as 1. An attacker can exploit this to make one liquidity token represent the entire pool reserves, causing rounding errors that prevent or disadvantage new liquidity providers and potentially allow the attacker to profit.
Submitted by danb
https://github.com/code-423n4/2021-12-vader/blob/main/contracts/dex-v2/pool/VaderPoolV2.sol#L334 on the first deposit, the total liquidity is set to nativeDeposit. this might be a very low number compared to foreignDeposit. It can cause a denial of service of the pair.
Impact
A pair can enter a denial of service state.
Proof of Concept
consider the following scenario: the owner of the pool calls setFungibleTokenSupport for a new token, for example weth. a malicious actor calls mintFungible, with nativeDeposit == 1 and foreignDeposit == 10 ether. totalLiquidityUnits will be 1. the pool can be arbitraged, even by the attacker, but totalLiquidityUnits will still be 1. this means that 1 liquidity token is equal to all of the pool reserves, which is a lot of money. It will cause a very high rounding error for anyone trying to mint liquidity. then, anyone who will try to mint liquidity will either:
- fail, because they can’t mint 0 liquidity if their amount is too small.
- get less liquidity tokens than they should, because there is a very high rounding error, and its against new liquidity providers.
The rounding error losses will increase the pool reserves, which will increase value of liquidity tokens, so the hacker can even profit from this.
after this is realised, no one will want to provide liquidity, and since the pair cannot be removed or replaced, it will cause denial of service for that token forever.
SamSteinGG (Vader) acknowledged
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 pool initialises total liquidity units to the native deposit amount without enforcing a minimum ratio or preventing extreme imbalances on the first deposit.
Impact
The pair can enter a denial of service state, preventing new liquidity providers from participating and potentially allowing the attacker to profit from rounding errors, with the effect persisting for that token.
What the attacker needed
Pool owner enables a new token; attacker can call mintFungible
How it was found
- The pool owner enables support for a new token via setFungibleTokenSupport.
- A malicious actor calls mintFungible with a native deposit of 1 and a foreign deposit of 10 ether.
- totalLiquidityUnits becomes 1, making one liquidity token equal to all pool reserves.
- The attacker can arbitrage the pool while totalLiquidityUnits remains 1.
- New liquidity providers either fail to mint or receive fewer tokens due to high rounding error.
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.
When you add money to a liquidity pool, you get tokens representing your share. The first person to add money sets the initial exchange rate between the two tokens. If they add a tiny amount of one token and a large amount of the other, they can make each share token extremely valuable. Later users then get very few shares for their money due to rounding, so they lose out and stop using the pool.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.