Skip to content
Business logic Audit finding Advanced

Positive VPI paid by an open position is priced into Junior NAV although the lifetime clamp returns it on that position's skew-restoring close, so a Junior LP can redeem at a self-inflated NAV and take incumbent Junior LPs' funds

A skew-increasing open position pays a positive VPI charge that is booked into pool cash and counted in Junior NAV, even though the lifetime clamp lets that same position reclaim the charge when it closes and restores skew. A Junior LP can open such a position just before an epoch boundary, have its matured redemption funded at the inflated NAV, then close and take the rebate, leaving incumbent Junior LPs to absorb the loss.

emanueldlvg Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#98608 [SC-Critical] Positive VPI paid by an open position is priced into Junior NAV although the lifetime clamp returns it on that position's skew-restoring close, so a Junior LP can redeem at a self-inflated NAV and take incumbent Junior LPs' funds

Submitted on Nov 9th 2026 at 01:29:53 UTC by @emanueldlvg for Audit Competition | Plether

Description

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

The program states that the v2.0.0 Arbitrum Sepolia release is built from a commit whose packages/perps/src is identical to a82d4fef. I also compared the deployed runtime bytecode of the contracts below with an a82d4fef build, excluding immutables and metadata, and they match. The proof of concept runs in the repository's Foundry suite at the in-scope commit, with the release parameters and Pyth mocked. No in-scope contract is modified.

Contract Arbitrum Sepolia v2.0.0 address Role in the issue
CfdEngineProtocolLens (created by HousePool) 0x82fc00d77e86c52e2480459d07ad6220f1106413 Root cause. getHousePoolInputSnapshot prices LP entry and exit from pool.totalAssets(), which includes positive VPI that an open position can still take back
HousePool (HousePoolAccountingLib) 0xeb5604c393843b2f3c347ec24fa9ddad6ab2131e Root cause. buildReconcileSnapshot is the canonical entry/exit price; _settleLpEpoch funds matured redemptions at it
CfdEngineSettlementSidecar 0xd3ede337e042d5aa6ba68e03d0c885b3d4a062dc Books an open's positive VPI as LP revenue (recordClaimantInflow(Revenue, CashArrived)); pays the close-time VPI rebate out of HousePool
CfdEnginePlanner (CfdEnginePlanLib, CloseAccountingLib) 0x802a0755413fb966b397155b5c5cc0198e6bed3f Plans the open charge, and the close rebate up to the position's own lifetime accrual (lifetime clamp)
TrancheVault (Junior) 0x4a8b67184a1e3224c11a191cc69f22c50eef734e Escrows the redemption request and pays the funded USDG
OrderRouter 0x918663d6da8cb33b325a04c4a5e8c51d42f3b444 Public commitOrder / executeOrder / settleLpEpoch used by the attacker and any keeper
CfdEngine 0xca18a6783d7542f9d2f28f4f259772b74c4d6baa Executes the open and close

Release parameters used (packages/perps/DEPLOYMENT.md and the program page):

  • risk: vpiFactor 0.01e18, maxSkewRatio 0.4e18, maintenance 10 bps, initial 20 bps, frozen-market 300 bps, baseCarryBps 500, liquidation bountyBps 10;
  • execution fee 4 bps, LP epoch 1 hour, LP deposit cooldown 1 hour;
  • Senior cap 40,000,000 USDG and 80% of the pool, both set through the 72-hour timelock;
  • Senior and Junior seeds of 1 USDG each.

Brief/Intro

A trader whose open increases the pool's skew pays a positive VPI charge. The Engine books that charge into HousePool cash as LP revenue straight away, so Junior NAV rises by the charge. The charge is not final, though. When the same position later closes and restores the skew, the lifetime VPI clamp rebates it up to exactly what that position paid, out of HousePool cash. For a trader who controls both legs, the VPI is a round trip that nets to zero.

LP pricing does not see that the cash will go back. The NAV that prices redemptions (and deposits) is pool assets minus trader claims plus the terminal price delta, and the refundable charge sits inside "pool assets". So between the open and the close, Junior NAV is overstated by the charge, and a Junior LP can create that overstatement on demand.

A Junior LP with a matured redemption opens a skew-increasing position about 90 seconds before the hourly LP epoch boundary. Any keeper then settles the epoch, which funds the redemption at the inflated Junior price. The attacker closes, the clamp returns the charge to it, and the Junior LPs who stayed absorb the rebate. The price is the same, 1.00, from start to finish; no oracle choice of any kind is involved.

Main proof of concept:

  • Pool: 30.01M USDG of depth: Senior 10M, an incumbent Junior LP 10M, and the attacker's Junior position of 10M, which it bought at the fair price.
  • Market: ordinary traders hold a 7.5M LONG, so organic skew is 25% of depth.
  • Attacker: a full redemption of its Junior shares, and a 4.2955M LONG that takes net skew to 39.3% of depth (the cap is 40%).

End to end, the attacker deposits 10,000,000.00 USDG into Junior and later redeems 10,006,807.67 USDG. Its trading collateral pays 3,436.84 USDG of execution fees and carry. Its absolute result is +3,370.83 USDG for one cycle. A control run from the same EVM snapshot makes the same deposit and redemption without the trade and ends at −91.26 USDG, which is the ordinary Senior coupon over the period. The trade is therefore worth +3,462.09 USDG against an honest LP round trip. The incumbent Junior LP's position ends 5,180.49 USDG lower than in the control. Three cycles in a row give the attacker an absolute +10,121.56 USDG and take 15,550.56 USDG from the incumbent.

Vulnerability Details

Root cause. LP entry and exit are priced from the pool's current cash, trader claims and the terminal price delta. That cash includes positive VPI charges paid by positions that are still open. The protocol's own lifetime clamp entitles those positions to a rebate of up to their whole accrued charge when they reduce skew again, and a trader that controls both legs can always do that. Pricing therefore treats as LP equity an amount that the paying position can withdraw again, and any redemption funded in between is overpaid.

1. A skew-increasing open pays its VPI into HousePool as LP revenue

CfdEnginePlanLib.planOpen turns the open's VPI and execution fee into tradeCostAssets (CfdEnginePlanLib.sol lines 331–333):

Solidity
delta.tradeCostAssets = openState.tradeCostAssets;
delta.marginDeltaAssets = order.marginDelta;
delta.poolRebatePayoutAssets = openState.tradeCostAssets < 0 ? uint256(-openState.tradeCostAssets) : 0;

CfdEngineSettlementSidecar.executeOpen collects it from the trader, sends the execution fee to the treasury and books the rest into the pool as claimant revenue with cash arrived (CfdEngineSettlementSidecar.sol lines 446–464, verbatim):

Solidity
        (int256 netMarginChange, uint256 protocolFeeCreditedAssets) = clearinghouse.applyOpenCost(
            delta.account,
            delta.marginDeltaAssets,
            delta.tradeCostAssets,
            host.pool(),
            host.protocolTreasury(),
            delta.executionFeeAssets
        );
        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.totalAssets() rises by the charge. In the proof, the attacker's 4.2955M LONG pays 13,807.50 USDG of positive VPI into the pool. The whitepaper states the effect: "Positive VPI increases physical pool assets" (WHITEPAPER.md line 411).

2. The same position's skew-restoring close is rebated up to that charge

At close, CloseAccountingLib.buildCloseState prices a fresh VPI delta on the current skew. A skew-restoring close has a negative delta, a rebate. The lifetime clamp only stops the position's lifetime VPI going below zero (CloseAccountingLib.sol lines 103–118):

Solidity
state.proportionalAccrualAssets =
    (inputs.position.vpiAccrued * int256(inputs.sizeDelta)) / int256(inputs.position.size);
if (inputs.poolDepthAssets != 0) {
    state.vpiDeltaAssets = CfdMath.calculateVPI(
        inputs.preSkewAssets, inputs.postSkewAssets, inputs.poolDepthAssets, inputs.vpiFactor
    );
}
// Clamp so lifetime VPI (accrued + delta) never goes negative. ...
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
    state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}

A position that paid C at open and closes back to the original skew therefore receives a rebate of exactly C: the fresh delta is −C at unchanged depth, and the clamp caps it at −C at lower depth. CfdEnginePlanLib._planCloseActionSettlement turns the negative action amount into actionRebateAssets (lines 1041–1061). The plan pays it from pool cash free of trader claims (lines 973–977), and CfdEngineSettlementSidecar.executeClose moves it out of the pool (lines 621–624, verbatim):

Solidity
        if (delta.actionRebatePaidAssets > 0) {
            IHousePool(host.pool()).payOut(address(clearinghouse), delta.actionRebatePaidAssets);
            clearinghouse.settleAssets(delta.account, int256(delta.actionRebatePaidAssets));
        }

In the proof, the close pays 12,089.06 USDG out of the pool to the attacker. That is the 13,807.50 USDG charge less the 1,718.44 USDG close execution fee, which the close planner nets into the rebate and leaves in the pool. The attacker's VPI round trip nets to zero, and only its two execution fees remain as cost.

3. LP pricing counts the refundable charge as equity

CfdEngineProtocolLens.getHousePoolInputSnapshot builds the LP pricing inputs from the pool's physical assets (CfdEngineProtocolLens.sol lines 59–73):

Solidity
ICfdEngineTypes.TerminalNavSnapshot memory terminalSnapshot = engineContract.terminalNavSnapshot();
uint256 poolAssets = engineContract.pool().totalAssets();
snapshot.physicalAssets = poolAssets;
...
snapshot.terminalLpPriceDeltaAssets = terminalSnapshot.terminalLpPriceDeltaAssets;
snapshot.traderClaimBalanceAssets = terminalSnapshot.totalTraderClaimsAssets;

HousePoolAccountingLib.buildReconcileSnapshot, "the single canonical terminal-NAV snapshot shared by LP entry and exit pricing", computes distributable = physicalAssets + terminalDelta − traderClaims (HousePoolAccountingLib.sol lines 57–78). No term subtracts the positive lifetime VPI that open positions can reclaim. HousePool._settleLpEpoch reconciles against that snapshot and then funds matured redemptions in _fundRedemptionPhase from the post-reconcile tranche principal and supply (HousePool.sol lines 876–888, 944–960). The specification describes this ordering: "synchronized settlement prices funded shares from the post-reconcile, pre-burn tranche snapshot" (ACCOUNTING_SPEC.md lines 572–573).

While the attacker's position is open, the 13,807.50 USDG charge is Junior revenue, so the Junior price is overstated by it. A redemption funded in that window takes its share of the charge in USDG.

4. The attacker controls both ends

The epoch boundary is public and hourly. The attacker opens its skew-increasing position shortly before the boundary of the epoch in which its own full redemption matures. Whoever settles that epoch, the protocol's keeper or anyone else, funds the redemption at the inflated price. The attacker closes immediately afterwards and receives the charge back. Its price exposure lasts about two minutes. No oracle choice is involved: the proof uses one price, 1.00, for every tick.

Relation to documentation and published findings

  • Mechanism, not harm. WHITEPAPER.md line 411 ("Positive VPI increases physical pool assets") describes the cash effect at open, for the admission predicate.
  • Anticipated VPI. ACCOUNTING_SPEC.md lines 1064–1066 and SECURITY.md lines 870–872 say that anticipated VPI and its reserve do not inflate terminal K or symmetric LP NAV. Here the cash has already arrived, and the inflation comes from counting cash that the same position can reclaim, which these sentences do not address. They do state the intent, and that intent supports this report. ACCOUNTING_SPEC.md lines 1064–1066 say that "anticipated carry, VPI, fees, spreads, and other action economics stay outside terminal K" and that the VPI reserve "does not inflate marked LP receivables or symmetric LP NAV". Refundable positive VPI held as pool cash does inflate symmetric LP NAV until the position that paid it closes.
  • Timing. WHITEPAPER.md lines 742–744 ("a matured request is priced at the valid snapshot when a permissionless caller actually settles it") accepts market timing risk. It does not cover a NAV spike the redeemer creates itself and reverses right after.
  • Lifetime clamp. SECURITY.md line 1443 ("the lifetime clamp intentionally zeroes otherwise extractable rebate-only round trips") protects the trader-side VPI round trip. The comment on the clamp itself says it exists to prevent "LP sandwich attacks". The LP-side pricing of the same round trip is unprotected.
  • Not known. None of the listed reports or known-issue sections covers positive VPI in LP pricing or VPI round trips around LP epochs. The two published VPI items about pool depth need a change of depth between the open and close; here depth is unchanged until the attacker's own redemption, after which the clamp caps the rebate at the accrual.

Relation to the negative-VPI rebate NAV issue

This report is distinct from negative-VPI rebate NAV issue, in which a skew-reducing open's negative-VPI rebate is paid out of pool cash into a reserve that LP NAV excludes. That issue deflates NAV and is exploited with a deposit. This one inflates NAV and is exploited with a redemption, through the opposite VPI sign and a different accounting bucket.

  • The other issue's fix does not touch this one. Its mitigation adds the aggregate negative-VPI reserve, max(−vpiAccrued, 0) per position, to the LP pricing snapshot. In this scenario every open position, the organic LONG and the attacker's LONG, has positive vpiAccrued, so _negativeVpiReserveTarget returns 0 (CfdEnginePlanLib.sol lines 48–54) and that term is 0. The PoC asserts this at every settlement: negativeVpiReserveSeen stays false.
  • Measured. I applied that mitigation to a local copy of a82d4fef and re-ran an earlier variant of this test. The variant has the same mechanism and parameters; only the order of the attacker's deposit and the organic trade differs. Every number was unchanged to the atom (+3,473.23 USDG attacker, −5,193.43 USDG incumbent), while the other report's proof of concept stopped paying under the same patch.
  • Separate fix needed. This issue needs its own fix, in the positive-VPI term (see Recommendation).

Exploitation

The proof of concept uses the repository's BasePerpTest stack with the release risk parameters and the release Router configuration. Every LP action goes through the public TrancheVault / HousePool / OrderRouter entry points. Every trade goes through the public V3 commitOrder / executeOrder. Marks go through OrderRouter.updateMarkPrice. Prices come from the suite's Pyth mock, and no in-scope contract is modified. Each run is compared with a control branch from the same EVM snapshot, identical except that the attacker does not open and close its LONG. Every open posts 2% margin.

Main test (test_OneCycle_RedeemAtSelfInflatedNav):

  1. An incumbent Junior LP deposits 10,000,000 USDG and a Senior LP deposits 10,000,000 USDG through the public request/settle/claim path. Ordinary traders open a 7.5M LONG, which will be 25% of final depth.
  2. The attacker deposits 10,000,000 USDG into Junior at the fair price through the same public path, settled by a keeper through the Router. It waits out the 1-hour cooldown. Pool depth is now 30,014,064.50 USDG and the incumbent's Junior position is worth 10,013,925.43 USDG.
  3. The attacker requests redemption of all its Junior shares. The request matures at the next epoch boundary.
  4. About 90 seconds before the boundary, the attacker opens a 4,295,500 USDG LONG through the Router, taking net skew to 39.3% of depth. It pays 13,807.50 USDG of positive VPI into HousePool.
  5. The epoch starts and a keeper calls OrderRouter.settleLpEpoch. The attacker's redemption is fully funded at the inflated Junior price.
  6. The attacker closes its LONG. The skew-restoring close is rebated, and 12,089.06 USDG leaves the pool for the attacker: the charge less the netted close fee.
  7. The attacker claims 10,006,807.67 USDG. The control run, with the same deposit and redemption but no trade, returns 9,999,908.74 USDG.
  8. Result for one cycle:
    • Absolute: the attacker put in 10,000,000.00 USDG plus collateral. It got back 10,006,807.67 USDG and its collateral less 3,436.84 USDG of fees and carry: +3,370.83 USDG. The control ends at −91.26 USDG, because Junior pays the ordinary Senior coupon.
    • Against the control: +3,462.09 USDG.
    • Incumbent Junior: 10,008,516.62 USDG against 10,013,697.11 USDG in control, a loss of 5,180.49 USDG.
  9. Three cycles in a row (test_ThreeCycles): the attacker re-deposits the same 10M at the fair price each time, waits out the cooldown and repeats steps 3–7. It ends +10,121.56 USDG in absolute terms against −273.80 USDG in control, and the incumbent ends 15,550.56 USDG lower than in control.

Impact Details

Incumbent Junior LPs lose funds to an unprivileged attacker, and the attacker withdraws them as USDG.

  • The value moved. It is the position's positive VPI charge. The attacker places it in the pool before its redemption is priced and takes it back after its redemption is paid. Its share of the charge leaves with its redemption, and the rebate is then charged to the Junior LPs who remain.
  • Principal, not only yield. The incumbent's loss comes out of its Junior position value, and it compounds per cycle.

This is "Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield" (Critical). The griefing downgrade does not apply, because the attacker profits in absolute terms.

What the attacker needs. Let f be the attacker's share of Junior, σ the organic same-direction skew, s the attacker's open size and D the depth. Then:

  • Charge: C ≈ k·s·(2σ + s) / (2D) with k = 0.01, up to the 40% skew cap.
  • Capture: f × C.
  • Cost: two 4 bps execution fees on s, plus about two minutes of carry and price exposure.
Case (test_Sensitivity, same harness) Attacker share of Junior Organic skew Attacker vs control / cycle Incumbent loss / cycle
Main test 50% 25% +3,462.09 −5,180.49
No organic skew at all 50% 0% +2,150.86 (absolute +2,059.54) −6,867.06
Share sweep 20% 25% −507.59 −780.85
Share sweep 25% 25% +10.05 (break-even) −1,346.25
Share sweep 30% 25% +568.85 −1,959.65
Share sweep 40% 25% +1,850.91 −3,378.19
Share sweep 50% 25% +3,462.09 −5,180.49
  • No organic skew is required. At zero organic skew the attacker profits with half of Junior. Organic same-direction skew lowers the share needed: break-even is about 25% of Junior at 25% skew and about 40% at zero skew.
  • Incumbents always lose. They lose f × C minus the close fee kept by the pool, whether or not the attacker profits.
  • Redemption room. The redemption must fit the pool's free cash and the Junior covenant. Both hold in the proof: about 18M of free cash against a 10M exit, and the covenant leaves 17.5M of Junior withdrawable.
  • Repeatable. One cycle per deposit, activation, cooldown and redemption, about two to three hours.

Capital and risk. The attacker's capital is an ordinary Junior position bought at the fair price and redeemed in full, plus 2% margin on the trade. The program states: "A high capital requirement is generally not a valid reason to downgrade a report." The trade's price exposure lasts about two minutes and can be hedged off-chain. The remaining risk is that another trader reduces the skew before the close, which would turn part of the charge into genuine LP revenue.

Recommendation

Do not price LP entry and exit with positive VPI that an open position can still reclaim through the lifetime clamp. Keep it in physical cash for solvency and payout affordability. The positive lifetime VPI of open positions is a contingent rebate liability until the position closes.

Fix. Maintain an aggregate of open positions' positive lifetime VPI, Σ max(vpiAccrued, 0), in the Engine. Update it wherever vpiAccrued changes: open, increase, partial or full close, liquidation. Expose it through CfdEngineProtocolLens.getHousePoolInputSnapshot and subtract it from terminalAssets in HousePoolAccountingLib.buildReconcileSnapshot. When a position closes, the clamp-adjusted realized VPI leaves the aggregate. What the pool keeps becomes ordinary revenue, and what is rebated has never been priced as LP equity. Withdrawal funding keeps using physical cash minus reserves, so solvency checks do not change.

Solidity
// HousePoolAccountingLib.buildReconcileSnapshot (sketch)
uint256 terminalAssets = engineSnapshot.physicalAssets;
uint256 terminalLiabilities = engineSnapshot.traderClaimBalanceAssets
    + engineSnapshot.openPositivePositionVpiAssets; // refundable to open positions via the lifetime clamp

Add a regression test that funds a Junior redemption while a skew-increasing position is open, closes the position, and asserts that the incumbent tranche value is unchanged within rounding.

Proof of Concept

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

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

The file contains three tests:

  • test_OneCycle_RedeemAtSelfInflatedNav: the main case, with absolute and control results;
  • test_ThreeCycles: the main case three times in a row;
  • test_Sensitivity: zero organic skew, and the attacker's share of Junior at 25%, 30%, 40% and 50% (plus 20%).

How it is built:

  • It inherits the suite's BasePerpTest and overrides _riskParams() with the release values.
  • It sets the tranche seeds to 1 USDG and puts all LP capital through public deposits.
  • It applies the release Router configuration and the 40M / 80% Senior caps through the owner's 72-hour timelocked config paths.
  • Prices come from the suite's MockPyth. There is no vm.store, deal, etch or mockCall on in-scope contracts, and time is read with vm.getBlockTimestamp().
  • Each case reports the attacker's absolute USDG result (USDG redeemed minus USDG deposited, plus the change in trading collateral) and the same quantity in a control branch from the same EVM snapshot. The tests assert that the absolute result is positive, that it beats the control, and that the incumbent ends lower than in the control.

The suite's Router is the repository's test harness, which only adds a legacy scalar commitOrder overload. The proof uses the production V3 commitOrder(OrderRequest), executeOrder, updateMarkPrice and settleLpEpoch entry points.

Complete test:

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

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

/// @notice A skew-increasing open pays positive VPI into HousePool cash, which raises Junior NAV at once. The same
///         position's skew-restoring close is rebated up to its own lifetime accrual (CloseAccountingLib lifetime
///         clamp), so that cash goes straight back to the trader. A Junior holder with a matured redemption opens just
///         before the LP epoch boundary, lets any keeper settle the epoch (its redemption is funded at the inflated
///         NAV), then closes. Incumbent Junior LPs pay the rebate.
///
///         One constant price (1.00) is used throughout: no oracle tick choice is involved.
///         Public entry points only: LP capital through TrancheVault.requestDeposit / HousePool.settleLpEpoch (no open
///         positions) or OrderRouter.settleLpEpoch / TrancheVault.claimDeposit / requestRedeem / claimRedeem; trades
///         through OrderRouter.commitOrder / executeOrder; marks through OrderRouter.updateMarkPrice. Pyth (MockPyth)
///         and USDG (mock token) are the only mocks; no vm.store / deal / etch / mockCall on in-scope contracts.
///         Release parameters: DEPLOYMENT.md risk params, release Router config, 1 USDG seeds, Senior caps 40M / 80%.
contract PositiveVpiRedeemSpikePoC is BasePerpTest {

    address internal constant ORGANIC_LONG = address(0x0711);
    address internal constant ATTACKER = address(0xBADBAD);
    address internal constant INCUMBENT = address(0x1BC0);
    address internal constant SENIOR_LP = address(0x5E1105);
    address internal constant KEEPER = address(0xE0EC);

    uint256 internal constant PRICE = 1e8;
    uint256 internal constant SENIOR_DEPOSIT = 10_000_000e6;
    uint256 internal constant INCUMBENT_JUNIOR = 10_000_000e6;
    uint256 internal constant ATTACKER_COLLATERAL = 1_000_000e6;
    uint256 internal constant MARGIN_BPS = 200; // 2% margin on every open
    uint256 internal constant TARGET_SKEW_BPS = 3930; // the attacker tops net skew up to 39.3% of depth (cap 40%)

    uint256 internal orderNonce;
    bool internal negativeVpiReserveSeen;

    struct Run {
        uint256 attackerUsdgIn; // USDG the attacker deposited into Junior over all cycles
        uint256 attackerUsdgOut; // USDG the attacker redeemed from Junior over all cycles
        int256 collateralChange; // change of the attacker's trading collateral (fees, carry, VPI round trip)
        uint256 incumbentJuniorValue; // incumbent Junior position value at the end
        uint256 vpiCharge; // positive VPI paid into the pool by the attacker's first open
        uint256 rebate; // pool cash paid back to the attacker on its first close
    }

    struct Case {
        uint256 depth;
        uint256 attackerLongNotional;
        uint256 incumbentBefore;
        Run attack;
        Run control;
    }

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

    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        return CfdTypes.RiskParams({
            vpiFactor: 0.01e18,
            maxSkewRatio: 0.4e18,
            maintMarginBps: 10,
            initMarginBps: 20,
            fadMarginBps: 300,
            baseCarryBps: 500,
            minBountyAssets: 1e6,
            bountyBps: 10,
            keeperShareBps: 5000,
            protocolShareBps: 0
        });
    }

    function _initialJuniorDeposit() internal pure override returns (uint256) {
        return 0; // all LP capital enters through the public request/settle/claim path
    }

    function _initialSeniorDeposit() internal pure override returns (uint256) {
        return 0;
    }

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

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

    function setUp() public override {
        super.setUp();
        _applyReleaseRouterConfig(); // 72 h timelock
        _setSeniorCapacity(40_000_000e6, 8_000); // 72 h timelock
        assertEq(engine.executionFeeBps(), 4, "release execution fee");
        assertEq(pool.maxSeniorShareBps(), 8_000, "release Senior share cap");
        assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "release Senior exposure cap");
        vm.warp(SETUP_TIMESTAMP + 7 days); // Monday 10:00 UTC, live market
        _refreshMark(PRICE);
    }

    // ------------------------------------------------------------------ tests

    /// @notice Main case: attacker holds 50% of Junior, ordinary traders hold a LONG of 25% of depth.
    function test_OneCycle_RedeemAtSelfInflatedNav() external {
        Case memory c = _case(10_000_000e6, 2500, 1);
        _report("ONE CYCLE (attacker 50% of Junior, organic skew 25%)", c);

        int256 absoluteAttack = _absolute(c.attack);
        int256 absoluteControl = _absolute(c.control);
        assertGt(c.attack.vpiCharge, 0, "no positive VPI paid");
        assertGt(absoluteAttack, 0, "attacker ends with less USDG than it started with");
        assertGt(absoluteAttack, absoluteControl, "attack no better than an honest LP round trip");
        assertLt(c.attack.incumbentJuniorValue, c.control.incumbentJuniorValue, "incumbent Junior not harmed");
        assertFalse(negativeVpiReserveSeen, "a negative-VPI reserve existed at settlement");
    }

    /// @notice The same cycle three times in a row (re-deposit at fair NAV, 1 h cooldown, redeem with the trick).
    function test_ThreeCycles() external {
        Case memory c = _case(10_000_000e6, 2500, 3);
        _report("THREE CYCLES (attacker 50% of Junior, organic skew 25%)", c);
        assertGt(_absolute(c.attack), 0, "attacker ends with less USDG than it started with");
        assertGt(_absolute(c.attack), _absolute(c.control), "attack no better than an honest LP round trip");
        assertLt(c.attack.incumbentJuniorValue, c.control.incumbentJuniorValue, "incumbe

The original report as published on Immunefi, by emanueldlvg. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

How it worked

Root cause

Likely the LP pricing snapshot counts positive VPI cash paid by still-open positions as pool equity, without subtracting the contingent rebate those positions can reclaim through the lifetime clamp.

Impact

An unprivileged attacker could take funds from incumbent Junior LPs, profiting in absolute terms, though the profit depends on its share of Junior and the organic skew, and a competing trader reducing skew before the close would turn part of the charge into genuine LP revenue.

What the attacker needed

A Junior LP position bought at fair price; a matured redemption request; capital for a skew-increasing trade; a keeper settles the epoch

The fix

The report recommends tracking the aggregate positive lifetime VPI of open positions and subtracting it from terminal assets in the LP pricing snapshot, so refundable VPI is never priced as LP equity.

How it was found

  1. An incumbent Junior LP and a Senior LP deposit, and ordinary traders open a long position.
  2. The attacker deposits into Junior at the fair price and waits out the cooldown.
  3. The attacker requests redemption of all its Junior shares, maturing at the next epoch boundary.
  4. Shortly before the boundary the attacker opens a skew-increasing long, paying positive VPI into the pool.
  5. A keeper settles the epoch and the redemption is funded at the inflated Junior price.
  6. The attacker closes the long, receives the rebate, and claims its redemption.

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 of money lets people buy shares at a price based on what the pool holds. A trader can pay a temporary fee into the pool that the rules later give back when they close their trade. The pool's share price counted that fee as real money, so someone could buy out at a higher price and then take the fee back, leaving the other share holders short.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by emanueldlvg

View all

10 more disclosed reports, best first.

More from Plether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.