Skip to content
Business logic Audit finding Advanced

A temporary adverse mark at the first LP settlement after a recapitalization resets the Senior high-water mark and pays Senior principal to Junior

When the owner recapitalises an impaired Senior tranche, the reconciliation applies the recapitalisation after the mark-driven plan has already zeroed both principals, so the bootstrap branch overwrites the Senior high-water mark with the recapitalisation amount. A temporary adverse mark at the first settlement after recapitalisation therefore permanently lowers Senior's restoration target, and on the rebound the surplus is credited to Junior principal, which a Junior holder can redeem in USDG.

Cryptor Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99498 [SC-Low] A temporary adverse mark at the first LP settlement after a recapitalization resets the Senior high-water mark and pays Senior principal to Junior

Submitted on Nov 13th 2026 at 22:14:30 UTC by @Cryptor for Audit Competition | Plether

Description

Brief/Intro

When the Senior tranche is impaired, the protocol's recovery is CfdEngine.recapitalizePool, an immediate owner action that moves USDG into HousePool and queues it as a pending Recapitalization inflow for "normal pool reconciliation" (CfdEngine.sol:627-630, SECURITY.md:155-162). The repository asserts what that reconciliation must do for an impaired Senior tranche that still holds principal: "Recapitalization should still restore senior principal to the HWM" (test/perps/accounting/waterfall/HousePoolWaterfall.t.sol:389-418).

HousePool._reconcile first reconciles the stored tranche principals against the current mark and writes the result to storage (HousePool.sol:1584-1585). Only afterwards does it apply the queued recapitalization, from a state re-read from storage (HousePool.sol:1598, :1768). HousePoolPendingPreviewLib.applyClaimantRecapitalizationIntent picks its branch from that post-mark state. If the mark has just zeroed both principals, it takes the bootstrap branch and overwrites seniorHighWaterMark with the recapitalization amount (HousePoolPendingPreviewLib.sol:118-122). The previous high-water mark, which absorbLoss deliberately keeps "so future revenue continues to restore senior impairment" (HousePoolWaterfallAccountingLib.sol:161-163), is erased.

So the first committed LP settlement after a recapitalization decides the outcome. If it runs at a mark where open positions show an unrealized trader gain at least as large as the Senior principal left before the recapitalization, Senior's restoration target drops from its high-water mark H to the recapitalization amount H - S. When the mark returns, the waterfall restores Senior only to H - S and credits the rest of the recovery to Junior principal (HousePoolWaterfallAccountingLib.sol:147-158). A Junior holder whose shares were worth zero redeems it in USDG. Every step after the owner's recapitalization is a public call. The settlement is the permissionless OrderRouter.settleLpEpoch, and a Junior holder's own zero-value redemption request supplies the epoch progress it needs.

The proof of concept runs at release risk parameters, with the pool never in degraded mode. After a recapitalization of exactly the recorded Senior gap, a 5.08% temporary mark at the first settlement makes the Senior LP exit with 25,871.625416 USDG less, and the Junior holder redeems 25,452.816597 USDG, against zero in the same-state control. With a 22.23% mark the figures are 116,147.796536 and 106,701.447771 USDG.

Vulnerability Details

The recapitalization is routed after the mark-driven plan is stored

Solidity
// packages/perps/src/HousePool.sol:1555
function _reconcile(...) internal {
    ...
    HousePoolPendingPreviewLib.ClaimantPendingBuckets memory claimantBuckets = _getPendingClaimantBuckets();
    HousePoolPendingPreviewLib.ClaimantPendingBuckets memory settleableClaimantBuckets =
        _settleablePendingClaimantBuckets(reconcileSnapshot, claimantBuckets);
    bool allowRevenueContinuation = seniorPrincipal + juniorPrincipal != 0;              // :1567
    HousePoolReconcilePlanLib.ReconcilePlan memory plan = HousePoolReconcilePlanLib.planReconcile(
        _currentPendingAccountingState(),
        reconcileSnapshot,
        _pendingClaimantBucketAssets(settleableClaimantBuckets),                        // pending reserved first
        ...
    );
    ...
    _setWaterfallState(plan.state.waterfall);                                            // :1584, mark-driven result stored
    unassignedAssets = plan.state.unassignedAssets;
    ...
    _applyPendingClaimantBucketsLive(settleableClaimantBuckets, claimantBuckets, allowRevenueContinuation); // :1598
}

planReconcile subtracts the settleable pending buckets from distributable equity and reconciles the stored principals against what is left at the current mark. When an open position's unrealized gain is at least the stored Senior principal, nothing is left. absorbLoss then zeroes both principals and leaves the high-water mark unchanged (HousePoolWaterfallAccountingLib.sol:161-185), and the zeros are written to storage.

_applyPendingClaimantBucketsLive then reads the stored state back (HousePool.sol:1768) and applies the recapitalization to it:

Solidity
// packages/perps/src/libraries/HousePoolPendingPreviewLib.sol:111
function applyClaimantRecapitalizationIntent(PendingAccountingState memory state, uint256 amount, uint256 recapitalizationTargetAssets)
    internal pure
{
    uint256 remaining = amount;
    if (state.seniorSupply > 0) {
        if (state.waterfall.seniorPrincipal == 0 && state.waterfall.juniorPrincipal == 0) {   // :118, post-mark zeros
            state.waterfall.seniorPrincipal += remaining;
            state.waterfall.seniorHighWaterMark =                                          // :120, old mark overwritten
                recapitalizationTargetAssets > remaining ? recapitalizationTargetAssets : remaining;
            remaining = 0;
        } else {
            uint256 gap = state.waterfall.seniorHighWaterMark > state.waterfall.seniorPrincipal  // :124, restore branch
                ? state.waterfall.seniorHighWaterMark - state.waterfall.seniorPrincipal
                : 0;
            ...
        }
    }
    if (remaining > 0) {
        state.unassignedAssets += remaining;
    }
}

The recapitalization was recorded while Senior held principal, and the owner sized it as a restoration of H - S. Because the branch is chosen after the mark, the same funding is applied as a fresh bootstrap. recapitalizationTargetAssets is that H - S, so the high-water mark becomes H - S and the record of H is gone. Nothing revisits the decision when the mark moves back.

The rebound is credited to Junior

On the next reconciliation the unrealized gain reverses into LP surplus. distributeRevenue restores Senior only to the new mark and credits the rest to Junior principal:

Solidity
// packages/perps/src/libraries/HousePoolWaterfallAccountingLib.sol:147
if (remaining > 0 && nextState.seniorPrincipal < nextState.seniorHighWaterMark) {
    uint256 deficit = nextState.seniorHighWaterMark - nextState.seniorPrincipal;
    uint256 restore = remaining < deficit ? remaining : deficit;
    nextState.seniorPrincipal += restore;
    remaining -= restore;
}
...
nextState.juniorPrincipal += remaining;                                               // :158

The part of the recapitalization that was not settleable on the first pass meets a closed gap and becomes unassignedAssets (HousePoolPendingPreviewLib.sol:134-136).

The invariant that breaks

The waterfall library states the high-water mark rule: "losses do not reduce it, while senior withdrawals scale it and senior gains above it increase it" (HousePoolWaterfallAccountingLib.sol:9-10). ACCOUNTING_SPEC.md:337 repeats it as reconciliation step 3: "Charge a shortfall to Junior first, then Senior. Losses do not reduce the Senior high-water mark." ACCOUNTING_SPEC.md:634 defines a Recapitalization inflow as "recapitalization intended to restore waterfall claimants".

In this path an unrealized loss at step 3 lowers the high-water mark through step 5, and a recapitalization intended to restore Senior permanently reduces Senior's entitlement. The repository's own test of a recapitalization recorded while Senior holds impaired principal expects the opposite: test_FreshPendingSeniorMutation_RestoresHwmWithoutDebtQueue asserts "Recapitalization should still restore senior principal to the HWM". The proof of concept's control branch reproduces that expected outcome. Its adverse branch differs only by the mark at the first settlement.

The band is reachable in a solvent pool that is not degraded

The pre-recapitalization LP equity has to be at or below zero at the settlement mark while the recapitalized pool stays solvent. The queued recapitalization is pool cash for every risk gate:

  • HousePool.totalAssets() is min(raw balance, accountedAssets) (HousePool.sol:426-429). A CashArrived recapitalization raises accountedAssets immediately (HousePool.sol:640-642).
  • Open admission prices depth from totalAssets() (OrderRouterExecutionSidecar.sol:933, :953; CfdEngine.sol:1138).
  • Fresh trader payouts, the degraded-mode latch and clearDegradedMode all use _availableCashForFreshPoolPayouts, which is pool.totalAssets() minus trader claims (CfdEngine.sol:865-871, :849, :1351-1369, :655-667).

Positions opened after the recapitalization are therefore admitted and backed by it. An ordinary adverse mark on them can take pre-recapitalization equity below zero without degrading the pool. The proof of concept asserts engine.degradedMode() == false after the open.

Root cause

  1. HousePool._reconcile stores the mark-driven waterfall plan (src/HousePool.sol:1584-1585) before it applies the pending recapitalization (src/HousePool.sol:1598).
  2. _applyPendingClaimantBucketsLive rebuilds its state from storage (src/HousePool.sol:1768), so the recapitalization sees the principals as the current mark left them, not as they were when the recapitalization was recorded or when the reconciliation began.
  3. applyClaimantRecapitalizationIntent takes the bootstrap branch when both of those principals are zero and overwrites seniorHighWaterMark with the recapitalization target (src/libraries/HousePoolPendingPreviewLib.sol:118-122).
  4. The pre-reconcile principal and high-water mark are not consulted. allowRevenueContinuation is captured from them at :1567, but only for revenue routing.
  5. On the rebound, distributeRevenue restores Senior to the overwritten mark and credits the remainder to Junior principal (src/libraries/HousePoolWaterfallAccountingLib.sol:147-158).

The commit step

The overwrite becomes storage only when a reconciliation commits. The permissionless route with open positions is OrderRouter.settleLpEpoch (src/OrderRouter.sol:479-484), which validates a signed Pyth update, refreshes the Engine mark and settles in one call. HousePool._settleLpEpoch reconciles first (src/HousePool.sol:835) and reverts with HousePool__NoLpEpochProgress when no epoch advances (src/HousePool.sol:1183-1184), which also rolls back the reconciliation.

A matured Junior redemption with zero value supplies that progress. The funding phase refunds the zero-value head and counts it (src/HousePool.sol:960-986), and the refund returns the shares to the holder for a later redemption. LP epochs are hourly (HousePool.sol:178) and requests close five minutes before a boundary (TrancheVault.sol:39). When no other LP request is pending, a Junior holder's own request therefore sets which hourly boundary is the first committed settlement after the recapitalization. Junior shares are transferable ERC20 subject to the deposit cooldown (TrancheVault.sol:314-334), so the holder can be anyone who holds or acquires wiped Junior shares.

Attack scenario

Starting state: Junior principal is zero with live Junior shares, Senior principal S is below its high-water mark H after realized trading losses, and the pool is not degraded.

  1. The owner calls CfdEngine.recapitalizePool(H - S), the documented recovery for the recorded gap. The amount is queued.
  2. A trader opens a position through the public Router path. Admission counts the queued recapitalization as depth. In the proof of concept this is a fully margined 579,100-notional Short at 1.00, 39% of pool cash and inside the 40% skew cap.
  3. A Junior holder requests redemption of its zero-value shares before the epoch cutoff, and the request matures at the next hourly boundary.
  4. The basket moves until the position's unrealized gain is at least S. Any address calls OrderRouter.settleLpEpoch with a valid signed update. The plan zeroes both principals, the recapitalization bootstraps Senior with seniorHighWaterMark = H - S, and the Junior request is refunded as progress.
  5. The basket returns and the trader closes at its entry price, with no realized gain.
  6. At the next settlement, Senior is restored only to H - S, the remainder of the recovered equity is credited to Junior principal, and the unapplied part of the recapitalization goes to unassignedAssets.
  7. The Junior holder claims its refunded shares, waits the ordinary cooldown, and redeems Junior principal in USDG. A Senior LP who exits receives H - S worth of value instead of H.

Steps 1 to 6 are public calls. The Junior holder needs no role and takes no price risk. It only holds shares that are worth nothing in the control branch and files an ordinary request. The trader in step 1 can be any unrelated account. A participant who opens that position itself can hedge it off-chain, because the transfer depends on the mark seen at the settlement, not on any realized trading gain.

The program's privileged-role exclusions cover attacks that require a malicious, compromised or out-of-procedure trusted role. Neither applies here. The program page lists the recapitalization among the owner's immediate trusted actions and places "a legitimate, documented action by a trusted role that triggers a bug harming users" in scope. The owner funds exactly the gap read from chain and gains nothing, and the defect is in how the reconciliation applies that funding.

Relation to documented limitations and known issues

The program treats packages/perps/SECURITY.md Known Limitations and the listed audit reports as known issues, and accepts a report on a documented root cause only where the fix at a82d4fef is incomplete or introduces a new bug.

The bootstrap branch and its tests. The NatSpec of applyClaimantRecapitalizationIntent documents the bootstrap: "With senior owners and zero claimed principal, all amount bootstraps senior principal and sets the high-water mark to max(recapitalizationTargetAssets, amount)" (HousePoolPendingPreviewLib.sol:103-107). The repository pins zero-principal resets in five tests. Each one commits a realized wipe first, and none lets a mark produce the zero inside the reconciliation that applies a recapitalization recorded while Senior held principal:

Test How principal reaches zero Reset source
TrancheRecoveryBehavior.t.sol:24-55 test_PostWipeoutRequiresExplicitRecapForHwmReset pool tokens burned, wipe reconciled recapitalization recorded after the wipe
HousePoolSeededSetup.t.sol:58-114 test_MaxDepositAndMaxMint_ReopenForPendingSeniorRecapAfterWipeout pool tokens burned, wipe reconciled ("Senior principal should be wiped out before recap") recapitalization recorded after the wipe
HousePoolBootstrap.t.sol:301-324 test_RecordRecapitalizationInflow_SeedsSeniorWhenNoPrincipalButSeedSharesExist pool tokens burned, wipe reconciled recapitalization recorded after the wipe
HousePoolSnapshotParity.t.sol:155-169 test_PartialMixedInflowsPreserveFullIntentAndSettleResidualLater _wipePrincipal() burns pool tokens and reconciles recapitalization recorded after the wipe
HousePoolWaterfall.t.sol:420-445 test_AssignUnassignedAssets_ResetsSeniorHwmWhenSeniorIsEmptyButJuniorStillExists storage write owner assignment of unassigned assets

The one repository test that records a recapitalization while Senior holds impaired principal, HousePoolWaterfall.t.sol:389-418, asserts restoration to the high-water mark. The documented bootstrap reset is a policy for a tranche whose wipe has been committed. The reported path applies it to a tranche that was not wiped when the owner funded its restoration.

The reconciliation order. ACCOUNTING_SPEC.md:335-340 lists pending-bucket routing as step 5, after the loss and surplus steps, and explains the order: "Reserving them in step 2 prevents counting the same inflow twice." That reason concerns double counting. The same list states, at step 3, that losses do not reduce the Senior high-water mark, and that is the rule this path breaks.

Known Limitations. The LP accounting limitations note that "exact terminal NAV is only as current as its authenticated mark" (SECURITY.md:1382-1383). That entry concerns a NAV that follows the mark in both directions. The Senior high-water mark is defined as the value that does not follow a loss. No entry in the LP accounting, LP claim and allocation, or rounding limitations (SECURITY.md:1380-1433) covers recapitalization branch selection or a loss of high-water-mark entitlement beyond the one-atom rounding bound at :1417-1419.

Published audit findings:

Published issue Its root cause and impact This report Why its fix does not stop this path
SC Audit Studio SC-L1, permissionless zero-value senior withdraw can persist overstated tranche principal Pending claimant buckets were applied after mark-to-market without a cap, overstating stored principal Pending buckets are capped. The defect is which recapitalization branch runs after the mark, and the high-water mark it writes The cap by settleable equity (_settleablePendingClaimantBuckets) only sets how much of the recapitalization is applied in the first pass. The branch is chosen from the zeroed principals either way
Cecuro MED-12, mixed recovery inflows can strand LP revenue in ownerless pool assets A stale allowRevenueContinuation decision parked realized LP revenue as ownerless. The response's worked case (40,000 recapitalization and 15,000 revenue giving Senior 40,000 and Junior 15,000) starts from principal that a wipe had already zeroed, and it states "Recapitalization remains senior-first" Senior held principal when the recapitalization was recorded. Its high-water mark is overwritten and Senior value moves to Junior The fix recomputes revenue continuation (HousePool.sol:1577-1578, HousePoolPendingPreviewLib.sol:50-52) and does not touch the recapitalization branch or the high-water mark
Cecuro MED-24, LP can delay other redeemers with zero-payout refunds Refund epochs consume bounded settlement work and delay later redeemers One zero-value refund is the epoch progress that commits the reconciliation. No redeemer is delayed The accepted work-cap limitation does not concern waterfall state

SC-L1 is the closest published entry. It also arose because _reconcile applies the pending claimant buckets after the mark-to-market step, and the auditor recommended making that settlement "part of the same liability-adjusted reconcile kernel instead of applying it afterward". The response fixed the amount instead: "Pending recap/revenue is now capped to what's actually settleable after MTM/deferred liabilities" (audits/plether-pre-audit-report.pdf, SC-L1). If that entry is read as covering the ordering itself, the fix at a82d4fef is incomplete for this consequence. The capped recapitalization is still routed by a waterfall state that the current mark has just rewritten, and that produces the outcome measured here.

A separate report by the same researcher (#98615) covers a temporary mark clamping an existing unassignedAssets balance (HousePoolReconcilePlanLib.sol:73-74), with the rebound credited to Junior. This report concerns a different write (seniorHighWaterMark in the recapitalization bootstrap branch, HousePoolPendingPreviewLib.sol:118-122), a different victim (Senior LPs lose their own principal; no pre-existing ownerless balance is involved) and a different fix. Restoring a clamped reserve leaves the bootstrap overwrite unchanged, and keeping the high-water mark leaves the reserve clamp unchanged.

Companion report. A separate report submitted alongside this one covers the favorable direction at the same settlement. There, a temporary trader loss restores Senior before the recapitalization is applied, the recapitalization's restore branch finds no gap, and the recapitalization is stranded in unassignedAssets (HousePoolPendingPreviewLib.sol:123-136). The two defects sit in different branches of applyClaimantRecapitalizationIntent, have different victims and outcomes, and have disjoint narrow fixes (see the fix check in the proof of concept).

Impact Details

Measured on the release configuration with the pool never degraded. Each row is one same-state comparison: the first settlement after the recapitalization runs at 1.00 in the control and at the temporary mark in the other branch. Everything else is identical, including the trader's close at 1.00 and the later exits.

Measure (USDG) 5.08% temporary mark 22.23% temporary mark
Senior principal before the recapitalization (S) 26,768.271103 117,044.503056
Senior high-water mark before the recapitalization (H) 1,485,028.127781 1,485,028.127760
Owner recapitalization (H - S) 1,458,259.856678 1,367,983.624704
High-water mark after the first settlement, control 1,485,028.127781 1,485,028.127760
High-water mark after the first settlement, temporary mark 1,458,259.856678 1,367,983.624704
Senior LP full exit, control 1,484,130.499438 1,484,130.499417
Senior LP full exit, temporary mark 1,458,258.874022 1,367,982.702881
Senior LP loss 25,871.625416 116,147.796536
Junior holder redemption, control 0 0
Junior holder redemption, temporary mark 25,452.816597 106,701.447771
Left in unassignedAssets, control 1,129.126121 1,129.126121
Left in unassignedAssets, temporary mark 1,547.706688 10,575.322677

In both runs the Senior LP loses about the Senior principal held before the recapitalization, the Junior holder receives most of it, and the remainder sits in unassignedAssets. In the control, 1,129.126121 USDG ends in unassignedAssets because the first settlement credits the open's VPI charge as LP revenue before it applies the recapitalization. That routing does not depend on the mark. The loss grows with S, and so does the move needed to trigger it.

Severity

The mapped impact is Critical: direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield. The value taken is the Senior LPs' principal at rest. In the same-state control the recapitalization restores Senior to its high-water mark. In the adverse branch Senior is restored only to the recapitalization amount, so the Senior LP loses about the principal it held before the recapitalization. A Junior holder, whose redemption was worth zero in both branches before the settlement, redeems that value as USDG. The beneficiary is identified and the loss is realized in settlement token.

The High tier "theft of unclaimed yield" is not claimed, because the transferred amount is Senior principal recorded before the recapitalization, not accrued yield. The Medium griefing tier is not claimed either, because a party other than the victim receives the value and withdraws it.

The program assesses feasibility separately from impact. The conditions that bound this path are stated here so they can be weighed:

  • Junior principal is zero and Senior is impaired, the state that recapitalizePool exists to cure.
  • The owner recapitalizes, a documented trusted action that the program lists as in scope when it triggers a bug ("Immediately, can ... recapitalize the pool"). In the proof of concept the amount is exactly the recorded gap, read from chain.
  • At the first committed settlement after the recapitalization, open positions carry an unrealized trader gain of at least S, the Senior principal before the recapitalization, and less than S plus the recapitalization. Net exposure is capped by maxSkewRatio (40% of pool depth, which includes the recapitalization). The required move is therefore about S / (0.4 x depth), and the loss is about S.

No attacker is required for the loss. The same transfer happens when an honest keeper commits the first post-recapitalization settlement at such a mark.

Mitigation

Choose the recapitalization branch from the claimed principal as it stood when the recapitalization was recorded, or when the reconciliation began, rather than from the state the current mark has just written. Equivalently, do not lower seniorHighWaterMark in a reconciliation that began with nonzero claimed principal. Keep the documented bootstrap reset for a tranche whose wipe was committed before the recapitalization, as pinned by TrancheRecoveryBehavior.t.sol:24-55.

Regression coverage should record a recapitalization while Senior holds impaired principal, commit the first settlement at an adverse mark that zeroes the remaining principal, return the mark, and assert that Senior is restored to its original high-water mark and that the Junior payout matches the control.

References

  • packages/perps/src/HousePool.sol:1555-1599 (_reconcile: plan stored at :1584-1585, pending buckets applied at :1598), :1759-1776 (_applyPendingClaimantBucketsLive, state re-read at :1768), :426-429 (totalAssets), :636-648 (recordClaimantInflow, accountedAssets raised at :641), :794-835 (settleLpEpoch, reconcile at :835), :960-986 (zero-value refund counted as progress), :1183-1184 (HousePool__NoLpEpochProgress), :178 (LP_EPOCH_DURATION)
  • packages/perps/src/libraries/HousePoolPendingPreviewLib.sol:103-137 (applyClaimantRecapitalizationIntent; bootstrap branch :118-122; restore branch :123-132; remainder to unassigned :134-136), :40-57 (applyPendingClaimantBucketsPreview)
  • packages/perps/src/libraries/HousePoolWaterfallAccountingLib.sol:9-10 (high-water mark rule), :140-159 (distributeRevenue), :161-185 (absorbLoss, high-water mark "deliberately unchanged")
  • packages/perps/src/libraries/HousePoolReconcilePlanLib.sol:47-106 (planReconcile)
  • packages/perps/src/CfdEngine.sol:627-654 (recapitalizePool), :655-667 (clearDegradedMode), :840-871 (fresh payouts and _availableCashForFreshPoolPayouts), :1138 (net pool depth), :1351-1369 (_enterDegradedModeIfInsolvent)
  • packages/perps/src/OrderRouter.sol:479-484 (settleLpEpoch), packages/perps/src/OrderRouterExecutionSidecar.sol:933, :953 (open admission depth)
  • packages/perps/src/TrancheVault.sol:39 (request cutoff), :314-334 (share transfers)
  • packages/perps/src/libraries/HousePoolTrancheGateLib.sol:28-30 (deposits closed while unassigned assets exist)
  • packages/perps/ACCOUNTING_SPEC.md:329-340 (waterfall and reconciliation order), :634, :639-643 (recapitalization intent and routing)
  • packages/perps/SECURITY.md:155-162 (owner-funded recapitalization), :1380-1420 (LP limitations)
  • packages/perps/test/perps/accounting/waterfall/HousePoolWaterfall.t.sol:389-418 (recapitalization restores impaired Senior to the high-water mark), the five bootstrap tests listed above

Proof of Concept

Proof of Concept

The test runs on an unmodified checkout of immunefi-team/audit-comp-plether at a82d4fefb02768e5b3bddcc97dee371eee24fea8, using the repository's own BasePerpTest fixture with the v2.0.0 release risk parameters. One file, added to the frozen commit with no other change. It compiles and passes against the pristine repository. No production source is touched, test/perps/BasePerpTest.sol is used unmodified, and no vm.mockCall appears anywhere.

Notes on the fixture:

  • _riskParams sets the release risk parameters from DEPLOYMENT.md (vpiFactor 0.01e18, maxSkewRatio 0.4e18, maintMarginBps 10, initMarginBps 20, fadMarginBps 300, baseCarryBps 500), and setUp applies the release Senior limits (40,000,000 USDG, 8000 bps).
  • MockSettlementToken stands in for USDG and MockPyth for Pyth Network. The production PletherOracle reads MockPyth through its real staleness, confidence and divergence checks.
  • Every value-moving call after setup goes through a public entry point: router.commitOrder, router.executeOrder, router.updateMarkPrice, router.settleLpEpoch, pool.settleLpEpoch, seniorVault.requestRedeem, juniorVault.requestRedeem, juniorVault.claimRedeemRefund. The single owner call, engine.recapitalizePool, is the documented recovery, and its amount is read from pool.seniorHighWaterMark() - pool.seniorPrincipal().
  • The direct pool.settleLpEpoch(0, 0) in _impairSenior runs at zero open interest, which HousePool.sol:794-796 documents as permissionless from the cached mark. Every settlement with an open position goes through router.settleLpEpoch.
  • _impairSenior only builds the starting state that recapitalizePool exists to cure. Each round closes two opposite positions at 0.01 and 1.99 to realize a trader gain larger than Junior principal in a few rounds. These prices are not meant as basket moves. The reported mechanism starts after that state is committed, and from the recapitalization on the test uses only 1.00 and the computed temporary mark.
  • The basket price convention is the protocol's own: CfdMath.calculateExactPnl makes a Side.SHORT position profitable as the basket price rises (src/CfdMath.sol:61-66). The trader opens a Short at 1.00, is marked in profit at the temporary mark, and closes at 1.00.
  • The temporary mark is computed, not

The original report as published on Immunefi, by Cryptor. 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: `_reconcile` stores the mark-driven waterfall plan before applying the queued recapitalisation, and the recapitalisation helper then reads the zeroed principals back from storage and takes its bootstrap branch, overwriting the Senior high-water mark.

Impact

A Senior LP exiting after the rebound receives about the pre-recapitalisation Senior principal less, and the Junior holder redeems that value in USDG; the proof of concept runs with the pool never in degraded mode, though the path needs a temporary mark large enough to wipe the stored Senior principal.

What the attacker needed

Senior impaired, Junior principal zero; owner recapitalises the gap; temporary adverse mark at first settlement; Junior holder holds wiped shares

The fix

The reconciliation should apply the queued recapitalisation against the pre-mark principal and high-water mark, or otherwise preserve the Senior high-water mark when the recapitalisation was recorded while Senior still held principal.

How it was found

  1. The owner calls the recapitalisation function for the recorded Senior gap, queuing the amount.
  2. A trader opens a position through the public router, with admission counting the queued recapitalisation as depth.
  3. A Junior holder requests redemption of its zero-value shares before the epoch cutoff.
  4. The basket moves until the position's unrealised gain is at least the Senior principal, then any address calls the permissionless LP epoch settlement with a valid signed price update.
  5. The basket returns and the trader closes at entry price, then the next settlement restores Senior only to the overwritten mark and credits the rest to Junior.
  6. The Junior holder claims the refunded shares, waits the cooldown and redeems Junior principal in USDG.

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 splits money between a safer Senior part and a riskier Junior part, and it remembers a target value (the high-water mark) that Senior should be restored to after losses. The bug is that a one-off bad price reading at the wrong moment makes the pool forget that target and replace it with a smaller number. Later, when prices recover, the extra money goes to the Junior side instead of back to Senior, and the Junior holder can withdraw 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 Cryptor

View all

18 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.