Skip to content
Business logic Audit finding Advanced

One atom of claim-net depth turns a triggered take-profit into a charge of 21.6 times its own notional and takes the owner's entire settlement balance

A close-accounting curve prices the skew change of a protective take-profit close using claim-net pool depth as a denominator, and that denominator has no floor and the resulting charge has no cap relative to the closed notional. With one atom of depth the owner's triggered take-profit is assessed a charge many times the position's notional, which drains the owner's entire settlement balance into the liquidity pool.

skydev Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#98284 [SC-High] One atom of claim-net depth turns a triggered take-profit into a charge of 21.6 times its own notional and takes the owner's entire settlement balance

Submitted on Nov 6th 2026 at 17:56:12 UTC by @skydev for Audit Competition | Plether

Description

Severity: Critical

Impact: Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield

Code: packages/perps/src at a82d4fefb02768e5b3bddcc97dee371eee24fea8 (libraries/CloseAccountingLib.sol, libraries/CfdEnginePlanLib.sol, CfdMath.sol)

Why this impact:

  • A triggered take-profit takes the owner's whole settlement balance instead of paying it a gain. In the attached PoC the owner holds a 12-lot (1,200-token) SHORT with a take-profit armed while the pool is healthy. When the take-profit finally crosses, the generated close is assessed an action charge of 3,296,780,471.208208 USDG, collects 51,173.869354 USDG, waives the uncollectible remainder, and leaves clearinghouse.balanceAssets(victim) at exactly 0. The closed notional is 2,373.709668 USDG (1,200 tokens at the execution price 1.97809139), so the protocol collected 21.558605 times the notional of the position it was closing and assessed 1,388,872 times it.
  • The charged amount is the owner's at-rest balance, not its exposure. The loss is bounded by what the account holds, not by the size of the protected position. An account with a small protected position and a large balance loses the balance.
  • The owner does not choose the moment. Triggering an armed protection is permissionless (PositionProtectionBook), so a third party decides when the owner's close is created, and it can wait for the pool state in which the charge consumes the account. The owner is explicitly asserted non-liquidatable at that price, so this is not a liquidation outcome.
  • The collected value becomes LP equity and an unprivileged attacker captures it pro rata. In a matched control that differs in one stored field, the attacker's own tranche position ends 49,513.655380 USDG above the control branch on the same price path (its value is 20,000.254622 before either branch runs, and the control branch leaves it at zero). A share ladder shows the attacker still gains 20,919.670158 / 10,459.835078 / 4,183.934030 USDG while holding only 49.99 % / 24.99 % / 9.99 % of the tranches, and cash is actually withdrawn through the production asynchronous redemption flow.
  • Conservation holds to the atom, so nothing here is a display artefact: the victim's debit equals the pool's gain plus the treasury's execution fee, and aggregate trader claims are byte-identical in both branches.
  • The fix is attached and its effect is measured. The patch in the Recommendation caps a positive close charge at the envelope the governed skew ratio already implies. Installed in the same scenario, it leaves the protected close executing normally, the owner keeping 51,163.425140 USDG instead of zero, and the attacker's LP premium at exactly zero: the charge falls from 51,173.869461 to 10.444321 USDG.
  • Scope. Finite close ceilings prevent the debit; this report does not claim a bypass of them. The exposed population is owners whose stored ceilings are type(uint256).max.

Brief/Intro

CloseAccountingLib.buildCloseState contains a deliberate safeguard for closes that happen when the pool has no economic depth. Its purpose is stated in the code:

Solidity
// CloseAccountingLib.sol:105-110
// With no economic depth, keep protective exits live without creating a fresh charge or rebate.
// The lifetime clamp below still recovers any previously received negative VPI.
if (inputs.poolDepthAssets != 0) {
    state.vpiDeltaAssets = CfdMath.calculateVPI(
        inputs.preSkewAssets, inputs.postSkewAssets, inputs.poolDepthAssets, inputs.vpiFactor
    );
}

The guard is exact-zero only, and the curve behind it has no floor on its denominator and no cap relative to the closed notional. One atom of claim-net depth therefore inverts the safeguard's stated purpose: instead of a protective exit with no fresh charge, the owner gets a charge on a 1 / D curve that exceeds its entire custody, and a terminal full close collects everything the account has before waiving the remainder.

Because protections are triggered permissionlessly, the party that decides whether the owner's close is created on the zero side or the one-atom side of that boundary is not the owner. The result is a transfer of the owner's at-rest settlement balance to HousePool, where any incumbent LP, including the attacker, owns it pro rata.

This is the opposite tail of the SCAN-03/04 remediation. PR #118, "fix(perps): use net risk depth and fingerprint calendar changes" (6d6622f2871dbdfc4904c20da2e1f7662f5763b6, 2026-10-15), replaced gross pool assets with claim-net depth and, in its own words, "Subtract outstanding trader claims consistently in carry, skew limits, VPI, previews, and maximum-open quotes. Checkpoint carry before claim mutations and define zero-depth admission and close behavior." Before that change there was no claim-net 0 -> epsilon boundary to land on, and the exact-zero close rule did not exist. The report is therefore filed under the program's rule that a report on the same root cause as a fixed or acknowledged finding is valid where it shows the fix "introduces a new bug".

Vulnerability Details

1. What the charge does at small depth

CfdMath.calculateVPI (CfdMath.sol:150-161, via tryCalculateVPI :164-180) prices the skew transition as the difference of two skew costs, each proportional to 1 / depth. There is no lower bound on depthAssets other than the exact-zero branch above it, and no bound on the result relative to the notional being closed.

quantity value in the main PoC
claim-net depth used for the curve 94 atoms (0.000094 USDG)
closed notional 2,373.709668 USDG
assessed action charge 3,296,780,471.208208 USDG
collected from the owner 51,173.869354 USDG
of which: the position's withheld price gain 1,173.709656 USDG
of which: the owner's settlement cash 50,000.159698 USDG
waived remainder 3,296,729,297.338854 USDG
owner's settlement balance afterwards 0

The owner armed a take-profit, so the first line of that split is the gain the protection existed to realise, and the second is the rest of the account.

A terminal full close consumes spendable action reserve, free settlement, safely released pledge and committed margin, and waives only what it cannot reach (CfdEnginePlanLib.sol:1093-1133). The waiver keeps the close alive; it does not keep the owner's money.

A separate pure test (test_D0VsD1FreshVpiDiscontinuity, 2,807 gas, no state) isolates the step: the same skew transition yields a fresh VPI of zero at D = 0 and a charge of over a billion USDG at D = 1 atom.

2. Claim-net depth is not the pool's liquidity

D is max(HousePool.totalAssets() - totalTraderClaimBalanceAssets, 0) (libraries/CfdEnginePlanLib.sol:1339-1341 via PositionRiskAccountingLib.computeNetPoolDepthAssets). It is a bookkeeping residual, not a cash balance. In the main PoC, at the moment the owner's close is priced:

  • live pool backing immediately before the close is 9,279.999946 USDG (aggregate claims of 9,280.000000 less the printed 54-atom deficit), and raw token custody is at least that;
  • the planner then projects 148 atoms of collectible carry into its own snapshot, giving a poolAssets input of 9,280.000094 USDG;
  • the denominator handed to the curve = 0.000094 USDG.

The owner is charged as if the pool were empty while the pool holds about 9.28 thousand USDG of real assets. The matched control prints the same identity on live state: accounted assets, real token custody and pool assets are all 9,280.080012 USDG at child time, against a depth of 0.080012 USDG.

3. A third party decides when the owner's close happens

A protection trigger is permissionless, and the trigger queues the close through the Router's own path (OrderRouter.sol:440-470, _recordCommittedOrder at :459) rather than through an ordinary trader commit. Consequences used here:

  • the owner cannot choose the execution moment, and cannot cancel a queued close (documented);
  • the attempt carries the ceilings stored on the protection, copied unchanged;
  • the attempt is appended without the carry checkpoint that an ordinary close commit performs, so the owner's pending carry is still unrealized when the close is planned.

4. Three measured ways the close lands just above zero

The defect is the discontinuity and the missing cap; the path to a small positive D is incidental. Three are measured, from the narrowest to the widest:

  1. The owner's own carry (94 atoms). Aggregate claims exceed pool assets by 54 atoms, so claim-net depth is exactly zero when the protection is triggered and the guard would apply. Inside planClose the owner's pending carry is realized first (CfdEnginePlanLib.sol:815) and added to pool assets (:638-639), and only afterwards is the depth sampled (:1339-1341). 148 atoms of the owner's own carry turn D = 0 into D = 94 within one plan, and the guard no longer applies.
  2. A queued partial close (80,012 atoms, 0.080012 USDG). The matched control reaches this depth with an ordinary tuner order ahead of the owner's close in the FIFO. The ladder rungs run the same construction at 107,905 atoms (0.107905 USDG), the share transfer's own carry checkpoint accounting for the difference.
  3. An ordinary, non-knife-edge depth. test_attackRealisticFortyCentDepthStillConsumesEntireVictimSettlement passes in the attached run and asserts that a depth of the order of 0.4 USDG still consumes the owner's entire settlement; test_probeRealisticFortyCentDepthWithLongPartialClose demonstrates that a sub-dollar depth of 0.250006 USDG is reachable through ordinary public tuning (printed). Neither figure is offered as a drain threshold, and the exact depth of the 0.4 USDG variant is asserted inside that test rather than printed in the log. The point is only that the transfer is not a single-atom coincidence.

Note on path 1: the program's known-issue text for zero economic depth describes net depth as measured "after projected carry collection", so the post-carry evaluation is documented and this report does not claim a bypass of the guard's definition. The point is narrower and survives that text: for a protection child the guard's promise is unreachable whenever the owner has collectible (realized) carry larger than the deficit, which is precisely the class of closes the guard was written to protect.

5. PR #118 routed the same claim-net depth through a bounded carry ratio

PR #118 introduced computeNetPoolDepthAssets and fed its output to both denominator-sensitive consumers: carry utilisation and close VPI. The carry ratio it reused was already saturated; close VPI was not.

Solidity
// libraries/PositionRiskAccountingLib.sol:61-75, computeBorrowUtilizationBps
if (borrowBaseAssets == 0) {
    return 0;
}
if (poolAssets == 0) {
    return UTILIZATION_BPS;                 // zero depth is full utilisation, not a skip
}
utilizationBps = (borrowBaseAssets * UTILIZATION_BPS) / poolAssets;
if (utilizationBps > UTILIZATION_BPS) {
    utilizationBps = UTILIZATION_BPS;       // and the ratio itself is capped
}

For an empty borrow side the ratio is zero, and for a positive one it saturates, so in the carry path a vanishing denominator is the continuous limit of a bounded function rather than a discontinuity. To be precise about history: that cap and both zero branches predate PR #118, whose only change to this function was to re-point its parameter documentation at "Economic pool depth after reserving outstanding trader claims". The remediation therefore routed its new claim-net depth into an already-bounded, zero-continuous consumer, and separately routed the same depth into the close VPI curve, where it added the exact-zero exception around an output with no cap.

The remediation's own new test file is the clearest statement of what it considered at that boundary. test/perps/accounting/NetEconomicDepth.t.sol, added by PR #118, covers claims at or above assets from three sides: testFuzz_ClaimsAtOrAboveAssetsCapCarryAndLeaveEmptySideIdle fixes carry as capped, testFuzz_ClaimsAtOrAboveAssetsRejectOpenAndReturnZeroQuote fixes opens as rejected, and testFuzz_ZeroNetDepthCloseDoesNotPayFreshVpiRebate together with test_ZeroNetDepthRouterClosePreservesLifetimeRebateClawback fix the close at exactly zero depth, in the rebate direction. No case in that file, or anywhere else in the suite, covers a close one atom above zero paying an unbounded charge. The boundary this report is about is the one quadrant the remediation left untested, and it is the only one of the four in which the output is unbounded.

6. Root cause

Three properties combine. Removing either of the first two makes the charge safe; removing the third would leave the formula unsafe and merely make the loss self-inflicted rather than imposed:

  1. the zero-depth safeguard for protective exits is evaluated as an exact-zero test, so it offers no margin;
  2. the close VPI curve has no minimum denominator and the collectible action charge has no cap relative to the closed notional;
  3. the close is created by a third party at a time the owner does not choose, with ceilings the owner set long before, so the owner cannot react to the state in which its close will be priced.

Impact Details

All figures below are printed by the attached tests or are differences of printed values. The runs are a clean build (--force) at the repository's default profile, with no compiler-setting or optimizer override: solc 0.8.35, optimizer on, 200 runs, via-IR, 198 files compiled. The only environment variable used is FOUNDRY_SPARSE_MODE, which selects sparse compilation and changes no setting that affects produced bytecode.

Main attack and its paired control

C08CarryProtectionProbe, 2/2 PASS.

attack (ceilings at type(uint256).max) control (maxActionChargeAssets = 100 USDG)
deficit before the trigger 54 atoms 54 atoms
owner's carry realized in the plan 148 atoms rolled back
depth used for the curve 94 atoms n/a, rejected before settlement
assessed action charge 3,296,780,471.208208 USDG rejected
collected from the owner 51,173.869354 USDG 0
owner's position closed unchanged
owner's settlement balance 0 unchanged
protection consumed relatched

The control is the same scenario with one stored field changed. It proves the charge is the mechanism and that finite ceilings are a complete defence. A second control (test_controlFiniteGrossDebitBoundRejectsBeforeSettlement) rejects on the gross-debit ceiling instead.

Matched control: what the event moves, with everything else held fixed

C08MatchedControlProbe, 1/1 PASS. One EVM snapshot, identical setup, time, block, price path, FIFO ids, token mint and share balances; the only difference between branches is the stored maxActionChargeAssets.

attack control delta
HousePool assets (= accounted = real custody) 59,279.290375 9,280.080012 +49,999.210363
aggregate trader claims 9,280.000000 9,280.000000 0
treasury — — +0.949483
keeper accounts' value afterwards 1,002.040000 1,002.040000 0
attacker's LP value 49,513.655380 0 +49,513.655380
independent LP's value 4.949408 0 +4.949408
  • Conservation: the owner's cash debit of 50,000.159846 USDG equals the pool's gain of 49,999.210363 plus the treasury's 0.949483 execution fee, exactly. This is the cash leg only; the total recovered in the main attack additionally withholds the position's price gain, which never reaches the owner's balance and so does not appear as a debit. The treasury figure is itself a check on the closed notional: 0.949483 is the 4 bps execution fee on 2,373.709668 USDG.
  • Claims are byte-identical in both branches. The owner's money did not settle a claim, repay a liability, or discharge any debt of the owner's own. It became LP equity and nothing else.
  • Keeper compensation is identical in both branches: the keeper accounts hold 1,001.040000 USDG before either branch and 1,002.040000 USDG after each of them, so the same 1.000000 USDG of bounty is paid on both sides and the difference between the branches is the charge and only the charge.

The attacker does not need to own the pool

C08ShareLadderProbe, 4/4 PASS. Existing tranche shares are redistributed before the common snapshot; pool assets, supplies, oracle path, branch inputs and total LP ownership are unchanged, so the attacker's share is the only variable. Every rung shares one depth (0.107905 USDG), one owner debit (42,325.049969 USDG) and identical claims (9,280.000000 in both branches).

attacker's share attacker LP, start attacker LP, attack attacker LP, control gain vs control as % of the owner's loss
49.99 % 9,999.999995 20,919.670158 0 +20,919.670158 49.426 %
24.99 % 4,999.999997 10,459.835078 0 +10,459.835078 24.713 %
9.99 % 1,999.999998 4,183.934030 0 +4,183.934030 9.885 %

The attacker's gain tracks its share of the tranches almost exactly, which is the expected signature of pro-rata LP revenue. Conservation again holds: pool gain 42,324.100486 plus treasury 0.949483 equals the owner's debit of 42,325.049969.

The attacker is profitable at every rung and pays only gas plus the cost of positioning, so the griefing standard ("applies to High or Critical findings where the attacker gains no profit") does not apply.

Cash leaves the protocol

C08CaptureProbe, 8/8 PASS, measures the exit path rather than only the entitlement: after the charge, incumbent tranche owners hold 47,895.262918 USDG of value and 42,782.019880 USDG is actually received through the production asynchronous redemption flow. In the same file, test_attackUnlimitedBoundsConsumeEntireVictimSettlement records an assessed 559,689,841.487069 USDG against 49,961.759846 USDG recovered and a pool delta of 50,000.019844 USDG with claims unchanged at 9,280.000000.

Preconditions and limits, stated plainly

  • The pool must already be claims-heavy. A small D means aggregate claims have consumed almost all pool assets, which outside degraded mode the solvency checks prevent. In the PoC that precondition is constructed through public opens and closes together with mocked but internally valid price updates along the path 1.00 -> 1.95 -> 0.20. The PoC does not establish that a production market would traverse such a path, and it does not show that an attacker could force it. In production this is an opportunistic attack on a state the attacker waits for rather than creates.
  • The attacker cannot author prices. Pyth updates are mocked because the program allows mocking out-of-scope components, not because the attacker controls them. The trigger happens at the first genuine crossing of a take-profit armed long before, and no step depends on choosing between ticks.
  • Position-size coupling. The skew cap ties notional to depth at open time, so an owner of this size must have opened while depth was healthy, which is what the PoC does.
  • Capture needs an existing LP position. New deposits are blocked once the pool is degraded, so the attacker must already hold tranche shares; the ladder shows 9.99 % is enough. The owner's loss, however, is complete and permissionless before any of that.
  • Cash-out timing. The owner's loss and the LP entitlement happen with no trusted action. Realising the entitlement as cash follows the ordinary degraded-mode recovery, in which the owner of the protocol clears degraded mode after the inflow restores solvency. That is an operational dependency of the attacker's monetisation, not of the owner's loss.
  • The size of the loss varies with the variant. The primary carry variant empties the account (balance exactly 0); the ladder construction debits 42,325.049969 USDG, which is a material but partial loss for that owner. The report claims the complete loss only for the variant that asserts it.
  • Not claimed: no bypass of finite ceilings, no control of oracle data, no arbitrary victim, no instant payment to the triggering account, and no High fallback (the High impacts cover unclaimed yield and freezes, not settlement principal).
<details> <summary>Relation to the listed known issues, the out-of-scope list, and the documentation</summary>

Each rule below is quoted from the program's reviewed scope text, with its conditions, followed by the delta.

item what it says delta
SCAN-I17, pinned to CloseAccountingLib.sol:107-111 "Close VPI is computed from a single execution-time net pool depth, so a higher depth at execution lowers the positive VPI charge on a skew-increasing close." Condition: "Report concerns changing HousePool depth around a close to reduce its positive VPI action charge." Opposite direction and a different actor. This report is about an unbounded positive charge imposed on a third party's protected close, not about an actor reducing its own charge. The narrow fixes also differ: a minimum denominator or a cap on the collectible charge relative to notional stops this and does nothing for depth manipulation at ordinary depths.
SCAN-I18, pinned to :103-118 lower depth magnifies the negative VPI of a skew-reducing close; "the rebate is clamped to the position's proportional lifetime accrued VPI". Condition: "reducing HousePool depth around a close to enlarge its VPI rebate." Wrong sign. Here the signed VPI is positive, the lifetime clamp never binds, and no rebate is paid.
Zero economic depth, pinned to :105-118 "When net depth is zero after projected carry collection, every open or increase is rejected. Closes at zero depth skip the VPI curve but still apply the lifetime clamp." Condition: "Report concerns opens being rejected, or closes paying no fresh VPI while the lifetime clamp still applies." This report is the complement: a close paying an unbounded fresh VPI just above zero. The quoted text is also the reason the carry ordering is presented as a mechanism and not as a bypass: depth is documented as post-carry, and the finding is that the guard built on it has no margin.
Full-close waiver, pinned to CfdEnginePlanLib.sol:1130-1133 a charge the account cannot fund is waived instead of blocking the close. Condition: "Impact is limited to the uncollected charge or written-off loss that this design deliberately forgoes." The impact here is the collected 51,173.869354 USDG, not the waived remainder. The waiver is what keeps the close alive after the account has been emptied.
Lifetime VPI clamp "On close, VPI is clamped so the closed portion's lifetime VPI cannot go negative." Accepted and unused: the charge is positive, so the clamp does not engage. The clamp's comment does describe the adjacent attack shape ("an attacker opens at high depth, reduces pool depth, then closes"), which shows depth collapse around a close was considered, in the rebate direction only.
This researcher's report #97695, and the earlier #97670 it was matched to Root cause as the triage summary worded it: "a skew-increasing open's positive VPI charge is booked as Junior NAV, and the later clamped close rebate refunds it from pool cash, so a trader-LP can exit between the charge and the refund". Different defect, different loser, and the fixes do not overlap. There the charge is correctly sized and the defect is in LP exit pricing; the party that loses is the set of passive LPs, and the attacker is the same account that paid the charge. Here the charge itself is mis-sized by a factor of about 1,388,872 against the closed notional; the party that loses is an unrelated account whose close a third party triggered; and LPs, including passive ones, gain. The one-fix test is decisive: treating outstanding positive VPI as a refundable liability in LP pricing, which is the minimal fix for #97695 and #97670, leaves this finding untouched, because a close priced at one atom of depth still assesses billions and still empties the account.
Out of scope: "Lack of liquidity impacts" program out-of-scope list, Smart Contract Specific. Disclosed, and the response below is this report's argument rather than a settled reading. On our reading the exclusion addresses impacts that consist of illiquidity: an exit that cannot be funded, a liquidation without a counterparty, slippage. Here the close succeeds, the pool holds about 9,280 USDG of real custody at the moment of pricing, the denominator used is 0.000094 USDG, and the loss is an active collection produced by an internal formula whose output (1,388,872 times the closed notional) has no liquidity interpretation. The project also wrote a safeguard for the illiquid case, quoted at the top of this report, and a defect in that safeguard is a code defect. Note also that the listed known issue addresses behaviour at zero depth, not just above it.
Out of scope: "Impacts requiring basic economic and governance attacks" program out-of-scope list. No market power is required. The attacker holds ordinary positions and tranche shares, opens and closes through public entrypoints, and does not move the oracle.
MED-30, SCAN-L09, "unpaid protection-attempt cleanup" (all pinned to PositionProtectionBook.sol) frozen-market triggers; the trigger bounty is paid at trigger; cleanup and retries are unpaid, and liveness depends on keepers. None concerns the amount charged to a triggered close. This report does not concern keeper incentives, retry liveness, frozen triggers, or a protection left latched.
HIGH-1 clock alignment commit time may trail a published Pyth price. Not used. The trigger is at the first genuine crossing of a threshold armed long before, and no step depends on choosing between ticks.
SECURITY.md VPI limitations document that VPI depth is canonical assets net of trader claims and that closes at zero depth create no fresh VPI. Both accepted and reproduced exactly. Neither passage states that one atom above zero produces a charge larger than the account, nor that a third party may choose which side of that boundary another account's close falls on.
CloseFinancialLimits NatSpec, perps-aa-client README call the four values trader-authorised ceilings and type(uint256).max an explicit unlimited allowance. Acknowledged, and the reason finite ceilings are presented here as a complete defence. A maximum-loss ceiling is a limit on what a close may cost under the protocol's pricing; it is not consent for a charge of 21.558605 times the closed notional assessed because a third party chose the moment. The loss is also unrelated to the authorised exposure: it is bounded by the account's balance, not by the protected position.
Reachability context (out of scope, cited for exposure only) plether-app writes type(uint256).max into all four protection close limits for every take-profit and stop-loss ticket and exposes no amend action; on Arbitrum Sepolia the deployed PositionProtectionBook at 0x81e3b03cf29865b6c0f85925839567e2bc61073d held 13 protection records, at least two still armed, every observed record with all four limits at type(uint256).max (read-only eth_call, blocks 325430302 and 326323894). The frontend is out of scope and is not the root cause; this is cited only to show that the exposed configuration is the one that exists in practice. Take-profit and stop-loss are listed as active at launch on the program page.
</details>

Recommendation

The fix below is attached as a patch, and its effect is measured rather than asserted. With it installed, this attack collects 10.444321 USDG instead of 51,173.869461, the attacker's LP premium falls to exactly zero, and the protected close still executes normally.

Cap a positive fresh close VPI at the envelope the skew cap already implies. For admitted skew ratios no greater than maxSkewRatio, the quadratic curve's marginal charge per unit of closed notional is bounded by vpiFactor * maxSkewRatio. Capping a positive close charge at closedNotional * vpiFactor * maxSkewRatio therefore restores a bound the configuration already expresses, instead of introducing a new constant to argue about. At the release parameters (vpiFactor = 0.01e18, maxSkewRatio = 0.4e18) it is 40 bps of closed notional. Two files, and the cap applies only when the signed delta is positive, so rebates, the lifetime clamp and the zero-depth branch are untouched:

Diff
diff --git a/packages/perps/src/libraries/CfdEnginePlanLib.sol b/packages/perps/src/libraries/CfdEnginePlanLib.sol
index b576415e..5f7a6360 100644
--- a/packages/perps/src/libraries/CfdEnginePlanLib.sol
+++ b/packages/perps/src/libraries/CfdEnginePlanLib.sol
@@ -1340,6 +1340,7 @@ library CfdEnginePlanLib {
                     snap.poolAssets, snap.totalTraderClaimBalanceAssets
                 ),
                 vpiFactor: snap.riskParams.vpiFactor,
+                maxSkewRatio: snap.riskParams.maxSkewRatio,
                 frozenCloseSpreadBps: snap.frozenCloseSpreadBps,
                 oracleFrozen: snap.

The original report as published on Immunefi, by skydev. 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 zero-depth safeguard is an exact-zero test while the close VPI curve has no minimum denominator and the collectible charge has no cap relative to the closed notional.

Impact

A triggered protective close can be charged far more than its notional, taking the owner's whole settlement balance and turning it into LP equity that an existing tranche holder can later withdraw, though the pool must already be claims-heavy and the attacker must already hold shares.

What the attacker needed

Pool already claims-heavy; owner has an armed protection; attacker triggers it permissionlessly; attacker already holds tranche shares

The fix

The attached patch caps a positive close charge at the envelope implied by the governed skew ratio, which in the same scenario leaves the owner keeping 51,163.425140 USDG instead of zero.

How it was found

  1. The owner opens a short position with a take-profit armed while the pool is healthy.
  2. Aggregate trader claims are pushed to or above pool assets so claim-net depth is at or near zero.
  3. A third party permissionlessly triggers the armed take-profit, which queues the close.
  4. Inside the close plan the owner's pending carry is realised and added to pool assets, leaving a tiny positive depth such as 94 atoms.
  5. The close is priced on the curve with that tiny denominator, producing a charge far above the closed notional.
  6. The full close collects the owner's settlement cash and withheld gain, waives the remainder, and leaves the balance at zero.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A trading pool tracks how much money backs everyone's open positions. When a position closes, the code charges a fee based on how crowded the pool is, and that fee is divided by the pool's spare depth. If the spare depth is almost zero, dividing by it makes the fee enormous, and the code then takes everything the account holds to pay it. Because anyone can trigger a user's pre-set take-profit, a stranger can pick the moment when the pool looks empty and the user's money is taken.

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 skydev

View all

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