Skip to content
Business logic Audit finding Advanced

Unassigned cash is capped by an unrealized loss, then seeded to junior

The reconciliation logic caps the stored unassigned cash balance to distributable assets while a negative terminal delta exists, but never restores it once the delta recovers. An attacker who holds most junior shares can trigger a loss that wipes principal, then have the capped cash seeded back as junior principal and redeem it, taking more than they deposited.

Omisanin0 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#98992 [SC-Medium] Unassigned cash is capped by an unrealized loss, then seeded to junior

Submitted on Nov 11th 2026 at 10:55:49 UTC by @Omisanin0 for Audit Competition | Plether

Description

Brief/Intro

Recapitalization above the senior high-water mark is stored in unassignedAssets. The accounting spec says that balance is left out of the equity comparison. planReconcile caps the stored balance down to distributable assets while a negative terminal delta is on the book. The tokens stay in the pool. absorbLoss then wipes junior and senior principal and leaves the high-water mark where it is. A zero-quote junior redeem is enough epoch progress to keep the cap. When the long is closed flat, the delta comes back and the capped unassigned does not. The next settle takes the zero-principal seed. Senior is filled only up to the old high-water mark. The rest is junior principal, and the junior redeem pays it out.

On the deployed Arbitrum Sepolia v2.0.0 book, with the launch risk parameters already set, this run removed 103,011,998.238449 USDG from the unassigned label and paid the attacker 68,553,307.894544 USDG more than they deposited and posted as margin. The high-water mark did not fall. After the flat close the unassigned balance was still the capped number, and it was still that number after the redeem.

Vulnerability Details

ACCOUNTING_SPEC.md step 2 says to compare terminal equity with total principal, and to leave reserved pending inflows and unassignedAssets out of that comparison. Step 3 charges a shortfall to junior, then senior, and says losses do not reduce the senior high-water mark. Step 4 routes surplus to the high-water mark first, then to junior. Value with no claimant path is supposed to stay in unassignedAssets.

HousePoolAccountingLib.buildReconcileSnapshot sets distributable to physical assets, plus a positive terminal delta, minus trader claims, minus the absolute value of a negative terminal delta. It does not subtract unassignedAssets. The subtraction happens later, and it writes storage.

HousePoolReconcilePlanLib.planReconcile snapshots claimedEquityZero from senior principal plus junior principal before it touches unassigned (HousePoolReconcilePlanLib.sol:62). It then sets

Text
unassigned = min(unassigned, distributable)

at lines 73-74. If both principals are still nonzero, line 62 is false, so the function does not take the seed. It computes distributableToClaims as distributable - unassigned after that cap. When the negative delta is large enough that distributable has fallen to the capped unassigned, distributableToClaims is 0. HousePoolWaterfallAccountingLib.absorbLoss (HousePoolWaterfallAccountingLib.sol:167-184) then wipes junior and senior. It does not write the high-water mark.

The dip itself does not move cash. _reconcile runs at the start of _settleLpEpoch, before redemption funding. totalAssets stays min(token balance, accountedAssets). The loss is a terminal-book number. A queued redeem that now quotes zero still counts as epoch progress: the vault refunds the shares (HousePool.sol zero-quote path, then the progress check near line 1183). If that redeem were absent, HousePool__NoLpEpochProgress would revert the settle and the cap would roll back with it.

The flat close zeros the attacker's price delta. Stored unassigned stays at the capped value. getFreeAssets reserves the stored unassigned number, the max-profit envelope, and trader claims. During the dip the long's max-profit reserve still consumes the freed slice. After the close that reserve is gone, and the withdrawal snapshot is reserving the capped unassigned rather than the old one, so the capped slice is free cash.

The next settle sees both principals at 0. Line 62 is now true. Lines 76-80 seed distributable - unassigned through applyRevenueIntent with claimed-equity credit disabled. Senior is restored only up to the high-water mark that absorbLoss left alone. The remainder is junior principal, provided junior supply is nonzero. The attacker still has the shares, because the dip redeem was refunded. _reconcile books that principal before the vault prices the redemption, so the redeem is paid on the seeded number.

This is the gap-0 recap path. applyClaimantRecapitalizationIntent (HousePoolPendingPreviewLib.sol:111-137) sends the recap to unassigned when senior is at the high-water mark and both principals are nonzero. The empty-book branch, which replaces the high-water mark, is a different bug. It fires only if the recap is still pending when the wipe happens. Here the recap is settled into unassigned first, while both principals are nonzero, in an epoch that has progress.

The function comment on planReconcile states the two steps this run uses. With a fresh mark, unassigned is capped to remaining distributable value. If claimed principal is zero, the remaining distributable value is seeded through the pending-revenue rules (HousePoolReconcilePlanLib.sol:35-38). ACCOUNTING_SPEC.md line 327 also says seeded ownership continuity is preferred over governance re-assignment. A reader who stops on that comment can call the cap and the seed the rule.

That reading assigns the wrong cash. The cap is a one-way min. It only lowers the stored label. After the flat close the mark is back at the index, totalAssets is 2,123,006,990.859056, and that cash is still larger than the pre-dip unassigned balance of 1,805,571,392.518176. The label stays at 1,702,559,394.279727. A cap that tracked remaining distributable value would have let the label back up once the cash covered it again. The next settle does not. Both principals are zero, so lines 76-80 seed distributable - unassigned using the already reduced label. The 103,011,998.238449 that left the label is inside that seed.

Continuity of the wiped book would put senior back at the old high-water mark and put the other juniors back at the principal they already had. It would not pay them more. Spec line 315 and line 357 keep value with no claimant path in unassignedAssets, and a depositor does not acquire that value by holding shares. Spec lines 336-340 leave unassigned out of the equity comparison, so the shortfall is charged to principal and the unassigned balance does not move. On that rule the recovery is the wiped principal: senior up to the high-water mark, junior up to what was wiped, and the recap still unassigned.

The run splits those amounts. Of the 1,805,571,392.518176 recap, 1,702,559,394.279727 is still unassigned after the redeem. Senior finishes at 11,119,149.050776, the high-water mark from the dip, inside 1,000 USDG of the pre-dip mark. The junior balance left in the vault, which is the other holders after the attacker redeems, is 135,121,583.704301 against 102,034,940.678089 at the start. That increase is their share of the capped cash. The test requires it.

A long profits when the oracle price falls. The dip is an LP loss on that long. It is not a liquidation of the attacker. The open is a real OrderRouter.commitOrder plus executeOrder. The dip and the recovery are real OrderRouter.settleLpEpoch calls. The owner call is CfdEngine.recapitalizePool, which pulls USDG into the pool. That is the documented way surplus above the senior high-water mark becomes unassigned. The owner is the victim of the cap.

The live book already had open interest, so the long has to be large enough to clear principal after the existing book's delta at the dip price. terminalLpPriceDeltaAssetAtoms on the deployed book, read before the open, was -7,247,204.767754 USDG at the 0.40 basket. The 6,899,431 lot long is what takes the settled delta to -421,213,085.466047 USDG. The 0.40 skew cap on that size is why the owner recap is 1,805,571,392.518176 USDG. That cash is depth. After the attack, 1,702,559,394.279727 USDG of it is still labeled unassigned. The cap removed the other 103,011,998.238449 USDG from the label. An empty book hits the same lines with a much smaller recap. This run is the deployed book, skew and all.

The basket print is 39,999,997 because a print near 1.00 cannot wipe this principal under the launch skew cap. CfdEnginePlanLib sets maxSkewAssets to net depth times maxSkewRatio (CfdEnginePlanLib.sol:473). Net depth is physical assets minus trader claims (PositionRiskAccountingLib.computeNetPoolDepthAssets). Unassigned cash counts in that depth and does not count as principal. A long's loss is about its notional times the move, and the notional cannot exceed the skew cap, so the loss cannot exceed about 0.4 times depth times the move. Depth beyond principal is the recap. After the junior deposit, claimed principal is about 316 million. At a 1% move the recap has to be on the order of 250 times that principal, about 80 billion USDG, before a skew-capped long can push the loss through it. A 5% move still needs a recap of about 15 billion. The 0.40 print is the one that keeps the recap at 1.81 billion, the same order of magnitude as the book. A closer print is the same bug with a larger owner deposit. It does not become a different accounting path.

Deposits are refused once unassigned or a pending recap bucket is nonzero. The junior deposit is therefore requested and settled before recapitalizePool. The one-hour cooldown then elapses, the owner funds the pool, and a 10 USDG junior redeem is queued only so that epoch has progress. That small redeem is claimed at the end. It is a return of deposit. Claiming it before the dip request would reset lastDepositTime and block the zero-quote redeem.

The router locks the open execution bounty from free settlement before it locks marginDelta. On this deployment the bounty is capped at 0.200000 USDG. The clearinghouse deposit is the 5% margin plus that bounty. marginDelta on the order is the margin alone.

Impact Details

Impact: direct theft of user funds, at rest, other than unclaimed yield. Critical.

The stolen USDG is recapitalization cash sitting in HousePool. The cap deletes the unassigned label on 103,011,998.238449 USDG while the tokens remain in the contract. The zero-equity seed writes that amount into principal. Senior is restored to its own high-water mark. Junior holders are paid the rest in proportion to shares. The attacker held about two thirds of junior supply, redeemed, and finished 68,553,307.894544 USDG ahead of the cash they put in.

The run uses the parameters already stored on the Arbitrum Sepolia deployment: vpiFactor 0.01e18, maxSkewRatio 0.4e18, initial margin 20 bps, maintenance 10 bps. Settlement token is the deployed MockUSDG at 0x3d051DbBf5Ff427a4aE8Ad09746902666Af8FB9D, 6 decimals. At 1 USDG = $1, the figures below are the dollar amounts. Perps is not on Arbitrum One, so this is the measured loss on this book.

Item USDG
Attacker junior deposit 204,069,881.356178
Margin posted 34,497,155.000000
Open bounty posted 0.200000
Contributed 238,567,036.556178
Owner recap, routed entirely to unassigned 1,805,571,392.518176
Unassigned removed by the dip and not restored 103,011,998.238449
Junior redeem paid to the attacker 273,176,832.896255
Small redeem paid to the attacker 9.999996
Attacker ending balance 307,120,344.450722
Attacker profit 68,553,307.894544

The ending balance includes the margin that came back. Clearinghouse balance at the end is 0. Net trading drag is 553,653.445529 USDG, which is the 34,497,155.000000 margin minus the 33,943,501.554471 that the withdraw added to the wallet on top of the two redeems. Open and close execution fee is 4 bps each way on a 689,943,100 USDG notional. VPI charged on the open is rebated on the flat close. The close reduced pool cash by 765,488.886718 USDG. That rebate is the trader's own charge. It is well under half of the capped slice, and the dip itself did not change totalAssets (2,123,772,479.745774 before and after).

Junior principal just before the dip was 305,008,843.500390. The seed then paid the attacker 273,176,832.896255 and left 135,121,583.704301 in the vault. Sum of those two is 408,298,416.600556. The amount of junior principal above the pre-dip balance is 103,289,573.100166. That equals the capped 103,011,998.238449, plus the net fee the round trip left in the pool (1,043,165.292247 inflow on the open, minus 765,488.886718 rebate on the close), minus the 101.543812 coupon that raised senior principal and the high-water mark together before the wipe. The other junior holders were left with 135,121,583.704301 against a pre-attack junior principal of 102,034,940.678089. Their gain is their share of the same capped cash. The attacker sized the deposit to take the larger share.

Free cash after the flat close was 379,503,717.677819. That is what funded the redeem. Unassigned after the redeem was still 1,702,559,394.279727.

Gas printed by the test was 10,643,331. Forge metered the test call at 8,515,631. Either figure is a few dollars on Arbitrum at ordinary prices. The position stays open across one LP hour. The paying redeem is a later hour, after the one hour deposit cooldown that the share refund resets.

References

  • packages/perps/ACCOUNTING_SPEC.md lines 315, 327, 336-340, and 357. Step 2 excludes unassignedAssets from the equity comparison. Value with no claimant path stays there. A depositor does not acquire it by holding shares. Line 327 prefers seeded ownership continuity over governance re-assignment of a wiped book. That continuity restores the wiped principal. It does not assign the quarantined recap.
  • packages/perps/src/libraries/HousePoolReconcilePlanLib.sol: the function comment at lines 35-38 states the cap and the zero-principal seed. claimedEquityZero is line 62, the cap is lines 73-74, and the seed is lines 76-80. The cap only lowers the stored label.
  • packages/perps/src/libraries/CfdEnginePlanLib.sol line 473 and packages/perps/src/libraries/PositionRiskAccountingLib.sol computeNetPoolDepthAssets. Skew is 40% of physical assets minus trader claims. That bound is why the dip basket is 0.40.
  • packages/perps/src/libraries/HousePoolAccountingLib.sol: buildReconcileSnapshot lines 60-77. Distributable subtracts the absolute negative delta. It does not subtract unassigned.
  • packages/perps/src/libraries/HousePoolWaterfallAccountingLib.sol: absorbLoss lines 167-184. Principal is wiped. The high-water mark is not.
  • packages/perps/src/libraries/HousePoolPendingPreviewLib.sol: applyClaimantRecapitalizationIntent lines 111-137 routes a recap to unassigned when senior is at the high-water mark. applyRevenueIntent lines 158-187 is the seed. The empty-book high-water replacement is a different path and is not this run.
  • packages/perps/src/HousePool.sol: _settleLpEpoch reconciles before it funds redemptions. The zero-quote refund counts as progress, so HousePool__NoLpEpochProgress does not roll the cap back. getFreeAssets lines 1235-1254.
  • packages/perps/src/TerminalNavBookV2.sol: _terminalLpPriceDeltaAssetAtoms lines 320-349. A lower print on a long is a negative LP delta.
  • packages/perps/src/OrderRouter.sol: commitOrder line 85, executeOrder line 240, updateMarkPrice line 429, settleLpEpoch line 479.
  • packages/perps/src/CfdEngine.sol: recapitalizePool lines 632-653. Owner pulls USDG into the pool and records a claimant inflow.
  • packages/perps/src/PletherOracle.sol: _resolveHistoricalOrderBasket lines 596-643, _resolveCurrentBasket lines 749-800. Order window 15 seconds. Mark and settle window is the last 15 seconds.
  • Source pin a82d4fefb02768e5b3bddcc97dee371eee24fea8. The Sepolia bytecode under test is the v2.0.0 deployment. packages/perps/src at that pin matches the deployed source commit.

Proof of Concept

Proof of Concept

Run from src/packages/perps (foundry.toml: solc 0.8.35, via-IR, optimizer runs 200). Forge on this machine is 1.5.1-stable. No private key and no Pyth API key.

Bash
cd src/packages/perps
ARB_SEPOLIA_RPC_URL=https://sepolia-rollup.arbitrum.io/rpc \
forge test --match-contract UnassignedRoundTripCaptureForkTest -vv

ARB_SEPOLIA_RPC_URL defaults to https://sepolia-rollup.arbitrum.io/rpc. F669_FORK_BLOCK defaults to 0, which forks the latest block the node still serves. The passing run did that. Timestamp 1794393919. Foundry reports block.number as the Arbitrum L1 block, 12111242 on this run. The test does not require block.number to equal an L2 pin, and it does not require senior, junior, or unassigned to equal one historical triple. It logs the book it forked. This run's book was senior 11,112,650.853906 at the high-water mark, junior 102,034,940.678089, unassigned 0. An earlier head at timestamp 1794392538 had the same three balances. cast find-block 1794392538 on that RPC returns L2 block 328159251. The public node drops historical state, so that block is optional. Set F669_FORK_BLOCK only when the node still serves it. If a later book has unassigned already set, senior impaired, trading inactive, or an order queue, the test reverts and names that precondition. A book that still meets them runs the same path and prints its own amounts.

Chain id 421614. In-scope contracts are the deployed ones. No in-scope file is edited. Nothing in scope is redeployed or etched.

Contract Address
CfdEngine 0xcA18a6783D7542F9D2F28F4f259772b74C4D6bAA
HousePool 0xeB5604c393843B2f3c347Ec24Fa9dDaD6Ab2131e
Junior vault 0x4A8b67184a1E3224c11A191cc69F22C50EEf734e
PletherOracle 0x4f2c62A0E03657F52C633c19c11f88d8F0897Bb2
OrderRouter 0x918663D6Da8CB33b325a04c4A5e8c51D42F3b444
MarginClearinghouse 0xB5B851f627d6Df3CF3F096E23e20a58884D7b89A
TerminalNavBookV2 0x61C7f7Cf91c295a86250E1e05a91901e8E1e51A3
MockUSDG 0x3d051DbBf5Ff427a4aE8Ad09746902666Af8FB9D
Pyth 0x0B73614636C855Bf23F342F307FB981A3e47f42B

The owner read from engine.owner() is 0x5a71a4094Ec81165Ada48AA4c27dA48ec27E0d6B. The test pranks that address for recapitalizePool only.

Pyth in the test is MockPyth from packages/shared/test-support, etched at the oracle's existing Pyth address after new MockPyth() is deployed on the fork. The program allows a Pyth stand-in. A signed Hermes update was not available, and the test does not invent one. The payload is abi.encode(FeedUpdate[]) with exponent -8 and confidence 0. The six feed ids, bases, weights, and inversions are read from the deployed oracle. The quoted basket was 100,000,000 at the index and 39,999,997 at the dip. setFee(0) makes the update fee 0. The calls still read getUpdateFee and pass msg.value. USDG is the deployed MockUSDG. The test calls its existing mint. It does not deploy a second settlement token.

Foundry does not implement ArbSys. ArbitrumForkSupport.install() etches the repo's ForkArbSys at address 100. That shim returns block.number and nothing else, so vm.roll still separates the commit block from the execute block. No other precompile is etched. No engine, router, pool, vault, or book is mocked. Marks go through router.updateMarkPrice. Settles go through router.settleLpEpoch. Opens and the close go through router.commitOrder and router.executeOrder. The test checks ExecutionResult.status == Executed.

The order queue at the pin was empty (nextExecuteId 0, globalTailOrderId 0), so the attacker's commit is the head. Junior and senior redeem and deposit queue heads were 0. The whole warp stays on Wednesday 11 November 2026, and the test reverts if isOracleFrozen or isFadWindow becomes true.

Steps:

  1. Fork latest. Require chain id 421614, trading active, unassigned 0, senior equal to a positive high-water mark, junior principal above 0, and an empty order queue. On this run those balances were senior 11,112,650.853906, junior 102,034,940.678089, unassigned 0. Etch MockPyth. Publish the index basket through router.updateMarkPrice. The engine mark becomes 100,000,000.
  2. requestDeposit of 204,069,881.356178 USDG into the junior vault, twice the live junior principal. Warp to that LP epoch and router.settleLpEpoch at the same basket. Claim the shares: 205,660,874,001,389,362. Junior principal is now 305,009,056.584302. Senior is still at its high-water mark.
  3. After the one hour cooldown, the owner calls recapitalizePool(1,805,571,392.518176). The attacker queues a redeem of about 10 USDG of shares so the epoch has progress, and does not claim it yet. router.settleLpEpoch at the index. Unassigned becomes 1,805,571,392.518176, the whole recap. Both principals are still nonzero. Senior principal plus a 1,000 USDG tolerance still covers the high-water mark. Pending recap is 0.
  4. Deposit 34,497,155.200000 USDG to the clearinghouse (margin plus the 0.200000 bounty). commitOrder a long of 6,899,431 lots (size 689,943,100e18), target price 1, margin delta 34,497,155.000000. Two seconds and one vm.roll later, executeOrder with a unique payload whose publish time is inside (commitTime, commitTime + 15s]. Status is Executed. Entry price 100,000,000. Max profit 689,943,100.000000. Position size matches.
  5. requestRedeem the entire remaining junior balance. Warp to that epoch. router.settleLpEpoch at the dip basket 39,999,997. claimRedeemRefund returns every share that was queued. Senior principal is 0. Junior principal is 0. High-water mark is 11,119,149.050776, above the pre-dip mark. totalAssets is unchanged at 2,123,772,479.745774. Unassigned is 1,702,559,394.279727. The cap removed 103,011,998.238449. Terminal delta at the dip is -421,213,085.466047.
  6. commitOrder and executeOrder close the full long at the index basket. Target price is CAP_PRICE. Size is 0. Unassigned is still 1,702,559,394.279727. Terminal delta is back to -1,030,030.927997, the pre-existing book at the index. Pool cash falls by the 765,488.886718 VPI rebate. getFreeAssets is 379,503,717.677819.
  7. The refund set lastDepositTime. After one hour plus one second, requestRedeem all shares again. router.settleLpEpoch at the index. The seed runs before the redeem is funded. claimRedeem pays 273,176,832.896255. The earlier 10 USDG redeem pays 9.999996. withdraw takes the clearinghouse balance to the wallet. Unassigned is still 1,702,559,394.279727. Senior principal equals the high-water mark, 11,119,149.050776. Junior principal left in the vault is 135,121,583.704301.

The test requires the wipe, the unchanged high-water mark, the cash-neutral dip, the cap above half of the 50,000,000 USDG surplus it sized for, the unassigned balance frozen across the close, and pool cash after that close still above the pre-dip unassigned label. It requires free cash above half the cap, a nonzero exit, senior restored to the high-water mark and within 1,000 USDG of the pre-dip mark, the junior balance left in the vault above the starting junior principal, and ending > contributed.

Text
fork timestamp 1794393919
vpiFactor 10000000000000000
maxSkewRatio 400000000000000000
initMarginBps 20
indexPrice 100000000
dipPrice 39999997
preDipDelta -7247204767754
deposit 204069881356178
recap 1805571392518176
margin 34497155000000
openBounty 200000
lots 6899431
notional 689943100000000
entryPrice 100000000
maxProfit 689943100000000
cappedAway 103011998238449
senior after dip 0
junior after dip 0
hwm after dip 11119149050776
unassigned after dip 1702559394279727
totalAssets after dip 2123772479745774
terminalDelta at dip -421213085466047
unassigned after close 1702559394279727
closeRebate 765488886718
freeAfterClose 379503717677819
exitAssets 273176832896255
smallRedeemAssets 9999996
unassigned after exit 1702559394279727
senior after exit 11119149050776
junior left 135121583704301
passiveJuniorLeft 135121583704301
contributed 238567036556178
wallet 307120344450722
clearing 0
ending 307120344450722
profit 68553307894544
fundsAtRiskCappedUnassigned 103011998238449
gas 10643331

Full test, src/packages/perps/test/perps/poc/UnassignedRoundTripCaptureFork.t.sol:

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

import {ArbitrumForkSupport} from "@plether/test-utils/ArbitrumForkSupport.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {Test} from "forge-std/Test.sol";
import {console2} from "forge-std/console2.sol";

/// @notice Fork PoC for F-669 on the Arbitrum Sepolia v2.0.0 deployment.
/// @dev Plether accepts a local fork and mocks only for Pyth and USDG. This test forks the
///      deployed in-scope contracts, etches MockPyth at the oracle's Pyth address, and mints the
///      deployed MockUSDG. It does not redeploy or etch any in-scope contract.
///      Foundry does not implement ArbSys. `ArbitrumForkSupport` etches address(100) with a shim
///      whose only behavior is `arbBlockNumber() = block.number`, so `vm.roll` preserves the
///      same-L2-block check. No other precompile is etched.
///
///      Run from `src/packages/perps` (do not broadcast):
///      ARB_SEPOLIA_RPC_URL=https://sepolia-rollup.arbitrum.io/rpc \
///      forge test --match-contract UnassignedRoundTripCaptureForkTest -vv
///      The public rollup node prunes older account state. The default pin is the latest block.
///      Set F669_FORK_BLOCK to a still-served L2 block to reproduce a specific pin.
///      setUp does not pin senior, junior, or unassigned to one block's atoms. The attack requires
///      trading active, unassigned zero, senior equal to a positive high-water mark, and an empty
///      order queue. Deposit, long, and recap are sized from that book.
contract UnassignedRoundTripCaptureForkTest is Test {

    /// @dev Zero selects the latest block the RPC still serves.
    uint256 internal constant FORK_BLOCK = 0;
    uint256 internal constant INDEX_TARGET = 100_000_000;
    uint256 internal constant DIP_TARGET = 40_000_000;
    uint256 internal constant SURPLUS = 50_000_000e6;
    uint256 internal constant CHAINLINK_TO_TOKEN_SCALE = 1e10;
    uint256 internal constant LOT = 1e20;

    address internal constant ENGINE = 0xcA18a6783D7542F9D2F28F4f259772b74C4D6bAA;
    address internal constant POOL = 0xeB5604c393843B2f3c347Ec24Fa9dDaD6Ab2131e;
    address internal constant JUNIOR = 0x4A8b67184a1E3224c11A191cc69F22C50EEf734e;
    address internal constant ORACLE = 0x4f2c62A0E03657F52C633c19c11f88d8F0897Bb2;
    address internal constant ROUTER = 0x918663D6Da8CB33b325a04c4A5e8c51D42F3b444;
    address internal constant CLEARING = 0xB5B851f627d6Df3CF3F096E23e20a58884D7b89A;
    address internal constant BOOK = 0x61C7f7Cf91c295a86250E1e05a91901e8E1e51A3;
    address internal constant USDG = 0x3d051DbBf5Ff427a4aE8Ad09746902666Af8FB9D;
    address internal constant EXPECTED_PYTH = 0x0B73614636C855Bf23F342F307FB981A3e47f42B;

    IEngine internal constant engine = IEngine(ENGINE);
    IPool internal constant pool = IPool(POOL);
    IJunior internal constant junior = IJunior(JUNIOR);
    IOracle internal constant oracle = IOracle(ORACLE);
    IRouter internal constant router = IRouter(ROUTER);
    IClearing internal constant clearing = IClearing(CLEARING);
    IBook internal constant book = IBook(BOOK);
    IMintUSDG internal constant usdg = IMintUSDG(USDG);

    address internal attacker;
    address internal owner;
    address internal pythAddr;

    uint256 internal feedCount;
    bytes32[8] internal feedIds;
    uint256[8] internal bases;
    uint256[8] internal weights;
    bool[8] internal inverted;
    int64[8] internal indexRaw;
    int64[8] internal dipRaw;

    uint256 internal indexPrice;
    uint256 internal dipPrice;
    uint256 internal depositAssets;
    uint256 internal recapAssets;
    uint256 internal marginAssets;
    uint256 internal openBountyAssets;
    uint256 internal openSize;
    uint256 internal contributed;
    uint256 internal hwmBeforeDip;
    uint256 internal assetsBeforeDip;
    uint256 internal unassignedBeforeDip;
    uint256 internal unassignedAfterDip;
    uint256 internal cappedAway;
    uint256 internal juniorAtStart;
    uint256 internal gasStart;

    function setUp() public {
        string memory rpc = vm.envOr("ARB_SEPOLIA_RPC_URL", string("https://sepolia-rollup.arbitrum.io/rpc"));
        uint256 pin = vm.envOr("F669_FORK_BLOCK", FORK_BLOCK);
        if (pin == 0) {
            vm.createSelectFork(rpc);
        } else {
            vm.createSelectFork(rpc, pin);
        }
        require(block.chainid == 421_614, "Arbitrum Sepolia chain id");
        // Foundry reports the L1 block in `block.number` on this Arbitrum fork. The attack does not
        // require one historical senior, junior, and unassigned triple. It logs the book it forked.
        console2.log("fork L1 block.number", block.number);
        console2.log("fork L2 pin", pin);
        console2.log("fork timestamp", vm.getBlockTimestamp());
        console2.log("fork senior", pool.seniorPrincipal());
        console2.log("fork junior", pool.juniorPrincipal());
        console2.log("fork hwm", pool.seniorHighWaterMark());
        console2.log("fork unassigned", pool.unassignedAssets());
        require(POOL.code.length > 1000, "pool code");
        require(ENGINE.code.length > 1000, "engine code");
        require(ROUTER.code.length > 1000, "router code");

        // ArbSys precompile shim. Returns Foundry block.number and nothing else.
      

The original report as published on Immunefi, by Omisanin0. 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 cap on unassigned assets is applied as a one-way minimum during a negative delta and is never recomputed upward after the delta recovers, so the reduced label is later seeded into principal.

Impact

The attacker could take roughly 68.5 million USDG more than they put in, drawn from recapitalisation cash, while other junior holders also gain a share of the capped amount.

What the attacker needed

Owner recapitalises the pool; attacker holds most junior shares; one-hour deposit cooldown elapses; large long position opened

The fix

The cap should track remaining distributable value so the unassigned label can rise again once cash covers it, rather than being a one-way minimum.

How it was found

  1. Fork the deployment, confirm trading is active with unassigned at zero and both principals positive, then publish the index basket.
  2. Deposit a large junior amount, settle the epoch and claim the shares.
  3. After the cooldown the owner recapitalises the pool, and a small redeem is queued so the epoch has progress.
  4. Post margin and open a large long through the order router.
  5. Queue a full junior redeem, settle at the dip basket so principal is wiped and the unassigned label is capped, then claim the refunded shares.
  6. Close the long flat, then after the cooldown redeem all shares and withdraw, receiving more than was contributed.

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 pool keeps some cash that belongs to nobody in particular, called unassigned. A rule meant to protect the books shrinks that label during a bad trading moment but never grows it back when things recover. Because the cash is still physically there, a later step hands it out as if it were ordinary investor money, and the attacker collects it.

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 Omisanin0

View all

10 more disclosed reports, 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.