Any borrower with bad debt can be liquidated multiple times to lock funds in the lending pair
Leftover shares in liquidateClean are only subtracted from pair totals, not from the borrower's borrowed shares, so a borrower with bad debt can be liquidated repeatedly with zero shares to write off debt and corrupt pair accounting. This can lock the pool, prevent borrowers from repaying, and severely reduce lenders' withdrawals.
Submitted by panprog, also found by 0xA5DF and Lambda
Leftover shares in liquidateClean are only subtracted from pair totals, but not from user’s borrowed shares. This means that after liquidateClean, borrower’s shares will be greater than 0 (leftover shares after liquidations), but the user is still insolvent and can be liquidated again and again (with _sharesToLiquidate set to 0). Each subsequent liquidation will write off the bad debt (reduce pair totals by borrower leftover shares/amounts), but doesn’t take anything from liquidator nor borrower (since _sharesToLiquidate == 0).
This messes up the whole pair accounting, with total asset amounts reducing and total borrow amounts and shares reducing. This will make it impossible for borrowers to repay debt (or be liquidated), because borrow totals will underflow, and lenders amount to withdraw will reduce a lot (they will share non-existant huge bad debt).
Reducing pair totals scenario:
- Alice borrows
1000 FRAX(1000shares) against1.5 ETHcollateral (1 ETH = 1000,Max LTV=75%) - ETH drops to
500very quickly with liquidators being unable to liquidate Alice due to network congestion - At ETH =
500, Alice collateral is worth750against1000 FRAXdebt, making Alice insolvent and in a bad debt - Liquidator calls
liquidateCleanfor800shares, which cleans up all available collateral of1.5 ETH. - At this point Alice has
200shares debt with0collateral - Liquidator repeatedly calls
liquidateCleanwith0shares to liquidate. Each call pair totals are reduced by200shares (and total borrow amount by a corresponding amount). - When pair totals reach close to
0, the pool is effectively locked. Borrowers can’t repay, lenders can withdraw severly reduced amounts.
Proof of Concept
Copy this to src/test/e2e/LiquidationBugTest.sol
https://gist.github.com/panprog/cbdc1658d63c30c9fe94127a4b4b7e72
Recommended Mitigation Steps
After the line
add
_sharesToLiquidate += _sharesToAdjust;
amirnader-ghazvini (Frax) marked as duplicate and commented:
Duplicate of #112
Setting to original in set.
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
Impact
The pool accounting is corrupted, making it impossible for borrowers to repay or be liquidated normally, and lenders can withdraw only severely reduced amounts.
What the attacker needed
A borrower with bad debt; a liquidator calls liquidateClean; network congestion prevents timely liquidation
The fix
The liquidation logic should add the leftover shares to the shares to liquidate so the borrower's debt is properly reduced.
How it was found
- Alice borrows 1000 FRAX against 1.5 ETH collateral at 75% max LTV.
- ETH price drops to 500, making Alice insolvent with bad debt.
- A liquidator calls liquidateClean for 800 shares, clearing all collateral.
- Alice still has 200 shares of debt with zero collateral.
- The liquidator repeatedly calls liquidateClean with 0 shares, each time reducing pair totals by 200 shares.
- Pair totals approach zero, locking the pool and preventing repayment or normal withdrawal.
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 pool, when a borrower's collateral is worth less than their debt, a liquidator can step in to clear the debt. This report found that after one such cleanup, the borrower still appears to owe the leftover amount, so a liquidator can call the cleanup again and again with zero shares. Each call wrongly reduces the pool's totals without taking any real money, eventually breaking the pool so nobody can repay or withdraw properly.
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.