Deeply underwater liquidations panic instead of capping collateral
The liquidation engine's calculation subtracts a bonus-inclusive collateral seizure from the user's total collateral without capping it, so deeply underwater accounts cause a u128 underflow and panic. Liquidators using this path cannot process those positions, delaying resolution and increasing bad debt exposure.
Submitted by v12, also found by AuroraAI, daprolad, dumbbutt, rawsid11, and Spottedhyena0
Found by V12
contracts/liquidation-engine/src/calculation.rs#L7contracts/liquidation-engine/src/contract.rs#L49
Targets
- LiquidationEngineContract::calculate_liquidation
- LiquidationEngineContract::execute_liquidation
Affected Locations
- LiquidationEngineContract.calculate_liquidation:
calculate_liquidationcomputescollateral_amount_base = actual_debt_to_cover + bonus_amountand then subtracts it fromuser_account_data.total_collateral_basewithout capping or checking the result first. - LiquidationEngineContract.execute_liquidation:
execute_liquidationrelies oncalculate_liquidation, so the same arithmetic panic bubbles up and makes this liquidation path revert for deeply underwater accounts.
Description
calculate_liquidation derives collateral_amount_base from the debt to cover plus the liquidation bonus, then subtracts that value from user_account_data.total_collateral_base to compute remaining_collateral. For deeply underwater accounts, the bonus-inclusive seizure value can be greater than the user’s entire collateral base, so this subtraction underflows in u128 and panics instead of returning a capped result. Because execute_liquidation calls calculate_liquidation, the same condition causes the liquidation flow through the engine to revert before it can proceed. The issue is most likely to occur on the very positions that most need liquidation, since low health factors make total_collateral_base especially small relative to debt. The inputs consistently note that another router path has collateral-cap logic, but the liquidation engine path does not.
Root Cause
calculate_liquidation performs user_account_data.total_collateral_base - collateral_amount_base without first ensuring collateral_amount_base <= total_collateral_base or capping the seized collateral.
Impact
Liquidators using the LiquidationEngine path cannot process deeply underwater positions, so integrations that depend on this frontend are denied liquidation exactly when risk is highest. This can delay resolution of bad positions and increase protocol bad debt exposure until an alternate path such as direct liquidation_call is used.
Proof of Concept
See original finding for full Proof of Concept
Remediation
Cap the bonus-inclusive collateral seizure in liquidation-engine calculation to the user’s total collateral base before computing remaining collateral and bonus. This removes the u128 underflow for deeply underwater positions while preserving existing behavior for uncapped liquidations.
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 calculation subtracts the bonus-inclusive seizure amount from total collateral without first capping it to the available collateral, causing an unsigned integer underflow.
Impact
Liquidators using the LiquidationEngine path cannot process deeply underwater positions, which could delay resolution and increase protocol bad debt exposure until an alternate path is used.
What the attacker needed
Deeply underwater account; liquidation via LiquidationEngine path
The fix
The bonus-inclusive collateral seizure should be capped to the user's total collateral base before computing remaining collateral and bonus.
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.
When a borrower's debt is much larger than their collateral, the code tries to take more collateral than the user actually has. Subtracting a bigger number from a smaller one in an unsigned integer makes the program crash instead of handling it gracefully. That means the liquidation cannot go through on the accounts that most need it.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.