Boost can be sold under peg despite comments and code attempting to prevent it
The contract's check to prevent selling BOOST below peg only ensures the minimum output is at least the input amount, but does not stop sales that push the pool below the peg. An admin could sell BOOST below peg, causing the protocol to lose funds.
spark1 Follow with vinica_boy
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-10-axion-judging/issues/36
Found by
spark1, vinica_boy
Summary
Boost can be sold under peg despite comments and code attempting to prevent it. This is defined in the comments https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/MasterAMO.sol#L148-L150 and readme " There are, however, some hard-coded limitations —— mainly to ensure that even admins can only buyback BOOST below peg and sell it above peg. These are doctsringed."
Root Cause
The only apparent check to prevent boost from being sold below peg is a simple if statement:
if (minUsdAmountOut < toUsdAmount(boostAmount)) minUsdAmountOut = toUsdAmount(boostAmount);
However this does not prevent boost from being sold below peg. Consider pool with 90 boost and 110 usdc (ignore fees for now). 1 boost > 1 usdc. If _mintAndSellBoost is called with 20 boost, we will get end result 110 boost and 90 usdc. 20 boost were sold for 20 usdc. However, some of the boost were sold below the peg. Consider the first boost we sold. It was above the peg. At about 99.498 boost and 99.498 usdc the pool will be balanced. However, once we continue selling boost we will be selling below the peg.
The admin can call mintAndSellBoost directly. https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/MasterAMO.sol#L155-L168
The following affiliated check does nothing as without fee on transfer it will always pass. https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV2AMO.sol#L186-L188
// we check that selling BOOST yields proportionally more USD
if (usdAmountOut != usdBalanceAfter - usdBalanceBefore)
revert UsdAmountOutMismatch(usdAmountOut, usdBalanceAfter - usdBalanceBefore);
This also applies to mintSellFarm as it does the same call with toUsdAmount(boostAmount) https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV2AMO.sol#L349.
This may not apply to V3 AMO depending on if targetSqrtPriceX96 is set correctly: https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV3AMO.sol#L141-L160
This contradicts the comments and readme stating that boost cannot be sold below peg by the AMO.
Internal pre-conditions
no preconditions
External pre-conditions
no preconditions
Attack Path
Not an attack
Impact
The protocol loses funds equivalent to the area under the curve of boost sold below peg. In large depeg this could be a huge amount of money. In the 90 - 110 example the total loss is 10.502 - 9.498 = 1.004. The protocol has lost 5% of the funds used in _mintAndSellBoost. High severity as it has large loss and violates important invariant specified explicitly in readme.
PoC
Not required according to the terms
Mitigation
Check that you can only sell to the sqrt K 1:1 balanced price.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/AXION-MONEY/liquidity-amo/pull/4
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 check only ensures the minimum output is at least the input amount, but does not enforce that the sale price stays at or above the peg throughout the trade.
Impact
The protocol loses funds equivalent to the area under the curve of BOOST sold below peg; in large depeg this could be a huge amount of money.
What the attacker needed
Admin privileges
The fix
The fix should check that you can only sell to the sqrt K 1:1 balanced price.
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.
A peg is a target price, like 1 BOOST should equal 1 USDC. The contract tries to stop selling BOOST for less than that, but its check only looks at the total amount, not the price at each step. So an admin can still sell BOOST at a loss to the protocol.
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.