Deposit transactions lose funds to front-running when multiple fee tiers are available
The deposit function in a multipool contract lacks a minimum LP token output parameter, only checking minimum token amounts. An attacker could front-run a deposit by manipulating prices across multiple fee tiers to inflate reserves, causing the victim to receive fewer LP tokens and lose funds.
Deposit transactions lose funds to front-running when multiple fee tiers are available
Vulnerability Detail
The deposit transaction takes in minimum parameters for amount0 and amount1 of tokens that the user wishes to deposit, but no parameter for the minimum number of LP tokens the user expects to receive. A malicious actor can limit the number of LP tokens that the user receives in the following way:
A user Alice submits a transaction to deposit tokens into Multipool where (amount0Desired, amount0Min) > (amount1Desired, amount1Min)
A malicious actor Bob can front-run this transaction if there are multiple feeTiers:
by first moving the price of feeTier1 to make tokenA very cheap (lots of tokenA in the pool)
then moving the price of feeTier2 in opposite direction to make tokenB very cheap (lots of tokenB in the pool)
I believe this issue should be a low/non-issue, since the attacker can't increase both reserve0 and reserve1 of the Multipool contract through this scenario. This is due to the slippage of the UniswapV3 pool during the attacker's swaps, when you try to increase token0, you need a greater amount of token1 value.
A malicious actor Bob can front-run this transaction if there are multiple feeTiers:
by first moving the price of feeTier1 to make tokenA very cheap (lots of tokenA in the pool)
then moving the price of feeTier2 in opposite direction to make tokenB very cheap (lots of tokenB in the pool)
Therefore, the reserves will not be "overinflated". Also, since attacker can't increase both reserve0 and reserve1, the LP shares of the user will not become a lot smaller than before the large swap.
I believe this issue should be a low/non-issue, since the attacker can't increase both reserve0 and reserve1 of the Multipool contract through this scenario. This is due to the slippage of the UniswapV3 pool during the attacker's swaps, when you try to increase token0, you need a greater amount of token1 value.
A malicious actor Bob can front-run this transaction if there are multiple feeTiers:
by first moving the price of feeTier1 to make tokenA very cheap (lots of tokenA in the pool)
then moving the price of feeTier2 in opposite direction to make tokenB very cheap (lots of tokenB in the pool)
Therefore, the reserves will not be "overinflated". Also, since attacker can't increase both reserve0 and reserve1, the LP shares of the user will not become a lot smaller than before the large swap.
The attacker can increase both reserves precisely because multiple underlying pools are available (multiple fee tiers), so the attacker adds more of token0 to one fee tier and more of token1 to the other fee tier. This was detailed in the scenario of the original submission.
The slippage during the first swap of the attacker does not matter, as a sandwicher always incurs heavy slippage during a sandwich and rebalances during back run
huuducsc
I know that an attacker can manipulate multiple pools with multiple fee tiers. However, when the attacker adds more token0 to the first fee tier, the token1 amount of the position in this UniswapV3 pool will decrease. Similarly, the token0 amount of the position in the second fee tier will decrease. Moreover, the decreased amounts hold more value than the increased amounts due to the slippage of the UniswapV3 pool.
For example:
There are 2 positions in a 2 fee tier UniswapV3 pool. Initially, the first position (first fee tier) represents 1000 USDT-1000 USDC, and the second position (second fee tier) represents 2000 USDT-2000 USDC
=> Assuming that there is no fee, the initial reserves are 3000 USDT-3000 USDC.
2. The attacker increases USDT in the first pool -> the first position will have 1500 USDT-499 USDC.
The attacker increases USDC in the second pool -> the second position will have 1499 USDT-2500 USDC.
=> The new reserves will be 2999 USDT-2999 USDC (decreased).
huuducsc
The amounts of token0 and token1 in a position are calculated based on the current price and liquidity amount https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/LiquidityAmounts.sol#L120-L136. This mechanism is used in concentrated pools to prevent profiting from manipulating price then withdrawing position. If an attacker can increase the reserves without incurring any losses, as in the scenario described above, could anyone else do something similar and profit from their positions?
fann95
For example:
There are 2 positions in a 2 fee tier UniswapV3 pool. Initially, the first position (first fee tier) represents 1000 USDT-1000 USDC, and the second position (second fee tier) represents 2000 USDT-2000 USDC
=> Assuming that there is no fee, the initial reserves are 3000 USDT-3000 USDC.
The attacker increases USDT in the first pool -> the first position will have 1500 USDT-499 USDC.
The attacker increases USDC in the second pool -> the second position will have 1499 USDT-2500 USDC.
=> The new reserves will be 2999 USDT-2999 USDC (decreased).
The original report as published on Sherlock, by crimson-rat-reach. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the deposit function lacks a slippage check on the number of LP tokens minted, only verifying that the deposited token amounts meet minimums.
Impact
The user loses funds due to maximum slippage, as the attacker can sandwich the deposit to reduce LP tokens received.
The issue was fixed by adding a minimum acceptable amount of liquidity tokens to be minted and simplifying the slippage check.
How it was found
Alice submits a deposit transaction with minimum amounts for token0 and token1.
Bob front-runs by swapping in feeTier1 to make tokenA cheap and in feeTier2 to make tokenB cheap, inflating reserves.
Alice's transaction executes, the minimum amount checks pass, but she receives fewer LP tokens due to inflated reserves.
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.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
When you deposit tokens into a liquidity pool, you get LP tokens representing your share. This contract only lets you specify the minimum amount of each token to deposit, not the minimum LP tokens you'll receive. An attacker can manipulate the pool prices just before your deposit so you get fewer LP tokens than expected, effectively stealing some of your funds.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.