Attacker can manipulate low TVL Uniswap V3 pool to borrow and swap to make Lending Pool in loss
The protocol values Uniswap V3 LP positions using the spot price from the position's own pool, which can be a low-liquidity pool created by an attacker. An attacker can manipulate that pool's price to inflate the collateral value of their LP position and borrow more than the position is worth, causing a loss to the lending pool.
Originally disclosed on Code4rena
Submitted by minhquanym
In Paraspace protocol, any Uniswap V3 position that are consist of ERC20 tokens that Paraspace support can be used as collateral to borrow funds from Paraspace pool. The value of the Uniswap V3 position will be sum of value of ERC20 tokens in it.
function getTokenPrice(uint256 tokenId) public view returns (uint256) {
UinswapV3PositionData memory positionData = getOnchainPositionData(
tokenId
);
PairOracleData memory oracleData = _getOracleData(positionData);
(uint256 liquidityAmount0, uint256 liquidityAmount1) = LiquidityAmounts
.getAmountsForLiquidity(
oracleData.sqrtPriceX96,
TickMath.getSqrtRatioAtTick(positionData.tickLower),
TickMath.getSqrtRatioAtTick(positionData.tickUpper),
positionData.liquidity
);
(
uint256 feeAmount0,
uint256 feeAmount1
) = getLpFeeAmountFromPositionData(positionData);
return // @audit can be easily manipulated with low TVL pool
(((liquidityAmount0 + feeAmount0) * oracleData.token0Price) /
10**oracleData.token0Decimal) +
(((liquidityAmount1 + feeAmount1) * oracleData.token1Price) /
10**oracleData.token1Decimal);
}
However, Uniswap V3 can have multiple pools for the same pairs of ERC20 tokens with different fee params. A fews has most the liquidity, while other pools have extremely little TVL or even not created yet. Attackers can abuse it, create low TVL pool where liquidity in this pool mostly (or fully) belong to attacker’s position, deposit this position as collateral and borrow token in Paraspace pool, swap to make the original position reduce the original value and cause Paraspace pool in loss.
Proof of Concept
Consider the scenario where WETH and DAI are supported as collateral in Paraspace protocol.
- Alice (attacker) create a new WETH/DAI pool in Uniswap V3 and add liquidity with the following amount
1e18 wei WETH - 1e6 wei DAI = 1 WETH - 1e-12 DAI ~= 1 ETHLet’s just assume Alice position has price range from[MIN_TICK, MAX_TICK]so the math can be approximately like Uniswap V2 - constant product. Note that this pool only has liquidity from Alice. - Alice deposit this position into Paraspace, value of this position is approximately
1 WETHand Alice borrow maximum possible amount of USDC. - Alice make swap in her WETH/DAI pool in Uniswap V3 to make the position become
1e6 wei WETH - 1e18 wei DAI = 1e-12 WETH - 1 DAI ~= 1 DAI
Please note that the math I’ve done above is approximation based on Uniswap V2 formula x * y = k because Alice provided liquidity from MIN_TICK to MAX_TICK.
For more information about Uniswap V3 formula, please check their whitepaper here: https://uniswap.org/whitepaper-v3.pdf.
Recommended Mitigation Steps
Consider adding whitelist, only allowing pool with enough TVL to be collateral in Paraspace protocol.
Overinflated severity
minhquanym (warden) commented:
Hi @LSDan, Maybe there is a misunderstanding here. I believed I gave enough proof to make it a High issue and protocol can be at loss. You can think of it as using Uniswap V3 pool as a price Oracle. However, it did not even use TWA price but spot price and pool with low liquidity is really easy to be manipulated. We all can see many examples about Price manipulation attacks recently and they had a common cause that price can be changed in one block. About the Uniswap V3 pool with low liquidity, you can check out this one https://etherscan.io/address/0xbb256c2F1B677e27118b0345FD2b3894D2E6D487. This is a USDC-USDT pool with only
$8kin it.
This is not true because Alice’s pool will be immediately arbed each time she attempts a price manipulation. Accordingly, this issue only exists when a pair has very low liquidity on UniV3 and no liquidity elsewhere. I would have accepted this as a QA, but it does not fall into the realm of a high risk issue.
I’m open to accepting this as a medium if you can give me a more concrete scenario where the value that Alice is extracting from the protocol through this attack is sustainable and significant enough to exceed the gas price of creating a new UniV3 pool.
minhquanym (warden) commented:
@LSDan, Please correct me if I’m wrong but I don’t think Alice’s pool can be arbed when the whole attack happens in 1 transaction. Because of that, I still believe that this is a High. For example,
- price before manipulation is
p1- flash loan and swap to change the price to
p2- add liquidity and borrow at price
p2- change the price back to
p1- repay the flash loan
That’s basically the idea. You can see price is back to
p1at the end.
Ok yeah… I see what you’re saying now. This could be used to drain the pool because the underlying asset price comes from a different oracle. So if Alice creates a pool with 100 USDC and 100 USDT, and drops 3mm USDC from a flash loan into it, the external oracle will value the LP at
$3mm. High makes sense. Thanks for the additional clarity.
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 protocol uses the spot price from the same Uniswap V3 pool that holds the collateral, without checking that the pool has sufficient liquidity or using a time-weighted average price.
Impact
The attacker could borrow more than the collateral is worth, causing the lending pool to lose funds; the judge initially thought arbitrage would prevent this but later accepted that a single-transaction attack could drain the pool.
What the attacker needed
Attacker can create a Uniswap V3 pool; attacker has some initial tokens for liquidity; protocol accepts the LP position as collateral
The fix
The protocol should add a whitelist allowing only pools with sufficient TVL to be used as collateral.
How it was found
- Create a new Uniswap V3 pool for the token pair and add a small amount of liquidity, so the attacker owns all the liquidity.
- Deposit the LP position into Paraspace as collateral.
- Borrow the maximum possible amount of another token.
- Swap in the attacker's pool to change the price and reduce the position's value.
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 lending protocol lets people borrow money by putting up collateral. Here, the collateral is a share in a trading pool on Uniswap. The protocol works out the collateral's value by looking at the current price in that same trading pool. If the attacker creates a tiny trading pool and then trades heavily in it, they can make the price look very high, so their collateral seems worth much more than it really is. They then borrow as much as possible and walk away, leaving the lending pool with a loss.