Skip to content
Business logic Audit finding Advanced

Booked VPI charge is not reserved against its later rebate: a junior LP can exit at a higher share price and re-enter

The pool books a trader's full virtual price impact charge as LP revenue at open, but later refunds part of it as a rebate when the position closes, and the share price used for LP redemptions has no reserve for that future refund. A large junior LP can therefore redeem at an inflated price while an unrelated trader's position is open and re-enter afterwards, shifting value from the junior LPs who stay.

drMurlly Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#97620 [SC-Critical] Booked VPI charge is not reserved against its later rebate: a junior LP can exit at a higher share price and re-enter

Submitted on Nov 2nd 2026 at 14:41:17 UTC by @drMurlly for Audit Competition | Plether

Description

Brief/Intro

In plain terms (code read, with the test result below): the pool counts a fee as LP profit the moment it is paid, although it can hand much of it back when the trade closes; an LP who leaves in between is paid for profit that the LPs who stay would later give back.

Terms. VPI is virtual price impact, the skew-based charge or rebate on a trade (packages/perps/ACCOUNTING_SPEC.md:52). NAV is the pool net asset value that prices LP shares. Skew is long open interest minus short open interest. Junior is the first-loss LP tranche. By code read, F is the full VPI charge booked at the open (F = 0.005 * r^2 * D) and the part that is refunded when the position closes is at most F; inferred from the logged figures, it is about 73 percent of F in the linked test. USDG is the 6-decimal settlement token. Carry is the carry fee the pool collects from open positions. A keeper is any account that executes a queued order. An epoch is the hourly LP settlement round.

Plether Perps books the VPI charge that a trader pays when opening a skew-increasing position as pool cash and LP revenue at once (packages/perps/src/CfdEngineSettlementSidecar.sol:454-464). Part of that charge is refundable: when the same position later reduces the skew, the pool pays a rebate out of free pool cash (packages/perps/src/libraries/CfdEnginePlanLib.sol:973-978), bounded by the VPI the position actually paid (packages/perps/src/libraries/CloseAccountingLib.sol:112-118). The refundable part of booked VPI is therefore cash in the pool and in the junior share price, but the NAV used to price LP redemptions has no term for the possible future rebate. By code read and the test result below, while the position is open the junior share price is too high, relative to what the pool pays out if the position closes by reducing skew, by up to F, the full booked charge (F = 0.005 * r^2 * D), where r is the net skew as a fraction of pool depth D (so F is at most 8 bps of D). In a copy of the linked test with log lines added (supplementary measurements, Part A), the cash actually paid out at the close is 3,279.450138 USDG, against 4,499.9991 USDG booked. By code read, the execution fee and carry due on the close are netted against the rebate, so the pool keeps the netted fee (Attack steps, fourth item); the 73 percent figure is inferred from the logged figures, and F is an upper bound.

By code read, a junior LP who calls requestRedeem while an unrelated trader's skew is open would be paid at the higher price, and would re-enter after the trader closes. The junior LPs who stayed in the pool pay the rebate. This is a value transfer between LPs: in the test (inferred from the Delta table) about 99 percent of the exiting LP's gain is the incumbent junior LP's loss and about 1 percent comes from the trader. The trader receives less cash at the close in the attack world than in the passive world (13th item of Conditions and limits). By code read, it needs no oracle manipulation, no flash capital, no privileged role and no collusion with the trader; every call it makes is permissionless. By code read of the test and the vault, the attacker must be a large existing junior LP (6,000,000 USDG in the test), must wait a one-hour cooldown between entering and exiting, and cannot choose when the trader opens or closes (5th item of Conditions and limits).

In the linked test the same market is run twice from one EVM snapshot: in the PASSIVE world the large junior LP (the attacker) does nothing, in the ATTACK world it exits and re-enters as described. Compared with the passive world, the attacker ends +1,967.669907 USDG, the other junior LP (the incumbent) ends -1,948.864416 USDG and the trader ends -18.805002 USDG. By code read of the test file: the incumbent deposited 4,000,000 USDG, the risk parameters come from the Arbitrum Sepolia v2.0.0 release manifest, the EVM is in-process and the synthetic mark is 1.00. Inferred from the separate runs, the effect is bounded and conditional: profitable only above about 8 percent net skew, at most 8 bps of pool depth per cycle, a possible loss with several traders, and, in one separate run with the contract-default frozen fee, a loss while the oracle is frozen (11th item of Conditions and limits). The test uses a junior-only pool, a mock oracle with a constant mark, a test-only router adapter for the trader's commit and testnet manifest parameters; the test was not run on a fork or a deployment. Details: "Conditions and limits" (under Vulnerability Details). The full Delta table is in the Proof of Concept field.

Vulnerability Details

Root cause

By inspection, all code below is in packages/perps/src at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8. Line numbers were checked against that commit.

Site A: the VPI charge is booked as LP revenue at open

CfdEngineSettlementSidecar.executeOpen charges the trade cost, which includes the VPI charge, and records the cash that reaches the pool (after clearinghouse.applyOpenCost) as claimant Revenue with CashArrived. packages/perps/src/CfdEngineSettlementSidecar.sol:454-464:

Solidity
        if (delta.tradeCostAssets > 0) {
            uint256 poolCashInflowAssets = uint256(delta.tradeCostAssets) - protocolFeeCreditedAssets;
            if (poolCashInflowAssets > 0) {
                IHousePool(host.pool())
                    .recordClaimantInflow(
                        poolCashInflowAssets,
                        IHousePool.ClaimantInflowKind.Revenue,
                        IHousePool.ClaimantInflowCashMode.CashArrived
                    );
            }
        }

HousePool.recordClaimantInflow (packages/perps/src/HousePool.sol:624-651) adds the amount to accountedAssets. At the next reconcile the increase is allocated by the waterfall to junior principal after any senior impairment is restored (packages/perps/src/libraries/HousePoolReconcilePlanLib.sol:84-98, packages/perps/src/libraries/HousePoolWaterfallAccountingLib.sol:147-158). By code read, from that moment the junior share price includes the whole VPI charge.

Site B: part of the charge is paid back at close, from pool cash

When the position later reduces the skew, packages/perps/src/libraries/CfdEnginePlanLib.sol:973-978 plans an action rebate and pays it from free pool cash. It is waived only when that cash is not there:

Solidity
        if (delta.actionRebateAssets > 0) {
            delta.actionRebatePaidAssets =
                delta.actionRebateAssets < freePoolCashAssets ? delta.actionRebateAssets : freePoolCashAssets;
            delta.actionRebateWaivedAssets = delta.actionRebateAssets - delta.actionRebatePaidAssets;
            poolCashAfterCollectionsAssets -= delta.actionRebatePaidAssets;
        }

packages/perps/src/CfdEngineSettlementSidecar.sol:621-624 pays it with IHousePool(host.pool()).payOut(address(clearinghouse), delta.actionRebatePaidAssets).

packages/perps/src/libraries/CloseAccountingLib.sol:112-118 bounds the rebate by the VPI the position paid over its lifetime:

Solidity
        // Clamp so lifetime VPI (accrued + delta) never goes negative. Prevents LP sandwich attacks
        // where an attacker opens at high depth, reduces pool depth, then closes to extract a
        // net-negative lifetime VPI rebate. ...
        if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
            state.vpiDeltaAssets = -state.proportionalAccrualAssets;
        }

The VPI charge is refundable on the paths where the position later reduces skew at the same or lower depth, the pool has free cash, and the position is closed rather than liquidated: then the lifetime clamp returns up to what the position paid (packages/perps/src/libraries/CloseAccountingLib.sol:103-118, packages/perps/src/libraries/CfdEnginePlanLib.sol:973-978). On those paths the pool pays out cash that the share price already counted as revenue (packages/perps/src/libraries/CfdEnginePlanLib.sol:973-978, packages/perps/src/CfdEngineSettlementSidecar.sol:454-464). On other paths (liquidation, which does not compute a fresh VPI delta, packages/perps/SECURITY.md:1436; depth growth, where the rebate shrinks; an unfunded rebate, which is waived) the pool keeps it. By code read, the NAV used for exits has no term for the refund on the paths where it is paid, so the exit price is too high exactly there; on the paths where the pool keeps the charge, the NAV is already right (an LP who exits before a liquidation gives up the pool's gain, 8th item of Conditions and limits).

Where the NAV omits it

LP entry and exit are priced from HousePoolAccountingLib.buildReconcileSnapshot (packages/perps/src/libraries/HousePoolAccountingLib.sol:60-78). It starts from the pool's physical assets (terminalAssets = engineSnapshot.physicalAssets), which already contain the cash from Site A, adds the marked price delta terminalLpPriceDeltaAssets and subtracts trader claims. The inputs come from CfdEngineProtocolLens.getHousePoolInputSnapshot (packages/perps/src/CfdEngineProtocolLens.sol:62-70): snapshot.physicalAssets = poolAssets, where poolAssets = engineContract.pool().totalAssets(), and snapshot.terminalLpPriceDeltaAssets = terminalSnapshot.terminalLpPriceDeltaAssets. terminalLpPriceDeltaAssets is the marked price PnL of open positions. TerminalNavBookV2 deliberately excludes VPI from it, and the documentation states this as the intended design (packages/perps/SECURITY.md:863, packages/perps/SECURITY.md:871-872, packages/perps/ACCOUNTING_SPEC.md:1064). The documents say that "neither anticipated VPI nor its reserve inflates terminal K or symmetric NAV" (packages/perps/SECURITY.md:872). This report accepts that exclusion: it does not ask for anticipated VPI to be added to the price book. It concerns a different quantity, the VPI already collected, which the documents do not address: the booked positive VPI is already cash in physicalAssets (packages/perps/WHITEPAPER.md:411-412, in the paragraph on the open-time admission test) while the rebate that returns part of it is paid from the same pool. The suggested fix therefore changes the documented NAV treatment, a design decision for the maintainers; the evidence that it is a defect rather than a trade-off is the LP-to-LP transfer in the test below.

Size of the unreserved amount

The VPI curve is CfdMath.tryGetSkewCost (packages/perps/src/CfdMath.sol:118-140): cost(S, D) = vpiFactor * S^2 / (2 * D). By code read, with vpiFactor = 0.01 (Arbitrum Sepolia v2.0.0 release manifest, deployments/releases/2026-10-28-perps-arbitrum-sepolia-v2.0.0/manifest.json:166, also script/DeployPerpsArbitrumSepolia.s.sol:434-445; the test sets it in _riskParams()) and S = r * D:

F = cost(S, D) = 0.005 * r^2 * D   (inferred from 0.01 / 2 = 0.005)

D is the pool's economic depth, canonical assets minus outstanding trader claims (packages/perps/SECURITY.md:391). r is the net skew divided by that total depth (junior plus senior). By code read of the manifest, maxSkewRatio is 0.4e18, so r is inferred to be at most 0.4 and F to be at most 0.0008 * D, 8 bps of depth. Mainnet launch parameters were not available to us; F scales linearly with vpiFactor and quadratically with skew, so the figures here would change with them.

By the formula above (inferred), at the fixture (r = 0.30, D = 10,000,000 USDG) F is 4,500 USDG. By code read of the test file, the attacker holds 60 percent of the junior tranche, so its share of F is inferred to be about 2,700 USDG; it deposited 6,000,000 USDG. Its wallet ends at 6,002,699.999140 USDG (Delta table in the Proof of Concept field). The passive LP is inferred to earn 732.329233 USDG of pool revenue over the window the attacker is out of the pool; by the same inference, 2,699.999140 - 732.329233 = 1,967.669907, the gain in the Delta table. That 732.329233 USDG is inferred to be 60 percent of the part of the booked charge that the pool keeps in the passive world: by the same inference, 4,499.9991 booked less 3,279.450138 paid at the close is 1,220.548962, and 0.6 times that is 732.329377, within 0.0002 USDG of the figure in the Delta table (the booked and paid amounts come from a copy of the test with log lines added; see Attack steps, fourth item).

Equivalently, the attacker's gain is inferred to be its 60 percent share of the rebate the pool pays: by the same inference, 0.6 * 3,279.450138 = 1,967.670083 against 1,967.669907 in the Delta table. In the control with the VPI charge switched off the attacker loses 11.080668 USDG over the same window, which is the carry yield it forgoes (test_control_noVpi). Inferred from the wallet balances in the Delta table, with the VPI charge it forgoes 732.329233 USDG of revenue and its wallet gains 2,699.999140 USDG of unreserved charge. By code read, with no VPI there is no rebate to net the close execution fee against, so the fee goes to the treasury and the pool keeps only carry; with the VPI charge, inferred from the logged figures, about 1,200 USDG of the 1,220.55 USDG the pool keeps is that fee (Attack steps, fourth item).

Attack steps

By code read of the test file, all steps are calls by accounts with no role. The trader is an unrelated user the attacker neither controls nor funds. Times are seconds after the trader's open in the linked test.

  1. By code read of the test file: the trader commits an order (in the test through LegacyOrderRouterHarness, a test-only commit adapter, see the 9th item of Conditions and limits) and a keeper (anyone) executes it, a LONG of 3,000,000 tokens at mark 1.00 (30 percent of depth). The VPI charge is booked as LP revenue (Site A). By code read of the test file, it is executed at +1 s.
  2. By code read of the test file, the attacker, a junior LP holding 60 percent of the junior shares, calls requestRedeem on the junior vault for all its shares at +600 s. A request must be placed at least 5 minutes before the epoch boundary (packages/perps/src/TrancheVault.sol:39); epochs are one hour (packages/perps/src/HousePool.sol:178).
  3. By code read, anyone calls OrderRouter.settleLpEpoch (packages/perps/src/OrderRouter.sol:479-484, permissionless) after the boundary; in the test, by code read of the test file, at +3,599 s. By code read, the attacker is paid at the NAV that includes F while the position is still open. Inferred from the logged pool depths, the attacker's exit cuts pool depth from about 10M to about 4M. Inferred from those depths, after the exit the 3,000,000 token position is about 75 percent of the remaining depth, above the 40 percent maxSkewRatio; the redemption was nonetheless paid in full in the test (code read of the test file). maxSkewRatio is checked when a position is opened or increased (packages/perps/src/libraries/CfdEnginePlanLib.sol:473-477; packages/perps/src/CfdTypes.sol:88-94); we did not find an equivalent check on LP exits, but we did not audit that. We report this as a fact of the test and make no separate claim about it.
  4. By code read of the test file, the trader closes (requested at +14,400 s, executed at +14,401 s). The close plan computes the action rebate as the VPI rebate (clamped to the lifetime VPI accrued) less the execution fee and carry due on the close (packages/perps/src/libraries/CfdEnginePlanLib.sol:1041-1044 and packages/perps/src/libraries/CfdEnginePlanLib.sol:1059-1061), and the pool pays it from its cash (Site B). Measured in a copy of the test with log lines added (output in the linked supplementary measurements file), the booked charge is 4,499.9991 USDG and the pool pays 3,279.450138 USDG at the close in the passive world and 3,260.645136 USDG in the attack world. The difference to the booked charge (1,220.55 and 1,239.35 USDG, inferred from the logged figures) stays in the pool. In this path the execution fee is not collected from the trader and credited to the treasury; it is netted against the rebate, so the pool pays less and keeps it (packages/perps/src/libraries/CfdEnginePlanLib.sol:1041-1044, packages/perps/src/libraries/CfdEnginePlanLib.sol:1059-1061). The treasury balance did not change at the close in either world (see the supplementary measurements). The WHITEPAPER passage cited below states that the protocol execution fee belongs to treasury rather than LP assets for the open; we did not check the netted close path against that intent. About 1,200 USDG of each difference is, by inference, consistent with the 4 bps execution fee (1,200 USDG on 3,000,000 notional, manifest executionFeeBps 4) and the remainder with carry netted in the same plan; we did not log those components separately. Inferred from the logged depths, not from a clamp flag: by the VPI formula the cost of closing is about 4,497.98 USDG at the passive world's depth (10,004,501.999 USDG), below the 4,499.9991 accrued, so the lifetime clamp does not bind there; at the attack world's depth (4,001,801.999 USDG) the cost is about 11,244.9 USDG and the clamp binds. The gross VPI rebate is therefore inferred to be about 2.02 USDG larger in the attack world (0.1 percent of the attacker's gain). The cash paid is nevertheless 18.805002 USDG lower. The amount netted against the rebate is inferred to be about 1,239.35 USDG in the attack world against about 1,218.52 in the passive world (these two figures and the clamp reading are computed from the logged figures, not logged themselves). We did not determine why the netted amount differs. The remaining junior LPs bear the rebate.
  5. The attacker calls requestDeposit with the cash it received and claims the shares after the next epoch (+17,999 s, by code read of the test file). By code read, because the refundable amount is no longer in the share price, it would receive more shares for the same cash than it gave up. A one-hour holder cooldown (packages/perps/src/TrancheVault.sol:38) applies before its next exit.

In the output the attacker holds 6,004,946.797644148 shares at the end instead of 6,000,054.000432003, for the same cash.

Conditions and limits

Numbers marked "separate runs" come from a parametrised copy of the test (net skew, attacker share, senior deposit and position life are its knobs) or from the same test with the fix sketch applied. That copy is not among the linked files; its raw output lines are copied into the linked file supplementary-measurements.txt. These numbers give context and are not needed for the finding.

  1. Collusion-free LP cycle. The report covers this case and nothing else. The trader is unrelated; the attacker is a plain junior LP. A variant in which the LP also operates the trader was not found to be reliably profitable once a senior tranche is present and is not part of this report.
  2. Skew threshold. Separate runs (not run again for this report): the cycle loses 0.30 USDG at 5 percent net skew and 0.77 USDG at 8 percent, and gains 58.77 USDG at 10 percent; the break-even lies between 8 and 10 percent (a linear read of the 8 and 10 percent rows gives about 8 percent). Inferred from those runs, above 20 percent the gain is close to s * D * r * (0.005 * r - 4.05e-4), with s the attacker's share of the junior tranche (within 0.3 percent at 20, 30 and 39 percent). By the same inference, that fit does not hold at 5 to 10 percent (it gives -46.5 at 5 percent, -2.4 at 8 percent and +57.0 at 10 percent), and the 4.05e-4 term is of the size of the 4 bps execution fee (manifest executionFeeBps 4) plus carry, which the close plan nets against the rebate; if that is its source, the break-even is where 0.005 * r = 4.05e-4, near 8 percent net skew. We did not test that attribution separately.
  3. Bounded. Inferred from the manifest's maxSkewRatio, F is at most 8 bps of pool depth. Inferred from the Delta table and the separate runs, per cycle the gain is about 3.3 bps of the attacker's capital at 30 percent skew and about 6.0 bps at 39 percent (3,604.70 USDG in a separate run).
  4. Netting traders. The gain follows the net skew, and with several traders the sign depends on the closing order. Separate runs (not run again for this report): with a long and a short trader, net skew 20 percent with the smaller leg closing first gave the attacker +466.75 USDG; closing the dominant leg first, or a net skew of zero, gave a loss of between 1,331.83 and 5,420.96 USDG; the reason, by inference, is that the attacker's exit cuts depth and every later skew-increasing leg then pays VPI at the smaller depth.
  5. Timing. The position must be open at an hourly settlement. Separate run (not run again for this report): with the trader closing 30 minutes after the open, before the first epoch boundary, the attacker gained 0.000006 USDG.
  6. By code read of the test file, the headline is the 4 hour case. Separate runs (not run again for this report): the attacker still gained at longer position lives (24 h +1,912.10, 72 h +1,778.72, 168 h +1,511.96 USDG), but part of that gain is carry-collection timing, a documented collection-time ownership policy (packages/perps/ACCOUNTING_SPEC.md:731-740). This report does not rely on them.
  7. Fixture and senior tranche. By code read of the test file, the test has a junior-only pool: the incumbent holds 4,000,000 USDG, the attacker 6,000,000 USDG, and the senior tranche is only its 1 USDG seed. By code read of the test file, there is one trader with a 3,000,000 token LONG (r = 30 percent) and no offsetting flow. A pool with a real senior tranche is not modelled. By code read, two code paths may move the result either way: F accrues to the junior tranche only while it is sized on total depth, and junior redemption funding is limited by the senior covenant (packages/perps/SECURITY.md:396; packages/perps/src/HousePool.sol:1205-1216), which can reduce or block the exit step. Separate runs (not run again for this report): with a senior tranche added (the same 3,000,000 token position), the gain was +1,181.79 USDG with 5,000,000 senior and +843.41 with 10,000,000 senior, against +1,967.67 with none. Separate run (not run again for this report): with 30,000,000 senior the exit seems to have been capped by the covenant: the attacker's first exit paid 2,500,098 USDG of its 6,000,000 USDG, and the cycle lost 2,496,678 USDG against the passive LP. Earlier sweep rows (not run again for this report): the senior deposit is set to 0.25 to 3 times the junior tranche, and the rows showed gains between +1,730.50 and +4,244.13 USDG without the sketch (supplementary file, B2b); we did not reconcile those rows with the 5, 10 and 30 million rows above (not established), so the senior effect is not shown to be monotone. The launch senior ratio is unknown to us and we make no claim about either direction for a real pool.
  8. Oracle. By code read of the test file, the test uses MockPyth with confidence 0 and a constant basket mark of 1.00; price PnL between the exit and the close is not modelled. In two separate runs (not run again for this report) with the mark moved by +1 percent and -1 percent between the open and the close the gain stayed positive (+1,961.69 and +1,921.16 USDG). In one separate run (not run again for this report) in which the trader was liquidated after the exit (mark +6 percent, margin 1 percent) the cycle lost 13,679.999150 USDG against the passive LP; the reason, by inference, is that the exiting LP forgoes the pool's gain on the liquidation, so the cycle carries price risk. We did not model a price distribution, real oracle updates with signatures or confidence.
  9. Router. The trader's commit uses LegacyOrderRouterHarness, a test-only adapter that exposes a commitOrder entry with wide execution bounds. The harness is the repository's own (test/utils/LegacyOrderRouterHarness.sol, deployed by BasePerpTest): it turns the scalar commit into a V3 order request whose execution bounds are all set to the maximum and enters the production V3 commit by self-delegatecall (packages/perps/test/utils/LegacyOrderRouterHarness.sol:63-81). Execution (executeOrder), VPI computation and LP settlement (settleLpEpoch) are the production code paths. The production commit is the financially bounded V3 OrderRouter.commitOrder (packages/perps/src/OrderRouter.sol:77-90); we did not run it with realistic bounds, and the repository's production-router fixture (test/perps/gas/DirectCloseGas.t.sol) was not used.
  10. Set-up. setUp warps time backward once, after the timelock warps (as the repository's own test base does); harmless here. By code read of the test file, the deployer acts only in setUp; the exploit leg uses no privileged call.
  11. The report concerns a live oracle. When the oracle is frozen, exits pay a frozen-window LP fee (packages/perps/src/HousePool.sol:1147-1155). Separate run (not run again for this report): with the oracle frozen and a frozen LP fee that is not a release-manifest value (it is of the order of the contract's own default of 75 bps for junior), the attacker was paid 5,959,529 USDG for shares worth 6,000,000 USDG, a haircut of about 67 bps, far above the 8 bps maximum. Mainnet values of that fee are not known to us.
  12. Fees. The manifest sets the junior maintenance fee to 0 bps (script/DeployPerpsArbitrumSepolia.s.sol:138, deployments/releases/2026-10-28-perps-arbitrum-sepolia-v2.0.0/manifest.json:192). Other values were not re-run.
  13. The trader ends 18.805002 USDG lower in the attack world. This equals the difference between the cash the pool pays the trader at the close in the passive and attack worlds (3,279.450138 against 3,260.645136 USDG; Attack steps, fourth item). The gross VPI rebate is inferred to be about 2.02 USDG larger in the attack world through the clamp (Attack steps, fourth item), so the cash difference is the amount netted against the rebate (about 20.83 USDG more in the attack world) less that 2.02 USDG; we did not determine why the netted amount differs. Inferred from the Delta table, about 1 percent of the attacker's gain comes from the trader and 99 percent from the incumbent junior LP.
  14. Not run on a fork or deployment. The ticks are synthetic. The launch TVL, the senior share, the open interest and the mainnet risk parameters are unknown to us.

Suggested fix

Treat the refundable part of booked VPI as a liability until the position closes. The sketch in the linked suggested-fix.diff adds totalVpiAccrued to CfdEngine, the sum of every open position's vpiAccrued, updated in settlementWritePosition (packages/perps/src/CfdEngine.sol:1269) and settlementDeletePosition (packages/perps/src/CfdEngine.sol:1283). CfdEngineProtocolLens then subtracts it from terminalLpPriceDeltaAssets before the snapshot reaches buildReconcileSnapshot (packages/perps/src/CfdEngineProtocolLens.sol:70).

Tested effect, on a copy of the same commit: test_exploit_collusionFreeExitTiming fails (attacker 5,999,999.999950 USDG against 6,000,732.329233 for the passive LP, a delta of -732.329283). The controls still pass (5 passed, 1 failed in the mutant log). Separate runs (not run again for this report): with the sketch applied, the single-trader cycle rows (net skew 5 to 39 percent, longer position lives, and six senior-tranche rows with the senior deposit set to 0.25 to 3 times the junior tranche; these are not the 5, 10 and 30 million rows of limit 7, which were not re-run with the sketch) all turned negative; the headline row loses its forgone revenue (about -732.33 USDG). Same separate runs (not run again for this report): the 30-minute-close control stayed at +0.000006 USDG, rows with several traders or a liquidation also stayed negative (losses of 733.92 to 16,379.998 USDG), and the two rows (12a, 12c) in which LP depth grows while a position is open stayed positive for the entering LP (see the side effect below). The CfdEngine runtime size went from 23,137 to 23,278 bytes (limit 24,576). HousePool is at 24,571 bytes in the same build, so a fix should avoid changing it.

The maintainers should also consider two points. One point: the sketch sums vpiAccrued including negative values; how negative balances should be treated, given the dedicated reserve for them (packages/perps/SECURITY.md:866), was not tested. Another point: the rebate is computed at close-time depth and clamped to the accrued amount (packages/perps/src/libraries/CloseAccountingLib.sol:103-118). If LP deposits grow depth while a position is open, the rebate shrinks and the difference stays in the pool. Today the staying LPs keep it; with the sketch the entering LP would. One separate row (not run again for this report): depth growing from 5,000,000 to 10,000,000 USDG while a 1,500,000 notional position was open; the trader ended 1,120.79 USDG lower, against +3.44 with vpiFactor 0, so the effect is VPI-related; the rebate itself was not logged. This is a side effect to decide together with the fix, and it is adjacent to the AI-scan items named below.

Why this is not a known issue

The programme lists the audit reports and SECURITY.md Known Limitations as known. We checked the programme-listed items (the answers are in OUT-OF-SCOPE-ANSWERS.md, one by one). By inspection, no item lists LP exit pricing against booked VPI as a limitation. We address the nearest docu

The original report as published on Immunefi, by drMurlly. 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 net asset value used to price LP redemptions counts the booked VPI charge as cash but has no liability term for the portion that can later be refunded as a rebate.

Impact

A large junior LP could gain at the expense of other junior LPs, though the effect is bounded to at most 8 bps of pool depth per cycle, needs net skew above roughly 8 percent, and may be reduced or blocked by a senior tranche covenant.

What the attacker needed

Attacker is a large junior LP; one-hour cooldown between exit and re-entry; unrelated trader opens a skew-increasing position; net skew above about 8 percent

How it was found

  1. An unrelated trader opens a large long position, and the VPI charge is booked as LP revenue.
  2. The attacker, a junior LP holding most of the junior shares, requests redemption of all its shares.
  3. A permissionless epoch settlement pays the attacker at the NAV that still includes the booked charge.
  4. The trader closes, and the pool pays a rebate out of its cash to the remaining LPs' cost.
  5. The attacker requests a deposit with the cash received and claims shares after the next epoch.

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.

When someone opens a large trade, the pool charges them a fee for pushing the market out of balance, and that fee is immediately counted as profit for the people who put money in the pool. Part of that fee is given back when the trade is closed, but the pool's share price does not set anything aside for that give-back. So a big depositor can cash out at the inflated price before the refund happens and buy back in afterwards, leaving the other depositors to cover the refund.

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 drMurlly

View all

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