Boost buyback burns incorrect amount of liquidity
The `_unfarmBuyBurn` function in the V3AMO contract calculates the amount of liquidity to burn based on the pool's token reserves, which is invalid for V3/CL pools because they allow single-sided liquidity. An attacker can add boost-only liquidity to make the contract overestimate the liquidity to burn, pushing the boost token price above the peg and profiting from the price movement.
0x37 Follow with carrotsmuggler, pkqs90 and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-10-axion-judging/issues/114
Found by
0x37, carrotsmuggler, pkqs90, s1ce, spark1, vinica_boy
Summary
The function _unfarmBuyBurn in the V3AMO contract is a public function open to everyone and calculates the amount of liquidity to burn from the pool. This function basically burns LP positions to take out liquidity and uses the usd to buy up boost tokens and burns them to raise the price of boost tokens.
The issue is in the _unfarmBuyBurn function when it tries to estimate how much liquidity needs to be taken out.
As seen above, first the token reserves of the pool are checked. Then, the liquidity to be burnt is calculated from the difference of the reserves.
liquidity = (totalLiquidity * (boostBalance - usdBalance)) / (boostBalance + usdBalance);
liquidity = (liquidity * LIQUIDITY_COEFF) / FACTOR;
However, this calculation is not valid for V3/CL pools. This is because in V3 pools, single sided liquidity is allowed which adds to the totalLiquidity count, but increases the reserves of only 1 token. If a user adds liquidity at a tick lower than the current price, they will be adding only usd to the pool.
For example, lets say the price currently is below peg, at 0.9. Say there are 1000 boost and 900 usd tokens in the pool, similar to a V2 composition. Now, since its a V3 pool, a user can come in and add 100 usd to the pool at a price of 0.5. Since this price is lower than the spot price, only usd will be needed to open this position. Now, the total reserves of both boost and usd are 1000 each, so the calculated liquidity amount to be removed will be 0.
Thus the liquidity calculated in the contract has absolutely no meaning since it uses the reserves to calculate it, which is not valid for V3 pools. In the best case scenario, this will cause the function to revert and not work. In the worst case scenario, the liquidity calculated will be overestimated and the price will be pushed up even above the peg price. This is possible if users add single sided boost to the pool, increasing the liquidity amount calculated without changing the price. In this case, the contract assets will be used to force the boost token above peg, and malicious actors can buy the boost token before and sell it after for a handy profit.
Root Cause
The main cause is that liquidity is calculated from the reserves. This is not valid for V3, since it can have single sided liquidity, and thus the reserves does not serve as an indicator of price or in this case the deviation from the peg.
Internal pre-conditions
None
External pre-conditions
Any user can add boost-only liquidity to make the contract overestimate the amount of liquidity it needs to burn
Attack Path
Users can add boost-only liquidity to make the contract overestimate the amount of liquidity it needs to burn. When extra liquidity is burnt and extra boost is bought back and burnt, the price will be pushed up even above the peg price. Users can buy before trigerring this and sell after for profit.
Impact
Price can be pushed above the peg price
PoC
None
Mitigation
Use the quoteSwap function to calculate how much needs to be swapped until the target price is hit.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/AXION-MONEY/liquidity-amo/pull/7
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
The liquidity to burn is calculated from the pool's token reserves, which is invalid for V3 pools that support single-sided liquidity and thus reserves do not reflect price deviation from the peg.
Impact
The price of the boost token can be pushed above the peg price, allowing malicious actors to buy before and sell after for profit.
What the attacker needed
Any user can add liquidity to the pool
The fix
The protocol team fixed this issue by using the `quoteSwap` function to calculate how much needs to be swapped until the target price is hit.
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.
This report is about a smart contract that automatically buys back and burns its own token to raise its price. The contract decides how much to burn by looking at the amounts of two tokens in a trading pool, but that method only works for older pool types. In newer pools, people can add just one token, which tricks the contract into burning too much and pushing the price too high.
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.