Skip to content
Business logic Audit finding Advanced

A settlement at a temporary low mark permanently clips unassignedAssets in planReconcile, and the rebound moves the owner's recapitalization into Junior principal that the attacker redeems

When a reconcile happens at a temporary low mark, the pool's ownerless `unassignedAssets` balance is clipped down to the distributable value and the clipped amount is never recorded. On the rebound the recovery is routed to the Senior gap and then Junior principal, so an incumbent Junior LP can settle at the dip and later redeem recapitalisation capital that should have stayed unassigned.

emanueldlvg Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99885 [SC-Medium] A settlement at a temporary low mark permanently clips unassignedAssets in planReconcile, and the rebound moves the owner's recapitalization into Junior principal that the attacker redeems

Submitted on Nov 15th 2026 at 16:24:54 UTC by @emanueldlvg for Audit Competition | Plether

Description

Affected contracts (in-scope commit a82d4fef; live on Arbitrum Sepolia v2.0.0)

The program states that the v2.0.0 Arbitrum Sepolia release is built from a commit whose packages/perps/src is identical to a82d4fef. The defect is in the reconciliation libraries that HousePool inlines (HousePoolReconcilePlanLib, HousePoolPendingPreviewLib) and in HousePool._reconcile, which stores their result. The proof of concept runs in the repository's Foundry suite at the in-scope commit, with the release parameters, Pyth mocked by the suite's MockPyth and USDG by the suite's mock settlement token. No in-scope contract is modified.

Contract Arbitrum Sepolia v2.0.0 address Role in the issue
HousePool 0xeb5604c393843b2f3c347ec24fa9ddad6ab2131e Root cause. _reconcile stores unassignedAssets = min(U, D) from the inlined HousePoolReconcilePlanLib.planReconcile and keeps no record of the clipped amount. The next reconcile routes the recovery through HousePoolPendingPreviewLib.applyRevenueIntent to the Senior gap and Junior principal. assignUnassignedAssets later pays the owner only what is left
CfdEngine 0xca18a6783d7542f9d2f28f4f259772b74c4d6baa recapitalizePool, the owner's documented recovery action that creates unassignedAssets
OrderRouter 0x918663d6da8cb33b325a04c4a5e8c51d42f3b444 Public settleLpEpoch(bytes[]) the attacker calls as keeper at the low mark; public commitOrder / executeOrder / updateMarkPrice
TrancheVault (Junior) 0x4a8b67184a1e3224c11a191cc69f22c50eef734e Junior redemptions that pay out the moved recapitalization
TrancheVault (Senior) 0x5dc42ba5a1e8dd3e1b6868d10f66a9bf8fb5b83d Senior redemption (unchanged apart from coupon dust)
PletherOracle 0x4f2c62a0e03657f52c633c19c11f88d8f0897bb2 Validates the PoolReconcile and order baskets

Release configuration used (packages/perps/DEPLOYMENT.md): vpiFactor 0.01, maxSkewRatio 0.4, maintenance margin 0.1 %, initial margin 0.2 %, frozen-market margin 3 %, base carry 5 %, liquidation bounty 10 bps (minimum 1 USDG, 50 % keeper share), execution fee 0.04 % and settlement buffer 0.25 % (asserted), Senior cap 40,000,000 USDG and 80 % of the pool (applied through the owner's timelocked setter and asserted), Senior coupon 800 bps (pool default), Junior maintenance fee 0, 1 USDG seed in each tranche. The release Router configuration is applied through the owner's 72-hour timelocked path: maxExecutionWindowSeconds 60, orderExecutionStalenessLimit 60, liquidationStalenessLimit 15, basketMaxConfidenceRatioBps 10, orderSettlementWindow 15, maxComponentPublishTimeDivergence 5, adverseConfidenceMultiplierBps 2500, minOpenNotionalAssets 1,000 USDG, open-order bounty 1 bp (0.01–0.2 USDG), protection trigger bounty 0.2 USDG, maxPendingOrders 5, minEngineGas 600,000, maxPruneOrdersPerCall 64. Every mark moves at most 1 % and passes the oracle's ordering and freshness checks during a live Monday session (no frozen-market mode).

Brief/Intro

unassignedAssets (U) holds pool value that has no LP owner, typically the part of an owner recapitalization that exceeds the Senior high-water-mark gap. Only the owner may assign it, through assignUnassignedAssets. The protocol's stated invariant is that this value "cannot silently become windfall LP ownership" and that "recapitalization never accrues to junior principal".

Reconciliation protects U behind both tranches: a loss is charged to Junior, then Senior, and reaches U only when terminal distributable value D falls below U. At that point HousePoolReconcilePlanLib.planReconcile clips U to D, and HousePool._reconcile stores the clipped value. Nothing records how much was clipped. When the price recovers, the next reconcile finds zero claimed principal and routes the whole recovery through applyRevenueIntent: first to the Senior high-water-mark gap, then to Junior principal. U is never restored. A temporary mark-to-market dip is therefore turned into a permanent transfer of the owner's recapitalization capital to Junior holders.

Any caller can decide whether the dip is persisted, because LP settlement is permissionless through OrderRouter.settleLpEpoch. An incumbent Junior LP opens a position that U helps back, waits for an ordinary 2 % basket move, settles at the low mark with its own 2 USDG redemption as progress, waits for the rebound, and redeems.

In the proof of concept, after the owner's documented recapitalizePool(1,000,000), the 2 % dip-and-rebound clips U from 1,000,000.000000 to 995,341.236707 USDG. The owner's later assignUnassignedAssets receives 4,658.763293 USDG less than in the control run without the low-mark settlement. Junior principal after the rebound is higher by 4,658.825625 USDG (the clipped amount plus 0.062332 USDG, mostly Senior coupon that did not accrue while Senior principal was zero), and the attacker's total balance is +3,743.147766 USDG higher (80.34 % of the clipped amount). The honest Junior LP receives the rest. With a 3 % move the owner loses 14,648.763293 USDG and the attacker gains 11,769.653065 USDG. The attacker's trading accounts end with the same balance in the attack and the control run, so the whole gain is the clipped recapitalization.

Impact: Critical — Direct theft of funds (protocol recapitalization capital held in unassignedAssets is moved into Junior principal and redeemed by the attacker).

Vulnerability Details

unassignedAssets is the last loss layer, and a reconcile clips it to distributable value

HousePoolReconcilePlanLib.sol, lines 68–82:

Solidity
if (pendingBucketAssets > 0) {
    snapshot.distributable =
        snapshot.distributable > pendingBucketAssets ? snapshot.distributable - pendingBucketAssets : 0;
}

plan.state.unassignedAssets =
    state.unassignedAssets > snapshot.distributable ? snapshot.distributable : state.unassignedAssets;

if (plan.claimedEquityZero) {
    uint256 seededDistributableToClaims = snapshot.distributable > plan.state.unassignedAssets
        ? snapshot.distributable - plan.state.unassignedAssets
        : 0;
    HousePoolPendingPreviewLib.applyRevenueIntent(plan.state, seededDistributableToClaims);
    return plan;
}

The ordinary waterfall below these lines compares distributable - unassignedAssets with claimed principal and charges any shortfall to Junior, then Senior (lines 84–105). U is touched only when D is below U, which means both tranches are already wiped. Lines 73–74 then lower U to D.

The clip is stored, and nothing remembers it

HousePool.sol, lines 1584–1596:

Solidity
_setWaterfallState(plan.state.waterfall);
unassignedAssets = plan.state.unassignedAssets;

if (markFresh) {
    terminalDeficitAssets = reconcileSnapshot.deficit;
    lastReconcileTime = block.timestamp;

    uint256 juniorRevenueWithoutOwners = HousePoolReconcilePlanLib.juniorRevenueWithoutOwners(plan);
    if (juniorRevenueWithoutOwners > 0) {
        juniorPrincipal -= juniorRevenueWithoutOwners;
        unassignedAssets += juniorRevenueWithoutOwners;
    }
}

There is no "unassigned high-water mark" or deficit field. The only way back into U is the juniorRevenueWithoutOwners branch, which applies only when Junior has zero share supply. With live Junior holders it never applies.

The Senior tranche has exactly the protection U lacks. absorbLoss keeps the Senior high-water mark through a loss: it is "deliberately unchanged so future revenue continues to restore senior impairment" (HousePoolWaterfallAccountingLib.sol, lines 162–163).

The recovery goes to the Senior gap and Junior principal, never back to U

After the clip, stored Senior and Junior principal are both zero, so the next reconcile at a recovered mark takes the claimedEquityZero branch above and passes D - U' to applyRevenueIntent.

HousePoolPendingPreviewLib.sol, lines 158–188:

Solidity
function applyRevenueIntent(
    PendingAccountingState memory state,
    uint256 amount,
    bool allowClaimedEquity
) internal pure {
    if (!allowClaimedEquity && state.waterfall.seniorPrincipal + state.waterfall.juniorPrincipal != 0) {
        state.unassignedAssets += amount;
        return;
    }

    uint256 remaining = amount;
    if (state.seniorSupply > 0) {
        uint256 gap = state.waterfall.seniorHighWaterMark > state.waterfall.seniorPrincipal
            ? state.waterfall.seniorHighWaterMark - state.waterfall.seniorPrincipal
            : 0;
        if (gap > 0) {
            uint256 seniorAssignedAssets = remaining > gap ? gap : remaining;
            state.waterfall.seniorPrincipal += seniorAssignedAssets;
            remaining -= seniorAssignedAssets;
        }
    }

    if (remaining > 0 && state.juniorSupply > 0) {
        state.waterfall.juniorPrincipal += remaining;
        remaining = 0;
    }

    if (remaining > 0) {
        state.unassignedAssets += remaining;
    }
}

Senior is restored to its preserved high-water mark, and everything else, including the U that was clipped, becomes Junior principal. In the proof of concept, the stored Senior high-water mark of 5,001.154576 USDG is restored exactly, and Junior principal receives the 4,658.763293 USDG clipped from U.

What the protocol promises about unassignedAssets

The code and documentation state that ownerless value, and recapitalization in particular, must not reach LP principal without the owner's explicit assignment:

  • HousePoolPendingPreviewLib.sol, lines 103–107 (the recapitalization router): "Any remainder, including all value when there are no senior owners, becomes unassigned; recapitalization never accrues to junior principal."
  • HousePool.sol, line 657 (assignUnassignedAssets): "Prevents later LPs from implicitly capturing previously ownerless value."
  • INTERNAL_ARCHITECTURE_MAP.md, line 75: "Unassigned assets | Recognized Pool assets lacking an LP claimant path | Require explicit assignment; cannot silently become windfall LP ownership."
  • ACCOUNTING_SPEC.md, lines 356–357: "Revenue with no eligible share owner is routed to unassignedAssets; a new depositor cannot acquire it simply by being first to deposit."

The clip-and-recover path breaks all of these. Without any assignment, the recapitalization becomes Junior principal and is redeemed as ordinary Junior NAV.

What the attacker controls

The attacker does not move the market. It controls three things, all through public calls:

  1. Exposure. U is pool capital, so it counts as backing for new positions. After the 1,000,000 USDG recapitalization, the pool's assets are 1,015,321.236707 USDG against 999,000 USDG of maximum LONG liability. The attacker can therefore hold a 999,000 USDG LONG against about 10,000 USDG of tranche capital, which puts the clip threshold at about a 1.5 % move.
  2. Whether the dip is persisted. OrderRouter.settleLpEpoch is permissionless. The attacker calls it with a valid PoolReconcile basket at the low mark. Settlement needs queue progress, and the attacker supplies it with its own 2 USDG Junior redemption. At zero Junior NAV that redemption is refunded, which counts as progress. Without this call, as in the control run, the dip is never recorded and U stays whole.
  3. Timing. The clip can only be persisted once D < U. At a 1 % move (D = 1,005,331.236707 USDG > U), the pending reconcile charges only Junior, and a settlement reverts with HousePool__NoLpEpochProgress. At 2 % the preview wipes both tranches and the settlement goes through (test_Threshold_ClipRequiresDistributableBelowUnassigned).

The objections: "ownerless telemetry", an exogenous move, and the honest Junior LP's gain

U is ownerless, so nobody is robbed. U has no LP owner, but it is not free for anyone to take. It is protocol capital that came from the owner's wallet through recapitalizePool, and only the owner can assign it. In the proof of concept the owner assigns it with assignUnassignedAssets and receives 4,658.763293 USDG less (14,648.763293 at 3 %). ACCOUNTING_SPEC.md line 652 ("unassignedAssets should be exceptional telemetry, not a normal operating bucket") describes how often U is expected to be non-zero, not who may take it. The program states: "A report is not out of scope only because a privileged address is affected by the exploit", and "a legitimate, documented action by a trusted role that triggers a bug harming users or the protocol" is in scope. The owner's only action before the attack is the documented recapitalizePool. SECURITY.md describes it as an immediate recovery action ("The pool queues claimant allocation for normal reconciliation"), and ACCOUNTING_SPEC.md line 642 says reconciliation "allocates the queued amount to senior restoration or unassigned assets".

The move is exogenous. The attacker needs a real 2 % basket move followed by a rebound, and it holds an ordinary directional position while waiting. The defect does not depend on who causes the move. It is that a temporary mark becomes permanent ownership accounting whenever someone settles at it, and settling is a public action the attacker chooses. The attacker's trading accounts end with 155,094.080122 USDG in the attack run and 155,094.081507 USDG in the control run. The low-mark settlement adds no trading cost and no trading risk beyond what the position already carries in both runs. Under the program's feasibility rules, impact is assessed first and feasibility limitations change only the amount paid, not the severity.

The honest Junior LPs gain too. They do. The clipped recapitalization is credited to Junior principal pro rata, so the honest Junior LP in the proof of concept receives 914.742596 USDG more. That does not reduce the theft. The protocol loses 4,658.763293 USDG, and the attacker, who holds most of the Junior supply, takes 80.34 % of it. A larger Junior position captures a larger share.

The Senior LP is not harmed. Its high-water mark is restored exactly. It receives 5,000.152993 USDG against 5,000.213928 USDG in the control run, a 0.060935 USDG difference in coupon accrued while Senior principal was zero.

Exploitation

All steps below are in test_Attack_TwoPercentDipSettlementMovesRecapitalizationIntoJunior. The control run starts from the same EVM snapshot, with identical marks, trades and timing, and omits only step 6. LP capital, trades, marks and settlements go through the public TrancheVault, HousePool, OrderRouter and CfdEngine entry points.

  1. Setup (Monday 10:00 UTC, live FX session). Through the public request/settle/claim path, Junior receives the attacker's 4,000 USDG, two attacker wallets' 20 and 2 USDG, and an honest Junior LP's 978 USDG. Senior receives an honest Senior LP's 5,000 USDG. Each tranche also holds its 1 USDG seed.
  2. Owner, documented action. The owner calls CfdEngine.recapitalizePool(1,000,000 USDG) while Senior sits at its high-water mark. The 20 USDG attacker wallet exits through an ordinary settlement, which applies the recapitalization. Because there is no Senior gap, all of it becomes unassigned. State: U = 1,000,000.000000, Senior principal = Senior high-water mark = 5,001.093021, Junior principal = 4,980.907345.
  3. Attacker positions. Two attacker trading accounts, each funded with 80,000 USDG, open three interleaved LONG/SHORT pairs of 333,000 USDG notional with 20,000 USDG margin each order, within the 40 % skew cap. The SHORT account then closes at the entry price of 1.00. A 999,000 USDG LONG remains. Maximum liability is 999,000.000000 against pool assets of 1,015,321.236707.
  4. The 2 USDG attacker wallet requests redemption of its whole Junior balance, which provides queue progress for step 6.
  5. Dip. Ordinary marks every 10 minutes: 1.00 → 0.99 → 0.98. At 0.98, terminal distributable D = 995,341.236707 < U.
  6. Attacker as keeper. The attacker calls OrderRouter.settleLpEpoch with a valid PoolReconcile basket at 0.98. The 2 USDG head is refunded at zero Junior NAV (0 shares funded). Afterwards: Senior principal 0, Junior principal 0, Senior high-water mark 5,001.154576, U = 995,341.236707.
  7. The Senior LP, the attacker and the honest Junior LP request full redemptions. One hour later, the price returns to 1.00 in two 1 % marks, and the attacker closes its LONG at 1.00.
  8. A keeper settles (no open positions). Recovery reconcile: Senior principal 5,001.154576 (restored to its high-water mark), Junior principal 13,745.128961 (control: 9,086.303336), U stays 995,341.236707 (control: 1,000,000.000000).
  9. Claims: attacker 11,038.051167 USDG (control 7,296.772655), honest Junior LP 2,698.803510 (control 1,784.060914), Senior LP 5,000.152993 (control 5,000.213928).
  10. Owner, documented action. assignUnassignedAssets(false, receiver) assigns 995,341.236707 USDG (control: 1,000,000.000000).
  11. Attacker total (Junior redemption, both wallets, both trading accounts): 166,157.649948 USDG against 162,414.502182 in the control run, +3,743.147766 USDG. The attacker's net result moves from -1,607.497818 to +2,135.649948 USDG on 164,022 USDG deposited.

test_Attack_ThreePercentDipClipScalesWithMove repeats the scenario with a 3 % dip (three 1 % marks to 0.97): U is clipped to 985,351.236707, the owner loses 14,648.763293 USDG, and the attacker gains 11,769.653065 USDG (net +10,161.815609 instead of -1,607.837456).

Impact Details

Critical — Direct theft of funds. Protocol-owned recapitalization capital in unassignedAssets is transferred into Junior principal and redeemed by an unprivileged Junior LP. Nobody assigns it, and it does not pass through any owner decision.

  • Protocol loss: 4,658.763293 USDG with a 2 % move and 14,648.763293 USDG with a 3 % move. Each is the exact shortfall in the owner's later assignUnassignedAssets. The clip equals the amount by which terminal distributable value falls below U at the settled mark, so it is bounded only by U.
  • Attacker gain: +3,743.147766 USDG (2 %) and +11,769.653065 USDG (3 %), 80.34 % of the clipped amount in both runs (its share of Junior supply). The rest goes to the honest Junior LP. The Senior LP's result is unchanged apart from 0.06 USDG of coupon.
  • Reachability: the owner's only pre-attack action is a documented recapitalizePool. Any recapitalization above the Senior high-water-mark gap lands in U through normal reconciliation, as ACCOUNTING_SPEC.md line 642 states. U then backs new positions. Every attacker step is a public call (requestDeposit, requestRedeem, commitOrder, executeOrder, updateMarkPrice, OrderRouter.settleLpEpoch, claimRedeem). The market path is two ordinary 1 % marks down and two back. While U is non-zero, deposits are blocked, so the beneficiaries are the incumbent Junior holders, and the attacker is one of them.
  • No undo: once the clip is stored, no field remembers it, so no later reconcile restores U. The rebound reconcile in the proof of concept leaves U at 995,341.236707 USDG while Junior principal carries the difference, and the owner's documented assignment can only assign what is left.

Recommendation

Give U the same loss memory that Senior already has. When a reconcile clips U, record the clipped amount, and restore it first on the following revenue, before the Senior gap and Junior:

Solidity
// HousePoolReconcilePlanLib.planReconcile
uint256 clipped = state.unassignedAssets > snapshot.distributable ? state.unassignedAssets - snapshot.distributable : 0;
plan.state.unassignedAssets = state.unassignedAssets - clipped;
plan.state.unassignedImpairmentAssets += clipped; // new stored field

// on any later revenue (claimed-zero seeding and waterfall revenue alike):
uint256 restore = _min(revenue, plan.state.unassignedImpairmentAssets);
plan.state.unassignedAssets += restore;
plan.state.unassignedImpairmentAssets -= restore;
revenue -= restore; // only the remainder reaches the Senior gap and Junior

assignUnassignedAssets should also clear the impairment field, so the owner's explicit assignment decides who absorbs a realized loss of U. An alternative that is easier to reason about is to keep U outside mark-to-market reconciliation and reserve it, like pending claimant buckets, so that only realized losses can reduce it.

Add a path-independence invariant test: for any dip-and-rebound mark sequence, U, Senior principal and Junior principal after the rebound must be the same whether or not a settlement happened at the intermediate low mark, apart from coupon accrual.

Proof of Concept

Save the test below as packages/perps/test/perps/poc/UnassignedAssetsClipRecovery.t.sol and run from the repository root:

Bash
forge test --root packages/perps --match-contract UnassignedAssetsClipRecoveryPoC -vv

The file contains four tests:

  • test_Attack_TwoPercentDipSettlementMovesRecapitalizationIntoJunior: control and attack from one snapshot, 2 % dip;
  • test_Attack_ThreePercentDipClipScalesWithMove: the same with a 3 % dip;
  • test_Control_NoLowMarkSettlementKeepsRecapitalizationUnassigned: the control run alone; U is untouched and the owner assigns the full 1,000,000 USDG;
  • test_Threshold_ClipRequiresDistributableBelowUnassigned: at a 1 % move D stays above U, only Junior is charged in preview, and a settlement reverts with HousePool__NoLpEpochProgress. At 2 % both tranches are wiped and the settled U equals D.

It uses the repository's BasePerpTest, the suite's MockPyth and mock settlement token, and only public entry points for every non-owner action. There is no vm.store, etch or mockCall on in-scope contracts.

Complete test:

<details> <summary>Complete test </summary>
Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {HousePoolEngineViewTypes} from "@plether/perps/interfaces/HousePoolEngineViewTypes.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {HousePoolAccountingLib} from "@plether/perps/libraries/HousePoolAccountingLib.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";

/// @title A low-mark LP settlement clips `unassignedAssets` and the rebound credits the clipped recapitalization to
///        Junior principal
/// @notice Claimed impact: Critical - Direct theft of funds (owner recapitalization capital held as `unassignedAssets`
///         is moved into Junior principal that an incumbent Junior LP redeems).
///
///         Root cause: HousePoolReconcilePlanLib.planReconcile (lines 73-74) writes `unassignedAssets = min(U, D)` on a
///         reconcile whose terminal distributable D is below U, HousePool._reconcile (line 1585) stores it, and no
///         field remembers the clipped amount. The next reconcile at a recovered mark takes the claimed-zero branch
///         (lines 76-81): `applyRevenueIntent(D - U')` fills the Senior high-water-mark gap and then Junior principal.
///         Nothing restores U.
///
///         Scenario (release parameters; MockPyth and mock USDG are the only mocks; the owner performs one documented
///         action before the attack and one documented action after it):
///           1. LPs enter through request/settle/claim: Senior 5,000; Junior 5,000 (attacker 4,000 + two attacker
///              wallets 22, an honest Junior LP 978); 1 USDG seeds each.
///           2. Owner: CfdEngine.recapitalizePool(1,000,000) while Senior sits at its high-water mark. An ordinary
///              settlement routes all of it to `unassignedAssets` (no Senior gap to restore).
///           3. Attacker (two trading accounts) opens an interleaved 999k/999k LONG/SHORT hedge under the 40% skew
///              cap, then closes the SHORT at entry: 999k LONG exposure remains.
///           4. Ordinary <= 1% basket marks move the price down (the LONG gains). At the lowest mark the attacker,
///              acting as a permissionless keeper, calls Router.settleLpEpoch with a valid PoolReconcile update;
///              progress is a 2 USDG Junior redemption from an attacker wallet that is refunded at zero Junior NAV.
///           5. The price returns to 1.00. The attacker closes the LONG at entry; a permissionless settlement funds
///              everyone's full exits (Senior LP, attacker, the honest Junior LP).
///           6. Owner: assignUnassignedAssets(false, receiver), the documented way to recover ownerless value.
///         Control: identical marks, trades and timing without the settlement at the low mark.
contract UnassignedAssetsClipRecoveryPoC is BasePerpTest {

    // --- actors ---
    address internal constant SENIOR_LP = address(0x5E1105);
    address internal constant ATTACKER = address(0xA77AC4); // incumbent Junior LP; also trader owner and keeper
    address internal constant ATK_LONG = address(0xA770A1); // attacker trading account (LONG leg)
    address internal constant ATK_SHORT = address(0xA770C2); // attacker trading account (SHORT leg)
    address internal constant HELPER_A = address(0xA77A01); // attacker helper: progress for the recap settlement
    address internal constant HELPER_B = address(0xA77A02); // attacker helper: progress for the low-mark settlement
    address internal constant OTHER_JR = address(0x1D2001); // a second, honest incumbent Junior LP (not the attacker)
    address internal constant KEEPER = address(0xE0EC);
    address internal constant OWNER_RECEIVER = address(0x0E1105);

    // --- scenario constants ---
    uint256 internal constant ENTRY_PRICE = 1e8;
    uint256 internal constant PRICE_STEP = 1_000_000; // 0.01 = one ordinary <= 1% basket mark
    uint256 internal constant STEP_SECONDS = 10 minutes;
    uint256 internal constant SENIOR_DEPOSIT = 5000e6;
    uint256 internal constant ATTACKER_JUNIOR = 4000e6;
    uint256 internal constant OTHER_JUNIOR = 978e6;
    uint256 internal constant HELPER_A_JUNIOR = 20e6;
    uint256 internal constant HELPER_B_JUNIOR = 2e6;
    uint256 internal constant RECAP = 1_000_000e6;
    uint256 internal constant CHUNK_SIZE = 333_000e18; // 333,000 USDG notional per order at 1.00
    uint256 internal constant CHUNKS = 3; // 999,000 USDG per leg, interleaved to respect maxSkewRatio
    uint256 internal constant CHUNK_MARGIN = 20_000e6;
    uint256 internal constant TRADER_FUNDING = 80_000e6;

    uint256 internal curPrice;
    uint256 internal orderNonce;
    uint256 internal helperBRequest;
    uint256 internal helperBShares;
    uint256 internal helperAUsdg;

    struct Run {
        uint256 dipPrice;
        bool dipSettled;
        uint256 dDip; // terminal distributable at the lowest mark (same lens the pool uses)
        uint256 sDip;
        uint256 jDip;
        uint256 hDip;
        uint256 uDip;
        uint256 previewS; // getPendingTrancheState right before the recovery settlement
        uint256 previewJ;
        uint256 sRec; // after the recovery reconcile (funded exits added back)
        uint256 jRec;
        uint256 hBeforeRec;
        uint256 uRec;
        uint256 juniorSupplyRec;
        uint256 seniorUsdg;
        uint256 attackerUsdg;
        uint256 otherUsdg;
        uint256 helperBValue;
        uint256 traderBalances;
        uint256 assigned;
        uint256 attackerTotal;
    }

    // ------------------------------------------------------------------ configuration (release values)

    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        // packages/perps/DEPLOYMENT.md "Initial release parameters".
        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 override returns (uint256) {
        return 0;
    }

    function _initialJuniorSeedDeposit() internal pure override returns (uint256) {
        return 1e6;
    }

    function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
        return 1e6;
    }

    function setUp() public override {
        super.setUp();
        _applyReleaseRouterConfig();
        _setSeniorCapacity(40_000_000e6, 8000);
        assertEq(pool.maxSeniorShareBps(), 8000, "release Senior share cap");
        assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "release Senior exposure cap");
        assertEq(engine.executionFeeBps(), 4, "release execution fee");
        assertEq(engine.settlementBufferBps(), 25, "release settlement buffer");
        vm.warp(SETUP_TIMESTAMP + 7 days); // Monday 10:00 UTC, live FX session
        curPrice = ENTRY_PRICE;
        _refreshMark(curPrice);

        uint256 a = _requestDeposit(juniorVaul

The original report as published on Immunefi, by emanueldlvg. 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 reconcile stores `unassignedAssets = min(U, D)` without recording the clipped amount, so later revenue is routed to the Senior gap and Junior principal rather than restoring the impaired unassigned balance.

Impact

Protocol recapitalisation capital held as unassigned assets is moved into Junior principal and redeemed by an unprivileged Junior LP, with the owner receiving 4,658.76 USDG less at a 2% move and 14,648.76 USDG less at 3%, while the Senior LP is unaffected apart from coupon dust.

What the attacker needed

Owner recapitalises the pool; attacker holds Junior shares; a real 2% market move and rebound; attacker can call settleLpEpoch

The fix

The unassigned balance should get the same loss memory as Senior: record the clipped amount on a reconcile and restore it first from later revenue before the Senior gap and Junior, and clear the impairment field on explicit assignment.

How it was found

  1. Junior and Senior tranches are funded through the public deposit path, including the attacker's Junior position.
  2. The owner calls recapitalizePool while Senior is at its high-water mark, so the whole amount becomes unassigned assets.
  3. The attacker opens interleaved LONG/SHORT pairs and closes the SHORT side, leaving a large LONG position backed partly by the unassigned assets.
  4. A small attacker wallet requests a Junior redemption to provide queue progress.
  5. Marks move down in 1% steps until distributable value falls below the unassigned balance.
  6. The attacker calls settleLpEpoch at the low mark, clipping the unassigned balance, then waits for the rebound and redeems.

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 pool keeps a pot of money that belongs to the protocol owner rather than to depositors, called unassigned assets. When prices dip, the code shrinks that pot to whatever the pool is currently worth, but it forgets how much it removed. When prices recover, the missing money is handed to the junior depositors instead of being put back, so a junior depositor who settles at the dip can later withdraw part of the owner's money.

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 emanueldlvg

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.