Liquidations can be permanently blocked via getLiquidationBonus() unsigned underflow (Insolvent-but-unliquidatable accounts)
The liquidation bonus calculation subtracts a cross-denominated collateral balance from a required threshold in unsigned arithmetic, assuming the threshold is always at least the balance. When an account is insolvent only by distribution (one token short while the other has a surplus) and cross-margining is disabled, the balance can exceed the threshold, so the subtraction underflows and reverts, making the account unliquidatable.
Submitted by edoscoba, also found by 0xnija, Agontuk, AlexNiht, Bale, caesar49, dman, eternal1328, legat, Micky042, OxNoble, ProngsDev, VulSight, and Zitifethefirst
Finding description
PanopticPool.dispatchFrom() routes to liquidation when RiskEngine.isAccountSolvent() returns false at all liquidation ticks. The solvency check is intentionally not based on total cross-collateral value: it applies a utilization-dependent crossBufferRatio that can reduce cross-margining to ~0 at high utilization, forcing a strict per-token solvency requirement.
However, RiskEngine.getLiquidationBonus() computes a single cross-denominated “collateral balance” and “required threshold” using PanopticMath.getCrossBalances(...), then applies the documented formula:
liquidationBonus = min(collateralBalance / 2, required - collateralBalance)
This implementation assumes required >= collateralBalance and performs the subtraction in unsigned arithmetic:
uint256 bonusCross = Math.min(balanceCross / 2, thresholdCross - balanceCross);
When liquidation is triggered due to distribution insolvency (e.g., token1 balance is below requirement while token0 has a large surplus, and cross-margining is disabled by crossBufferRatio), it is possible and realistic for balanceCross > thresholdCross even though isAccountSolvent() is false. In that case, thresholdCross - balanceCross underflows and reverts, which bubbles up and reverts the entire liquidation.
Impact
- Liquidation DoS: accounts that the protocol deems liquidatable can become unliquidatable, breaking the core safety mechanism.
- Systemic risk escalation: undercollateralized portfolios can remain open and cannot be force-closed, increasing the likelihood of PLP losses and blocking recovery mechanisms that depend on liquidation completing successfully.
Recommended mitigation steps
-
Make
getLiquidationBonus()robust tobalanceCross >= thresholdCrossby clamping the deficit:uint256 deficitCross = thresholdCross > balanceCross ? thresholdCross - balanceCross : 0;uint256 bonusCross = Math.min(balanceCross / 2, deficitCross);
-
Align liquidation bonus computation with the protocol’s solvency semantics:
- Either compute “effective cross collateral” using the same
crossBufferRatiomethodology used inisAccountSolvent(), or - Derive bonus from per-token deficits/surpluses directly (rather than a single cross-total), so distribution-insolvent accounts cannot trigger a revert in the liquidation path.
- Either compute “effective cross collateral” using the same
-
Keep (and extend) regression tests covering liquidation paths where cross-margining is disabled by high utilization.
Proof of Concept
A runnable PoC:
test/foundry/core/LiquidationBonusUnderflowPoC.t.sol
Run it with:
forge test --match-path test/foundry/core/LiquidationBonusUnderflowPoC.t.sol -vvv
View detailed Proof of Concept
No more underflow for liquidation bonus calculation with no cross-margin.
Status: Mitigation confirmed. Full details in reports from Valves, edoscoba, and Nyx.
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 liquidation bonus formula assumes the required threshold is always greater than or equal to the cross-denominated collateral balance, but the solvency check can fail on a per-token distribution basis while the cross total still exceeds the threshold, so the unsigned subtraction underflows.
Impact
Accounts the protocol deems liquidatable could become permanently unliquidatable, which may let undercollateralised positions stay open and increase the risk of losses to the protocol's liquidity providers.
What the attacker needed
High utilisation disables cross-margining; account insolvent by token distribution; one token surplus, one token deficit
The fix
The bonus calculation was changed so that the deficit is clamped to zero when the balance exceeds the threshold, and the project confirmed the mitigation.
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-style protocol must be able to force-close an account that no longer has enough collateral, a process called liquidation. Here the code that works out the liquidator's reward subtracts one number from another assuming the first is always bigger; when it is not, the maths wraps around to a huge value and the whole liquidation transaction fails. The result is an account the protocol says is unsafe but that nobody can actually liquidate.
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.