LendingPair.liquidateAccount fails if tokens are lent out
The liquidation function attempts to transfer underlying supply tokens to the liquidator, but the contract may not hold enough of those tokens if they are lent out. This prevents liquidations, potentially leading to insolvency and loss of user funds.
Submitted by cmichel
The LendingPair.liquidateAccount function tries to pay out underlying supply tokens to the liquidator using _safeTransfer(IERC20(supplyToken), msg.sender, supplyOutput) but there’s no reason why there should be enough supplyOutput amount in the contract, the contract only ensures minReserve.
As a result, no liquidations can be performed if all tokens are lent out. Example: User A supplies 1k$ WETH, User B supplies 1.5k$ DAI and borrows the ~1k$ WETH (only leaves minReserve). The ETH price drops but user B cannot be liquidated as there’s not enough WETH in the pool anymore to pay out the liquidator.
Recommend minting LP supply tokens to msg.sender instead, these are the LP supply tokens that were burnt from the borrower. This way the liquidator basically seizes the borrower’s LP tokens.
talegift (Wild Credit) confirmed but disagreed with severity:
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.
Update to severity - 2
If liquidation is impossible, there’s insolvency risk and that creates a risk to lose user funds. Keeping high severity.
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 logic pays the liquidator in underlying tokens without ensuring the contract holds enough of them, instead of transferring the borrower's LP tokens.
Impact
Liquidations become impossible when tokens are fully lent out, which could lead to insolvency and loss of user funds.
What the attacker needed
Tokens are lent out; borrower becomes liquidatable
The fix
The liquidation should mint LP supply tokens to the liquidator instead of transferring underlying tokens.
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, if a borrower's collateral value drops, anyone can liquidate them to keep the system safe. This report shows that the liquidation fails when the pool has lent out most of its tokens, because it tries to pay the liquidator with tokens it doesn't have. That can leave bad debt and put everyone's funds at risk.
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.