Skip to content
Business logic Audit finding Advanced

Open-side price-impact revenue is priced into the payer's own same-epoch LP redemption and then reclaimed as a close rebate, letting a dual-role LP and trader skim incumbent LP yield

Open-side positive price impact is booked immediately as realised liquidity-provider revenue, so a dual-role actor who is both a large junior LP and a trader can have its own same-epoch redemption priced against that inflated principal, then reclaim the same amount as a close rebate. The remaining junior LPs bear the outflow, letting the actor skim booked but unwithdrawn yield.

abarbatei Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#98031 [SC-Critical] Open-side price-impact revenue is priced into the payer's own same-epoch LP redemption and then reclaimed as a close rebate, letting a dual-role LP and trader skim incumbent LP yield

Submitted on Nov 4th 2026 at 13:57:40 UTC by @abarbatei for Audit Competition | Plether

Description

Brief/Intro

When a trader opens a position that increases pool skew, the engine charges a positive price-impact amount (VPI) and books it immediately as realized liquidity-provider revenue: pool totalAssets rises by exactly that amount, and the next reconcile routes it into tranche principal. The same position keeps the right to reclaim up to that whole amount as a close-time rebate paid from pool free cash. Nothing links a trader's position to that trader's own liquidity-provider shares. An ordinary address that is simultaneously a large junior liquidity provider, a trader, and a permissionless epoch settler can therefore open to inflate junior principal, settle so its own matured redemption is priced at the inflated principal, redeem to keep a share of its own still-reversible payment, and then close to reclaim the full payment as a rebate charged to the liquidity providers who stayed. In production this is a repeatable extraction of incumbent liquidity providers' booked, unwithdrawn trading-revenue yield by an untrusted actor.

Vulnerability Details

Normal intended behavior. A skew-increasing open pays a price-impact charge that compensates liquidity providers for taking on risk, and a quick open-and-close round trip is meant to net to approximately zero for the trader: the open-side charge is given back at close through a one-sided clamp that stops a trader from extracting more than it paid. Liquidity-provider epochs settle on a one-hour cadence, and a matured redemption is funded at the tranche principal that stands at settlement. Shared profit and loss and transient net-asset-value movement are expected and documented; what is not intended is for one untrusted actor to keep part of a charge it is about to have refunded, at the direct expense of the other liquidity providers.

Root cause. Open-side positive price impact is recognized as realized, reversible liquidity-provider revenue at the moment of the open, so it enters the principal that prices a same-epoch redemption before the payer gives that same amount back at close. The booking happens in the CfdEngineSettlementSidecar::executeOpen lines 454-464 function:

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
                    );
            }
        }

For a positive-impact open the pool-cash inflow equals the charge V (the execution fee has already gone to the treasury). Recording it as CashArrived revenue raises accounted assets at once, inside the HousePool::recordClaimantInflow lines 640-642 function:

Solidity
        if (cashMode == IHousePool.ClaimantInflowCashMode.CashArrived) {
            accountedAssets += amount;
        }

So pool.totalAssets() rises by exactly V from the instant of the open, and no reserve is withheld for a positive-accrual position.

Same-epoch pricing. Settlement reconciles the pool, which routes the newly arrived revenue into principal, and only then reads the principal that prices redemptions. The ordering is fixed in the HousePool::_settleLpEpoch lines 835-841 function:

Solidity
        _reconcile(accountingSnapshot, statusSnapshot);
        _checkpointEngineCarryIndexes();

        result.cutoffEpoch = cutoffEpoch;
        RedemptionPhase memory juniorPhase;
        juniorPhase.pricingPrincipal = juniorPrincipal;
        juniorPhase.pricingSupply = _juniorShareSupply();

Reconcile moves the distributable excess through the revenue waterfall. With the senior tranche at its high-water mark the whole amount lands in junior principal, in the HousePoolWaterfallAccountingLib::distributeRevenue lines 147-158 function:

Solidity
        if (remaining > 0 && nextState.seniorPrincipal < nextState.seniorHighWaterMark) {
            uint256 deficit = nextState.seniorHighWaterMark - nextState.seniorPrincipal;
            uint256 restore = remaining < deficit ? remaining : deficit;
            nextState.seniorPrincipal += restore;
            remaining -= restore;
        }

        if (nextState.seniorPrincipal > nextState.seniorHighWaterMark) {
            nextState.seniorHighWaterMark = nextState.seniorPrincipal;
        }

        nextState.juniorPrincipal += remaining;

That revenue routing is reached from reconcile through the HousePoolReconcilePlanLib::planReconcile lines 95-99 function:

Solidity
        if (plan.revenue) {
            plan.juniorPrincipalBeforeRevenue = plan.state.waterfall.juniorPrincipal;
            plan.state.waterfall =
                HousePoolWaterfallAccountingLib.distributeRevenue(plan.state.waterfall, plan.deltaAssets);
            return plan;
        }

The matured junior redemption is then funded at that post-reconcile principal, at zero settlement fee in the live (non-frozen) regime, in the HousePool::_settleLpEpoch lines 881-888 function:

Solidity
            juniorPhase.budget = _juniorSettlementCapacity(freeAssets, _getWaterfallState());
            juniorPhase = _fundRedemptionPhase(
                juniorVault, result.cutoffEpoch, juniorPhase, _settlementFeeBps(false, statusSnapshot.oracleFrozen)
            );
            if (juniorPhase.fundedAssets > 0) {
                juniorPrincipal -= juniorPhase.fundedAssets;
                accountedAssets -= juniorPhase.fundedAssets;
            }

A request placed in epoch E matures for epoch E+1, and any settlement during E+1 funds it. The settlement entrypoint is permissionless, so the actor can trigger it itself through the OrderRouter::settleLpEpoch function:

Solidity
    function settleLpEpoch(
        bytes[] calldata pythUpdateData
    ) external payable nonReentrant {
        pythUpdateData;
        _delegateToKeeperSidecar();
    }

Because the actor holds fraction a of the junior tranche, its redemption captures a * V of its own still-reversible payment, and the other (1 - a) * V stays credited to the liquidity providers who remain.

Reclaim at close. A skew-reducing close computes a fresh negative price impact at the post-redemption depth and clamps it so lifetime price impact cannot go below zero, that is, the rebate cannot exceed the accrual V. The clamp is applied in the CloseAccountingLib::buildCloseState lines 103-118 function:

Solidity
        state.proportionalAccrualAssets =
            (inputs.position.vpiAccrued * int256(inputs.sizeDelta)) / int256(inputs.position.size);
        // With no economic depth, keep protective exits live without creating a fresh charge or rebate.
        // The lifetime clamp below still recovers any previously received negative VPI.
        if (inputs.poolDepthAssets != 0) {
            state.vpiDeltaAssets = CfdMath.calculateVPI(
                inputs.preSkewAssets, inputs.postSkewAssets, inputs.poolDepthAssets, inputs.vpiFactor
            );
        }
        // 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. This rule is identical in live and oracle-frozen markets; frozen-market
        // stale-price risk is priced separately through frozenSpreadAssets.
        if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
            state.vpiDeltaAssets = -state.proportionalAccrualAssets;
        }

A negative net action produces a rebate equal to the price impact less the close fee and carry, in the CfdEnginePlanLib::_planCloseActionSettlement lines 1041-1061 function:

Solidity
        int256 actionNetAssets = cs.vpiDeltaAssets
            + int256(
                cs.executionFeeAssets + cs.frozenSpreadAssets + delta.pendingCarryAssets - delta.realizedCarryAssets
            );
        uint256 vpiClawbackWithheldAssets;
        if (actionNetAssets > 0) {
            delta.actionChargeAssessedAssets = uint256(actionNetAssets);
            delta.actionChargeWithheldAssets = delta.priceGainAssets < delta.actionChargeAssessedAssets
                ? delta.priceGainAssets
                : delta.actionChargeAssessedAssets;
            delta.actionChargeToCollectAssets = delta.actionChargeAssessedAssets - delta.actionChargeWithheldAssets;
            uint256 vpiClawbackAssets =
                _negativeVpiReserveTarget(snap.position.vpiAccrued) - delta.vpiRebateReserveAfterAssets;
            vpiClawbackWithheldAssets = delta.actionChargeWithheldAssets < vpiClawbackAssets
                ? delta.actionChargeWithheldAssets
                : vpiClawbackAssets;
            delta.vpiRebateReserveConsumedAssets = vpiClawbackAssets - vpiClawbackWithheldAssets;
            _planCloseCashSources(snap, delta, cs.remainingSize == 0);
        } else if (actionNetAssets < 0) {
            delta.actionRebateAssets = uint256(-actionNetAssets);
        }

The rebate is paid from pool free cash that reserves only outstanding trader claims, not liquidity-provider balances, in the CfdEnginePlanLib::_planIsolatedCloseSettlement lines 970-978 function:

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

The payout leaves the pool in the CfdEngineSettlementSidecar::_executeClose lines 621-624 function:

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

Because the actor's own shares have already left the pool at the redemption, the rebate outflow is borne by the junior principal that remains. Loss is taken junior-first at the next reconcile, in the HousePoolWaterfallAccountingLib::absorbLoss function.

Why the clamp does not stop this. The lifetime clamp is a trader-side control: it ensures a round-trip trader cannot reclaim more than it paid, so the trade itself is a loss of fees and carry. This finding never exceeds the clamp. The extraction is on the liquidity-provider leg, where there is no equivalent control: the redemption prices in the actor's own reversible payment before the close reverses it, and the one-sided clamp then lets the full payment flow back as a rebate drawn from the liquidity providers who did not time their exit.

Why this is not documented or accepted behavior. The accounting specification's collection-time ownership policy ("LP ownership follows collection time", in packages/perps/ACCOUNTING_SPEC.md) concerns carry, which is non-reversible once collected, and an incoming liquidity provider sharing revenue that belongs to the liquidity providers present when it accrued. The generic trade-off recorded in the project's history, that a permissionless settlement may be ordered before an unrelated later close or liquidation realizes a loss, describes a transaction-ordering race between independent parties. Neither covers this mechanism. Here the same actor creates the booked amount, holds a contractual right to reverse it through the lifetime clamp, and prices its own exit against it. No race and no third-party loss is involved, and the outcome is the same whatever order other participants' transactions take.

Attack sequence. The whole cycle uses only public entrypoints:

  1. Early in liquidity-provider epoch E, the actor requests redemption of its junior shares. The request matures for epoch E+1.
  2. The actor opens a skew-increasing position. The open charges the positive price impact V, which the pool books at once as CashArrived revenue, so pool.totalAssets() rises by V.
  3. After the epoch boundary, the actor calls the permissionless settlement entrypoint. Reconcile routes V into junior principal, and the matured redemption is then funded at that inflated principal, returning a * V of the actor's own payment to the actor.
  4. The actor claims the funded redemption, then closes the position skew-reducing. The lifetime clamp allows a rebate of up to V, paid from pool free cash. The actor's shares have already left, so the liquidity providers who remain bear the outflow.

Attacker role and preconditions. The actor is an ordinary address holding no privileged role. It needs a large junior share so that a * V exceeds the two execution fees and carry, pre-existing directional skew from third-party trading so a modest increment pays a price impact well above those fees, junior covenant and free-cash headroom at settlement, and a live, unpaused, fresh-mark regime. Live execution also applies the oracle's adverse-confidence price shift, which the proof does not model; at the release parameters it is at most 2.5 basis points of notional per leg, about 25 USDG per round trip at the proof's size, so the cycle stays profitable. No trusted-role action, parameter change, pause, or price manipulation is required. Liquidity-provider epoch settlement is explicitly a permissionless keeper action under the program rules.

Impact Details

A single untrusted actor extracts booked but unwithdrawn trading-revenue yield from the liquidity providers who remain in the junior tranche, and nets a positive profit, by timing a redemption between an open and its close. The captured value is the a * V portion of the actor's own price-impact payment that the redemption returns to it, which the remaining liquidity providers would otherwise have kept.

Measured at the release parameters, on a ten-million-USDG pool split six million senior and four million junior, with the actor holding about half of the junior tranche on top of a three-million-USDG third-party directional skew:

Quantity Value per cycle
Open-side price impact booked as revenue (V) 1,624 USDG
Redemption excess captured by the actor (a * V) 811 USDG
Close rebate paid from pool free cash 1,423 USDG
Attacker net profit +410 USDG
Incumbent junior liquidity providers net -611 USDG

The incumbent loss exceeds the attacker gain by the open-side execution fee of 200 USDG, which is credited to the protocol treasury. The close-side fee and the carry are netted out of the rebate and remain in the pool. Values are rounded to whole USDG, matching the integer values the proof logs. The cycle is repeatable: a fresh redemption request can be made each epoch, subject to the one-hour epoch cadence, the deposit cooldown, and the junior covenant cap. Profit scales linearly with the actor's junior share and with the pre-existing skew, so larger stakes and higher ambient skew raise the per-cycle take.

This maps to the program impact "Theft of unclaimed yield" (High). It is not a theft of at-rest principal: in the profitable regime the incumbents' absolute balance is cushioned by ongoing third-party price-impact revenue, so the loss is of yield relative to the fair, no-timing baseline. It is more than a failure to deliver promised returns, because value leaves the incumbents and reaches a profiting actor who chose the timing.

Mitigation

Address the root cause: do not let a liquidity-provider redemption be priced at principal that includes a price-impact amount the payer can still reverse. Any one of the following removes the extraction while preserving the documented shared profit and loss:

  • Defer recognition of open-side positive price impact into tranche principal until the position that paid it is closed or its reversibility window has passed, rather than crediting it as CashArrived revenue at the open. Hold it in a non-net-asset-value escrow bucket (symmetric with how the negative-impact reserve is already excluded from net asset value) so that a same-epoch redemption cannot be priced against it.
  • Alternatively, bound the close-time action rebate by the pool cash that remains after reserving liquidity-provider balances funded in the same or a pending epoch, not only outstanding trader claims, so a redeemer cannot be funded from principal that the close is about to withdraw.
  • Alternatively, extend the lifetime clamp to the actor's combined trader and liquidity-provider position, so that value returned through a redemption priced on the open-side impact reduces the rebate available at close.

The first option is the cleanest, matching the treatment already given to the negative-impact reserve, and does not change outcomes for liquidity providers who do not redeem across a round trip.

References

Proof of Concept

Proof of Concept

The proof runs in the repository's own Foundry test suite at the commit in scope. It extends the suite's base fixture BasePerpTest (at packages/perps/test/perps/BasePerpTest.sol), which deploys the full perps stack (CfdEngine, HousePool, the Senior and Junior TrancheVaults, MarginClearinghouse, PletherOracle, OrderLifecycleBook and the OrderRouter) and mocks only the two out-of-scope components, the settlement token and Pyth, through the suite's MockSettlementToken and MockPyth. No contract in scope is modified.

The attack is end to end. Every step is a transaction sent from the attacker address to a public entrypoint of the deployed stack: TrancheVault::requestRedeem and TrancheVault::claimRedeem on the junior vault, OrderRouter::commitOrder with the production V3 bounded order request, OrderRouter::executeOrder with caller-supplied Pyth data (the attacker executes its own orders as a permissionless keeper), OrderRouter::updateMarkPrice, and OrderRouter::settleLpEpoch with caller-supplied Pyth data. No call pranks a protocol contract; the only cheats are picking the sender, funding ETH for the Pyth fee, and time warps. The suite's helpers are used only to fund the pool and the traders before the attack and to configure the out-of-scope Pyth mock. A single test demonstrates the impact; the counterfactual that isolates the capture is folded into that test arithmetically, by repricing the identical funded shares at the identical post-reconcile principal minus the actor's own V.

Setup assumptions:

  • Toolchain: Foundry with Solidity 0.8.35 and via-IR, as pinned by the perps package foundry.toml (optimizer 200 runs).
  • Place the proof under a fresh directory inside the perps package test tree, packages/perps/test/poc/vpi-epoch-redemption-timing/ProofVpiEpochRedemptionTiming.t.sol. The ../../perps/BasePerpTest.sol import resolves the base fixture from that location, and the @plether/perps/ imports resolve through the package's own remappings (@plether/perps/=src/). No build fix to the target was needed; the package compiles the proof and its dependencies unchanged.
  • Risk parameters are set to the DEPLOYMENT.md release values through the fixture's _riskParams override (vpiFactor 0.01, maxSkewRatio 0.4, maintMarginBps 10, initMarginBps 20, fadMarginBps 300, baseCarryBps 500, executionFeeBps is the suite default 4). The pool is funded to 10M USDG (6M senior, 4M junior split evenly between the actor and one incumbent), with a 3M-USDG third-party directional skew. No network or fork is used.

Exact execution command (run from packages/perps):

forge test --match-contract ProofVpiEpochRedemptionTiming -vv

Full proof source:

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

import {BasePerpTest} from "../../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {IAsyncTrancheVault} from "@plether/perps/interfaces/IAsyncTrancheVault.sol";
import {IHousePoolRedemptionMathSidecar} from "@plether/perps/interfaces/IHousePoolRedemptionMathSidecar.sol";

/**
 * End-to-end proof. One untrusted address wears three hats at once:
 *   (1) junior LP holding ~50% of the junior tranche,
 *   (2) trader of a skew-increasing position whose open-side price-impact charge V is
 *       booked at once as CashArrived LP revenue (CfdEngineSettlementSidecar.executeOpen),
 *   (3) permissionless keeper that executes its own orders and settles the LP epoch.
 *
 * Every attack step is a transaction sent by that address to a public entrypoint of the
 * deployed stack: TrancheVault.requestRedeem / claimRedeem, OrderRouter.commitOrder (the
 * production V3 bounded request), OrderRouter.executeOrder, OrderRouter.updateMarkPrice and
 * OrderRouter.settleLpEpoch (both with caller-supplied Pyth data). No call pranks a
 * protocol contract. The suite's helpers are used only to fund the pool and the traders
 * before the attack and to configure the out-of-scope Pyth mock.
 *
 * Sequence: request redemption -> open (pay V, pool books V as revenue) -> settle the
 * next epoch (reconcile prices V into junior principal BEFORE the redemption phase
 * prices the actor's request) -> claim -> close skew-reducing (rebate ~V - fee - carry
 * paid from remaining pool free cash).
 *
 * Assertions (all inside one run, plus an arithmetic control without the actor's trader legs):
 *  A. pool.totalAssets() rises by exactly V at the open (revenue booked immediately);
 *  B. the funded redemption is priced at the post-reconcile principal that includes V
 *     (its value exceeds the no-actor-V counterfactual by ~a*V);
 *  C. the close pays an action rebate ~= V - closeFee - carry from pool free cash;
 *  D. the attacker's combined USDG wealth change across both hats is positive at the
 *     release parameters (vpiFactor 0.01, maxSkewRatio 0.4, executionFeeBps 4), roughly
 *     a*V - 2*fee - carry, funded by the remaining (incumbent) junior LPs.
 */
contract ProofVpiEpochRedemptionTiming is BasePerpTest {
    address internal constant ACTOR = address(0xA11CE);
    address internal constant INCUMBENT_JUNIOR = address(0x1C1000);
    address internal constant INCUMBENT_SENIOR = address(0x5E0001);
    address internal constant SKEW_TRADER = address(0x5E30000);

    uint256 internal constant JUNIOR_EACH = 2_000_000e6; // actor + incumbent junior
    uint256 internal constant SENIOR_TOTAL = 6_000_000e6;
    uint256 internal constant PRICE = 1e8; // 1.00

    // Third-party skew trader notional 3M USDG; the actor adds 500k USDG (both LONG).
    uint256 internal constant SKEW_SIZE = 3e24; // 3e4 lots * 1e20
    uint256 internal constant ACTOR_SIZE = 5e23; // 5e3 lots * 1e20
    uint256 internal constant ACTOR_TRADER_FUNDING = 30_000e6;
    uint256 internal constant ACTOR_ORDER_MARGIN = 5_000e6;

    struct RunResult {
        uint256 vpiPaid; // V booked from the actor's open
        uint256 poolAssetsDeltaAtOpen;
        uint256 fundedShares;
        uint256 redeemedAssets; // full claim of the funded redemption
        uint256 juniorPrincipalAtPricing; // post-reconcile, pre-funding
        uint256 juniorSupplyAtPricing;
        uint256 balanceAfterOpen;
        uint256 balanceAfterClose;
        uint256 wealthBeforeAttack; // actor USDG (wallet + clearinghouse) after funding, before any attack step
        uint256 wealthEnd;
        uint256 poolAssetsBeforeClose;
        uint256 poolAssetsAfterClose;
    }

    // ------------------------------------------------------------------
    // Fixture overrides: release risk parameters, no default LPs
    // ------------------------------------------------------------------

    function _riskParams() internal pure override returns (CfdTyp

The original report as published on Immunefi, by abarbatei. 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 open-side price-impact charge is credited as CashArrived revenue and routed into tranche principal before the payer's own close-time rebate reverses it, with no link between a trader's position and that trader's LP shares.

Impact

A single untrusted actor could extract booked but unwithdrawn trading-revenue yield from remaining junior LPs, netting a positive profit per cycle, though the proof does not model the oracle's adverse-confidence price shift of up to about 2.5 basis points per leg.

What the attacker needed

Large junior LP share; pre-existing third-party skew; junior covenant and free-cash headroom; live, unpaused, fresh-mark regime

The fix

Defer recognition of open-side positive price impact into tranche principal until the paying position is closed or its reversibility window passes, holding it in an escrow bucket excluded from net asset value.

How it was found

  1. Request redemption of junior shares early in epoch E so it matures for E+1.
  2. Open a skew-increasing position, paying a positive price impact that the pool books as revenue.
  3. After the epoch boundary, call the permissionless settlement entrypoint so the redemption is funded at the inflated principal.
  4. Claim the funded redemption.
  5. Close the position skew-reducing to reclaim the payment as a rebate from pool free 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.

A pool lends money to traders and pays its depositors (liquidity providers) from trading fees. When a trader opens a trade that pushes the pool out of balance, they pay a charge that is counted as pool profit straight away, even though closing the trade later refunds it. If the same person is also a big depositor, they can withdraw at the moment the fake profit is counted, keep part of their own refunded charge, and leave the other depositors 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 abarbatei

View all

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