Skip to content
DoS Audit finding Intermediate

dispatchFrom() liveness DoS via StaleOracle : spot price manipulation blocks liquidations, force exercises, and premium settlements

The dispatchFrom function in PanopticPool unconditionally reverts with StaleOracle when the spot tick deviates from the TWAP by more than a threshold, blocking all liquidations, force exercises, and premium settlements. An attacker can front-run a liquidation with a swap to push the price out of range, causing the liquidation to revert and delaying it indefinitely.

fuzious Follow with brotzumax, LinKenji and 1 other

Originally disclosed on Code4rena

Submitted by fuzious, also found by brotzumax, LinKenji, and Valves

PanopticPool.sol L1388-L1389

Finding description

The PanopticPool.dispatchFrom() function, which serves as the shared entrypoint for liquidations, force exercises, and long premium settlements, unconditionally reverts with Errors.StaleOracle() when the live spot tick (currentTick) deviates more than tickDeltaLiquidation ticks from the protocol’s internal TWAP (twapTick).

unchecked {
    (RiskParameters riskParameters, ) = getRiskParameters(0);
    int256 MAX_TWAP_DELTA_LIQUIDATION = int256(
        uint256(riskParameters.tickDeltaLiquidation())
    );
    if (Math.abs(currentTick - twapTick) > MAX_TWAP_DELTA_LIQUIDATION)
        revert Errors.StaleOracle();
}

The default threshold is MAX_TWAP_DELTA_LIQUIDATION = 513 ticks (defined in RiskEngine.sol L76), corresponding to approximately a 5.27% price deviation (1.0001^513 ≈ 1.0527).

This gate executes before the function determines whether the operation is:

  • A liquidation (solvent == 0)
  • A force exercise (solvent == numberOfTicks && toLength == finalLength + 1)
  • A long premium settlement (solvent == numberOfTicks && toLength == finalLength)

Consequently, when abs(currentTick - twapTick) > tickDeltaLiquidation, all dispatchFrom operations are blocked for all callers.

Impact

  1. Delayed/Blocked liquidations: Insolvent positions remain open longer than intended. In stressed markets, this increases the probability that losses socialize to PLPs (Panoptic Liquidity Providers) or manifest as bad debt.
  2. Blocked force exercises: Legitimate force exercise operations on exercisable long positions are prevented.
  3. Blocked premium settlements: Long premium settlement cannot occur, preventing sellers from collecting owed premium.
  4. Liquidator griefing: Liquidators can be griefed into repeated reverted transactions (gas loss) if they do not utilize private orderflow.
  5. Economic exploitation: An insolvent user (or MEV searcher acting on their behalf) can front-run detected liquidation transactions with a swap that pushes currentTick beyond the threshold, then optionally back-run to restore the price,repeatedly delaying liquidation indefinitely.

Attack scenarios

Scenario A: Mempool-reactive liquidation DoS

  1. Account becomes insolvent; a liquidator submits a liquidation via dispatchFrom.
  2. Account owner (or MEV searcher) observes the transaction in the public mempool.
  3. Attacker front-runs with a swap that pushes currentTick beyond ±tickDeltaLiquidation ticks from twapTick.
  4. Liquidation executes and reverts with Errors.StaleOracle().
  5. Attacker can optionally back-run to restore price and minimize exposure.
  6. Repeat as needed to delay liquidation indefinitely.

Scenario B: Liveness failure during volatility

Even without a strategic attacker, large market moves can naturally place the spot price far from the protocol’s internal TWAP/EMA state. During that window, dispatchFrom is unavailable, coinciding with the exact periods where liquidations are most critically needed.

Recommended Mitigation Steps

The StaleOracle gate exists to prevent liquidation paths from executing at a potentially manipulated spot price. Removing it outright reintroduces price-manipulation attacks against liquidation pricing and accounting. Consider the following alternatives:

  1. Two-step liquidation (Mark and Execute)

    • Mark insolvency using TWAP/median-based criteria without reverting on divergence.
    • Execute liquidation after a delay or once oracle state catches up.
  2. Degraded mode: Proceed using oracle ticks only

    • If abs(currentTick - twapTick) > threshold, proceed but substitute currentTick with twapTick (or medianTick/latestTick) for all liquidation/settlement pricing inputs.
  3. Rate-limited/Governance-guarded bypass

    • Allow a privileged actor (or tightly scoped guardian role) to bypass the gate for emergency liquidation of specific accounts/pools.

Proof of Concept

PoC demonstrates end-to-end that:

  1. A valid liquidation succeeds when spot price is within the tickDeltaLiquidation threshold.
  2. The same valid liquidation reverts with Errors.StaleOracle when spot is moved out-of-range.
  3. Force exercise and premium settlement are similarly blocked when out-of-range.

Test Coverage

Test | What it proves |

test_PoC_LiquidationExecutes_WhenInsolvent_AndPriceInRange | Valid liquidation executes when abs(currentTick - twapTick) <= tickDeltaLiquidation |

test_PoC_LiquidationDoS_BlocksValidLiquidation_WhenPriceOutOfRange | Same valid liquidation reverts with Errors.StaleOracle when spot is out-of-range |

test_PoC_ForceExerciseExecutes_WhenPriceInRange | Valid force exercise executes in-range (emits ForcedExercised) |

test_PoC_ForceExerciseDoS_BlocksValidForceExercise_WhenPriceOutOfRange | Force exercise blocked by Errors.StaleOracle when out-of-range |

test_PoC_PremiumSettlementExecutes_WhenPriceInRange | Premium settlement executes in-range (emits PremiumSettled) |

test_PoC_PremiumSettlementDoS_BlocksValidSettlement_WhenPriceOutOfRange | Settlement blocked by Errors.StaleOracle when out-of-range |

test_PoC_StaleOracleBoundary_StrictGreaterThan_WhenReachable | Gate is strict > (not >=) at exact boundary |

PoC Diff

To apply the PoC, create the file test/foundry/core/LiquidationDoSPoC.t.sol with the following content:

View detailed Proof of Concept

Panoptic mitigated:

No more DoS via StaleOracle for liquidations.

Status: Mitigation confirmed. Full details in report from Nyx.


The original report as published on Code4rena, by fuzious. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 StaleOracle check is applied before determining the operation type, so any price deviation beyond the threshold blocks all dispatchFrom operations for all callers.

Impact

Liquidations, force exercises, and premium settlements can be blocked, potentially leading to bad debt and socialized losses, and liquidators can be griefed with repeated failed transactions.

What the attacker needed

Insolvent position; public mempool access; ability to swap on the underlying pool

The fix

The issue was mitigated by removing the DoS via StaleOracle for liquidations, as confirmed in the mitigation review.

How it was found

  1. Account becomes insolvent and a liquidator submits a liquidation via dispatchFrom.
  2. Attacker observes the transaction in the public mempool.
  3. Attacker front-runs with a swap that pushes currentTick beyond the threshold from twapTick.
  4. Liquidation executes and reverts with Errors.StaleOracle().
  5. Attacker optionally back-runs to restore price and minimize exposure.
  6. Repeat as needed to delay liquidation indefinitely.

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 smart contract checks that the current market price is close to a long-term average before allowing certain actions like liquidating an unhealthy loan. If the price is too far off, it refuses to do anything. An attacker can briefly move the price just before a liquidation, causing it to fail, and then move it back, so the bad loan never gets closed.

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.

More by fuzious

View all

1 more disclosed report, best first.

More from Panoptic: Next Core

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.