# Liquidation shortfall silently absorbed

Liquidation paths that clamp, cap, or write off debt without reverting or recording bad debt

_Area: DeFi oracles, liquidations and flash loans. Seen in 3 disclosed reports; latest 2023-11-16. Updated 2026-11-20._

## How it works

Liquidation math computes two paired amounts: debt removed and collateral seized. The assumption that breaks is that these stay consistent with what the protocol actually holds. When collateral runs out, code clamps one side (seize amount, or payout) to the available balance but leaves the other side (debt removed, or consideration paid) at the computed value, and does not revert or record the shortfall. The gap becomes a loss that someone else absorbs: remaining depositors [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md), the protocol treasury [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md), or the liquidator [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md).

## Where it shows up

- A `min`/cap/`if (x > balance) x = balance;` on a computed seize or payout amount, with no matching adjustment to the debt or payment side [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md)[E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md)
- Multiple liquidation entry points (`liquidate` vs `liquidateClean`) where only one writes off bad debt [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md)
- `totalAssets` or share price left above the solvent value after a liquidation that recovered less than owed [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md)
- Liquidation bonus multipliers applied after deriving debt from collateral value, then clamped [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md)
- Payout functions that truncate instead of reverting when the requested amount exceeds what is available [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md)

## How to review

The invariant: after any liquidation, the change in recorded debt equals the value of collateral actually transferred, and any unrecovered remainder is either reverted or explicitly booked as bad debt. Check each liquidation path separately and confirm they update the same accounting state [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md). For every clamp, ask what the paired amount does: if seize is clamped, debt reduction must be clamped proportionally [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md); if payout is clamped, the caller's payment must shrink or the call must revert [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md). Confirm `totalAssets`/share accounting reflects only solvent assets after a shortfall [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md).

## How finders spotted it

- Reasoned from the accounting invariant that `totalAssets` should equal solvent assets, then compared the two liquidation paths and saw one never subtracts bad debt [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md)
- Read `_updateBorrowAndCollateralShare` and noticed `collateralShare` clamped to `userCollateralShare` without reducing `borrowPart`; confirmed with a PoC adding a `require` to force the branch [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md)
- Read `liquidate()` and spotted the `if (totalCollateralReturned > userCollateral.amount)` clamp truncating payout instead of reverting; forced an underwater position with a 50% price move in a PoC [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md)

## Variants seen

- Bad debt left in `totalAssets`, creating a first-exit advantage for redeemers [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md)
- Asymmetric clamping: seize capped, debt removed not capped, leaking protocol funds [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md)
- Payout capped to available collateral, liquidator underpaid for debt repaid [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md)

## Impact and severity

Loss is socialized to later withdrawers [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md), leaked from protocol funds [E2](https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md), or borne by liquidators who then stop liquidating, worsening bad debt [E3](https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md). Severity rises with how much debt can be removed per unit of collateral and how many users share the inflated pool.

## Why fixes fail

Fixing one liquidation path while another still skips the write-off leaves the hole open [E1](https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md).

## Evidence
- E1: https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AH-02.md
- E2: https://bugbountylibrary.com/r/c4%3A2023-07-tapioca%3AH-03.md
- E3: https://bugbountylibrary.com/r/c4%3A2023-03-polynomial%3AM-02.md
