Min deposit protection during rebalancing can be bypassed if multiple fee tiers
The vault's rebalancing slippage protection checks aggregate liquidity across multiple fee tiers, so an attacker can manipulate prices in opposite directions on different tiers to make the aggregate check pass while the operator provides liquidity at worse prices. The attacker can sandwich the rebalance and profit at the operator's expense.
Source: https://github.com/sherlock-audit/2023-06-arrakis-judging/issues/28
Found by
cergyk
Summary
Arrakis vault implements a slippage protection during rebalancing, but it does not protect when multiple feeTiers are used.
Vulnerability Detail
The slippage protection used here: https://github.com/sherlock-audit/2023-06-arrakis/blob/main/v2-core/contracts/ArrakisV2.sol#L408-L409
can be used to check that liquidity is added around a given price (acts like a slippage protection), when used on one pool.
However when aggregated on multiple pools as it is done here (over same tokens but multiple fee tiers), it does not protect the user, as pools can be imbalanced in different directions, and funds can be provided in the same proportion but provide liquidity at a worse price,
Example:
Arrakis vault handles the price range 1200-2000 on WETH-USDC in fee tiers [0.3%, 0.5%], price of WETH sits at 1600.
Alice sees that Bob the operator tries to rebalance the pool and thus provides liquidity on both ranges
Alice front runs Bob transaction, driving the price of WETH-USDC on fee tier 0.3% to 1200, and on fee tier 0.5% to 2000.
Bob executes his operation, and provides bigger amounts of WETH and USDC to provide same liquidity (worse prices), and so the slippage checks out.
Alice back runs the operation and makes a nice profit.
Please note that in the setup using SimpleManager, price deviation is checked on every minting pool:
https://github.com/sherlock-audit/2023-06-arrakis/blob/main/v2-manager-templates/contracts/SimpleManager.sol#L189-L194
So the sandwiching is limited by the deviation parameter (1%). This issue still holds, since maybe Bob wanted to enforce a stricter deviation for his rebalance (0.5%) using this check, and fails to do so.
Impact
Bob makes an unfortunate rebalance to the profit of a sandwich.
Code Snippet
Tool used
Manual Review
Recommendation
Check deposited amounts in aggregate but grouped by fee tiers.
Discussion
kassandraoftroy
For me this issue is a valid medium and not a duplicate of #164 since it is about rebalance() not addLiquidity() (so does not have the proper checks to sniff out manipulation when adding liquidity on multiple fee tiers simultaneously).
Gevarist
For this issue we have a fix here, we are letting the operator to fix a custom max slippage value (lower than the vault max slippage defines by owner during initialization of the management).
IAm0x52
Fix looks good. Operator can now specify a tighter slippage value
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 slippage protection aggregates liquidity across multiple fee tiers, allowing offsetting price manipulations to cancel out in the check.
Impact
The operator could suffer a worse rebalance due to sandwiching, though the SimpleManager's 1% deviation check limits the manipulation.
What the attacker needed
Vault uses multiple fee tiers; attacker can front-run and back-run
The fix
The fix allows the operator to set a custom maximum slippage value lower than the vault's maximum, as confirmed in the discussion.
How it was found
- Alice sees Bob the operator is about to rebalance the vault.
- Alice front-runs Bob's transaction, moving the price on one fee tier down and on another fee tier up.
- Bob's rebalance executes, providing liquidity at worse prices but the aggregate slippage check passes.
- Alice back-runs the operation and makes a profit.
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 vault rebalances by adding liquidity to pools. It has a check to ensure it gets a fair price, but when multiple pools with different fee tiers are used, the check only looks at the total. An attacker can push prices in opposite directions on different pools so the total looks fine, but the vault actually gets a bad deal.
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.