Skip to content
Business logic Audit finding Advanced

Overly conservative degraded-mode solvency check enables attacker-controlled LP fund freeze exceeding 24 hours

The solvency check that switches the engine into degraded mode compares pool cash against the gross maximum profit of the dominant side without crediting the locked margin of the open losing position. An attacker can open a hedged long and short pair, close only the winning leg after a small price move, and latch degraded mode, which blocks all LP redemptions until the owner injects capital or the attacker closes the losing leg.

papikoo Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99063 [SC-High] Overly conservative degraded-mode solvency check enables attacker-controlled LP fund freeze exceeding 24 hours

Submitted on Nov 11th 2026 at 17:48:27 UTC by @papikoo for Audit Competition | Plether

Description

Brief/Intro

An attacker can cheaply and intentionally latch degradedMode on the CfdEngine by opening a hedged LONG+SHORT pair and closing only the winning leg after a small price move. This freezes all LP redemptions (both Senior and Junior tranches) for an unbounded duration controlled by the attacker, because _enterDegradedModeIfInsolvent() compares pool cash against gross directional max-profit liability without crediting the open losing position's locked margin. The freeze persists until the protocol owner manually injects capital via recapitalize() or the attacker voluntarily closes the losing position.

Vulnerability Details

The root cause is in CfdEngine._enterDegradedModeIfInsolvent() (line 1351-1368):

Solidity
function _enterDegradedModeIfInsolvent(
    address account,
    uint256 pendingPoolPayoutAssets
) internal {
    if (degradedMode) return;
    uint256 effectiveAssetsAfter = _availableCashForFreshPoolPayouts();
    // ...
    uint256 maxLiabilityAssets = _maxLiability();
    if (effectiveAssetsAfter < maxLiabilityAssets) {
        degradedMode = true;
    }
}

Where:

  • _availableCashForFreshPoolPayouts() = pool.totalAssets() - totalTraderClaimBalanceAssets (line 865-871)
  • _maxLiability() = max(longState.maxProfitAssets, shortState.maxProfitAssets) (line 1044-1050)

The check uses gross maxProfitAssets for the dominant side without subtracting locked margin (pnlPledge) held against the open positions. When a hedged trader closes only the profitable leg, the pool pays out the winner's PnL, reducing totalAssets. But the losing leg's maxProfitAssets remains at its full gross value, because maxProfitAssets is a directional aggregate that doesn't decrease when the opposing side closes.

Attack flow:

  1. Attacker opens equal-notional LONG and SHORT positions using two accounts (hedged, near delta-neutral)
  2. A small price move (~1.5%) makes one side profitable
  3. Attacker closes only the winning leg — pool cash decreases by the payout
  4. _enterDegradedModeIfInsolvent() fires: pool cash (987,540 USDG in the PoC) is now less than the losing side's gross maxProfitAssets (990,000 USDG) → degradedMode = true
  5. clearDegradedMode() reverts with CfdEngine__StillInsolvent because the losing position's maxProfitAssets still exceeds pool cash — even if the price fully reverts to the original entry price
  6. HousePool.settleLpEpoch() reverts with HousePool__DegradedMode, blocking all LP redemptions

The attacker keeps the losing position open indefinitely (paying only carry charges), maintaining the freeze. Even the protocol owner cannot clear degraded mode via clearDegradedMode() without first injecting fresh capital through recapitalize().

The attack is repeatable: after the owner clears degraded mode, the attacker can immediately re-trigger it with new hedged positions.

Impact Details

Temporary freezing of funds for at least 24 hours — specifically, ALL LP capital in both Senior and Junior tranches is frozen for an attacker-controlled, unbounded duration.

  • The freeze blocks HousePool.settleLpEpoch(), which means no LP can withdraw (redeem) any funds
  • New LP deposit settlements are also blocked during degraded mode
  • The attacker controls the duration by keeping the losing position open (cost: only carry charges)
  • The freeze persists even if the oracle price fully reverts to the original level

Cost-to-damage ratio: The attacker's cost is ~12 basis points of notional in execution fees plus ongoing carry charges. In the PoC, ~$120 in fees freezes ~$987,000 in LP capital — a 1:8,200 ratio, far exceeding the 1:100 threshold where griefing downgrade does not apply per the program's rules.

Capital requirement: 2× initial margin on the notional, approximately 0.4% of pool size at maximum leverage. The attacker recovers most margin when the losing position eventually closes (at a loss roughly equal to the winner's gain, minus fees).

Remediation: The solvency check should credit open positions' locked margin (pnlPledge) against gross max-profit liability, so that only the net unfunded exposure triggers degraded mode.

References

  • CfdEngine._enterDegradedModeIfInsolvent(): packages/perps/src/CfdEngine.sol lines 1351-1368
  • CfdEngine._availableCashForFreshPoolPayouts(): packages/perps/src/CfdEngine.sol lines 865-871
  • CfdEngine._maxLiability(): packages/perps/src/CfdEngine.sol lines 1044-1050
  • HousePool.settleLpEpoch() degraded mode guard: packages/perps/src/HousePool.sol lines 1864-1870
  • CfdEngine.clearDegradedMode(): packages/perps/src/CfdEngine.sol line 660-663

Link to Proof of Concept

https://gist.github.com/divolt-research/1df1ea070c43e71464636d2302375906

Proof of Concept

Proof of Concept

Steps to reproduce

  1. Place the PoC file at packages/perps/test/perps/poc/DegradedGriefPoC.t.sol
  2. Run: forge test --match-test "test_PoC_hedgedCloseLatchesDegradedAndFreezesLp" -vvv
  3. Observe: test passes — degraded mode latches, clearDegradedMode() reverts, LP redemption reverts

Step-by-step explanation

  1. Fund two attacker accounts with 100,000 USDG each (atkLong and atkShort)
  2. Open hedged positions: Open equal-notional LONG and SHORT positions (990,000 USDG notional each), split across multiple orders to stay within skew limits. Pool assets remain unchanged (1,002,000 USDG) because margin moves from clearinghouse, not from the pool.
  3. Price moves 1.5%: Basket price drops from 1.00 to 0.985. The LONG position is now profitable.
  4. Close only the winning LONG leg: Full close at 990,000e18 size at price 98,500,000 (0.985). Pool pays out the LONG's profit, reducing pool assets to 987,540 USDG.
  5. Degraded mode latches: _enterDegradedModeIfInsolvent() compares pool cash (987,540) against the SHORT side's gross maxProfitAssets (990,000). Since 987,540 < 990,000, degradedMode = true.
  6. Owner cannot clear: clearDegradedMode() calls the same _availableCashForFreshPoolPayouts() < _maxLiability() check, which still fails → reverts with CfdEngine__StillInsolvent.
  7. Price reverts — still cannot clear: Even after updating the mark price back to 1.00, the check still fails because the SHORT position's maxProfitAssets hasn't changed and pool cash hasn't increased.
  8. LP redemption frozen: An LP requests a redeem, advances to the settlement epoch, but pool.settleLpEpoch() reverts with HousePool__DegradedMode.

PoC code

Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {console} from "forge-std/console.sol";

contract DegradedGriefPoC is BasePerpTest {
    address atkLong = address(0xA001);
    address atkShort = address(0xA002);

    function test_PoC_hedgedCloseLatchesDegradedAndFreezesLp() public {
        // Fund attacker accounts with margin
        _fundTrader(atkLong, 100_000e6);
        _fundTrader(atkShort, 100_000e6);
        console.log("pool assets before", pool.totalAssets());

        // Step 1: Open hedged pair — equal LONG and SHORT notional (990k each)
        // Split across multiple orders to stay within skew limits
        _open(atkShort, CfdTypes.Side.SHORT, 390_000e18, 20_000e6, 1e8);
        _open(atkLong, CfdTypes.Side.LONG, 780_000e18, 15_000e6, 1e8);
        _open(atkShort, CfdTypes.Side.SHORT, 600_000e18, 40_000e6, 1e8);
        _open(atkLong, CfdTypes.Side.LONG, 210_000e18, 5_000e6, 1e8);
        assertFalse(engine.degradedMode());
        console.log("pool assets after opens", pool.totalAssets());

        // Step 2: Price moves 1.5% — close only the winning LONG leg
        _close(atkLong, CfdTypes.Side.LONG, 990_000e18, 98_500_000);
        console.log("pool assets after close", pool.totalAssets());

        // Step 3: Verify degraded mode latched
        assertTrue(engine.degradedMode(), "degraded latched");
        (uint256 lMax,,,) = engine.sides(0);
        (uint256 sMax,,,) = engine.sides(1);
        console.log("longMax", lMax, "shortMax", sMax);
        console.log("poolAssets", pool.totalAssets());

        // Step 4: Owner cannot clear — still insolvent by gross metric
        vm.expectRevert(ICfdEngineTypes.CfdEngine__StillInsolvent.selector);
        engine.clearDegradedMode();

        // Step 5: Even after price fully reverts, still cannot clear
        vm.prank(address(router));
        engine.updateMarkPrice(1e8, uint64(vm.getBlockTimestamp()));
        vm.expectRevert(ICfdEngineTypes.CfdEngine__StillInsolvent.selector);
        engine.clearDegradedMode();

        // Step 6: LP redemption is completely frozen
        vm.warp(vm.getBlockTimestamp() + 1 hours + 1);
        uint256 shares = juniorVault.estimateWithdrawShares(1e6);
        uint256 requestId = juniorVault.requestRedeem(shares, address(this), address(this));
        vm.warp(pool.lpEpochStart(requestId));
        vm.prank(address(router));
        engine.updateMarkPrice(1e8, uint64(vm.getBlockTimestamp()));
        uint256 markTime = engine.lastMarkTime();

        vm.expectRevert(IHousePool.HousePool__DegradedMode.selector);
        vm.prank(address(router));
        pool.settleLpEpoch(1e8, markTime);
    }
}

Test output (passes)

[PASS] test_PoC_hedgedCloseLatchesDegradedAndFreezesLp() (gas: 3048008)
Logs:
  pool assets before              1002000000000  (1,002,000 USDG)
  pool assets after opens         1002000000000  (unchanged)
  pool assets after close          987540060000  (987,540 USDG)
  longMax 0  shortMax              990000000000  (990,000 USDG)
  poolAssets                       987540060000

Suite result: ok. 1 passed; 0 failed; 0 skipped

Pool cash (987,540) < SHORT maxProfit (990,000) → degradedMode = true
clearDegradedMode() → revert CfdEngine__StillInsolvent
settleLpEpoch() → revert HousePool__DegradedMode

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

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 degraded-mode solvency check uses gross max-profit liability for the dominant side without subtracting the locked margin held against the opposing open position, so a hedged close leaves the pool looking insolvent.

Impact

All LP capital in both tranches could be frozen for an attacker-controlled, unbounded duration, blocking redemptions and new deposit settlements until the owner injects capital or the attacker closes the losing position.

What the attacker needed

Two funded accounts; capital for hedged positions; small price move

The fix

The solvency check should credit open positions' locked margin against gross max-profit liability so only the net unfunded exposure triggers degraded mode.

How it was found

  1. Fund two attacker accounts with margin and open equal-notional long and short positions split across several orders.
  2. Move the price about 1.5% so one leg is profitable, then close only the winning leg.
  3. Observe that degraded mode latches because pool cash is now below the losing side's gross max profit.
  4. Attempt to clear degraded mode and see it revert with the still-insolvent error, even after the price reverts.
  5. Request an LP redemption and see the epoch settlement revert with the degraded-mode error.

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 liquidity pool holds money that users can withdraw. The protocol has a safety switch that freezes withdrawals when it thinks the pool may not be able to pay out open trades. Here the safety check counts the full possible profit of one side of the book but ignores the money already set aside by the opposite side, so the pool looks poorer than it really is. An attacker can make the switch trip on purpose and keep it tripped, stopping everyone from withdrawing.

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.

More by papikoo

View all

1 more disclosed report, best first.

More from Plether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.