Liquidation can be escaped by depositing a Uni v3 position with 0 liquidity
A malicious user can escape liquidation by depositing a Uni v3 position with zero liquidity, because the liquidation process calls decreaseLiquidity which fails when liquidity is zero. This allows undercollateralized debt to remain unliquidated, potentially causing bad debt for the protocol.
Submitted by WatchPug.
When the liquidator is trying to liquidate a undercolldarezed loan by calling liquidateAccount(), it calls _unwrapUniPosition() -> uniV3Helper.removeLiquidity() -> positionManager.decreaseLiquidity().
However, when the Uni v3 position has 0 liquidity, positionManager.decreaseLiquidity() will fail.
See: https://github.com/Uniswap/v3-periphery/blob/main/contracts/NonfungiblePositionManager.sol#L265
Based on this, a malicious user can escaped liquidation by depositing a Uni v3 position with 0 liquidity.
Impact
Undercollateralized debts cannot be liquidated and it leads to bad debts to the protocol.
A malicious user can take advantage of this by creating long positions on the collateral assets and take profit on the way up, and keep taking more debt out of the protocol, while when the price goes down, the debt can not be liquidated and the risks of bad debt are paid by the protocol.
Proof of Concept
- A malicious user deposits some collateral assets and borrow the max amount of debt;
- The user deposits a Uni v3 position with 0 liquidity;
- When the market value of the collateral assets decreases, the liquadation will fail as
positionManager.decreaseLiquidity()reverts.
Recommendation
Check if liquidity > 0 when removeLiquidity.
talegift (Wild Credit) confirmed:
Valid issue. Good catch.
Severity should be lowered to 2 as it doesn’t allow direct theft of funds and the loss would only occur under specific external conditions.
2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements
https://docs.code4rena.com/roles/wardens/judging-criteria#estimating-risk-tl-dr
To my understanding, bad position would affect the whole protocol and a loss would have to be paid by other participans which means funds can be drained. For that reason, I’m keeping high risk.
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 liquidation code calls decreaseLiquidity on a Uni v3 position without checking if the position has zero liquidity, causing a revert.
Impact
Undercollateralized debts cannot be liquidated, leading to bad debts for the protocol; the judge noted that a loss would have to be paid by other participants, meaning funds can be drained.
What the attacker needed
A malicious user with collateral; ability to deposit a Uni v3 position
The fix
The code should check that liquidity is greater than zero before calling removeLiquidity.
How it was found
- A malicious user deposits some collateral assets and borrows the maximum amount of debt.
- The user deposits a Uni v3 position with 0 liquidity.
- When the market value of the collateral assets decreases, the liquidation will fail as positionManager.decreaseLiquidity() reverts.
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.
In a lending protocol, if a borrower's collateral value falls below their debt, anyone can liquidate them to recover funds. Here, the borrower can add a special type of collateral (a Uni v3 position) that has no actual liquidity, which makes the liquidation step fail. So the borrower keeps their debt even when they should be liquidated, and the protocol may lose money.
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.