Skip to content
Business logic Audit finding Advanced

Committed open orders can be cancelled at no cost after their fill price is known, because any caller can shrink HousePool depth through OrderRouter.settleLpEpoch (incomplete fix of SC-M4 component 3)

Committed open orders are re-planned at execution against live HousePool depth, and any caller can shrink that depth by funding a matured LP redemption through the permissionless settleLpEpoch. A trader can therefore cancel a losing committed order for free after its fill price is known, turning queued intents into free options that the protocol promises not to offer.

abarbatei Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#98039 [SC-Low] Committed open orders can be cancelled at no cost after their fill price is known, because any caller can shrink HousePool depth through OrderRouter.settleLpEpoch (incomplete fix of SC-M4 component 3)

Submitted on Nov 4th 2026 at 15:05:27 UTC by @abarbatei for Audit Competition | Plether

Description

Brief/Intro

At commit a82d4fefb02768e5b3bddcc97dee371eee24fea8 an open order is re-planned at execution time against the live HousePool.totalAssets(), and the planner's skew cap maxSkewAssets = netDepth * maxSkewRatio reserves nothing for orders that are committed but not yet executed. OrderRouter.settleLpEpoch is permissionless and funds any matured LP redemption out of the pool, so any caller can lower totalAssets() by the matured amount at a moment of its choosing. A SKEW_TOO_HIGH or SOLVENCY_EXCEEDED result at execution is classified ProtocolStateInvalidated and terminalizes the order as PlannerRejected with the full margin released and, for a self-executing account, the bounty refunded. The consequence is that a trader who has committed an order sized near the cap, and who has (or who merely finds) a matured, not yet funded LP redemption, can wait until the order's fill tick and the ticks after it are public, then decide whether that order fills or is cancelled for free. SECURITY.md promises LPs that "binding order semantics and the lack of a user cancellation path prevent traders from turning queued intents into free options"; the fix shipped for the pre-audit finding SC-M4 (plether-core PR 24) changed only the oracle pricing rule and left this third component of SC-M4 intact. The value of the option is bounded by how far the basket moves inside the few seconds that honest keepers leave between commit and execution, so the pool does not lose value in the ordinary case; it fails to deliver the binding-order guarantee it promises, and in a fast market it pays a stale fill against LPs with no offsetting losing leg. The attached Foundry proof executes the whole cycle through public entrypoints and measures the economics at the release risk parameters.

Vulnerability Details

1. Execution re-plans an open against live pool depth

When an order is executed, the sidecar builds the engine request from the current pool state, not from anything frozen at commit time:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L950-L954

Solidity
        request.executionPrice = oracleResult.executionPrice;
        request.neutralMarkPrice = oracleResult.neutralMarkPrice;
        request.poolDepthAssets = IHousePool(engine_.pool()).totalAssets();
        request.oraclePublishTime = oracleResult.publishTime;

The pre-oracle item at L933 samples the same value, and _callEngine forwards it to CfdEngine.processOrderTyped(order, executionPrice, poolDepthAssets, publishTime):

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L597-L600

Solidity
        bytes memory engineCall = abi.encodeCall(
            ICfdEngineCore.processOrderTyped,
            (context.order, request.executionPrice, request.poolDepthAssets, request.oraclePublishTime)
        );

2. The skew cap scales with that depth and reserves nothing for committed orders

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/CfdEnginePlanLib.sol#L448-L479

Solidity
        uint256 netDepthAssets =
            PositionRiskAccountingLib.computeNetPoolDepthAssets(snap.poolAssets, snap.totalTraderClaimBalanceAssets);
        if (netDepthAssets == 0) {
            delta.revertCode = CfdEnginePlanTypes.OpenRevertCode.SOLVENCY_EXCEEDED;
            return;
        }
        ...
        uint256 maxSkewAssets = Math.mulDiv(netDepthAssets, snap.riskParams.maxSkewRatio, CfdMath.WAD);
        if (
            inputs.postSkewAssets > maxSkewAssets
                && (inputs.postSkewAssets >= inputs.preSkewAssets || orderSideIsPostOpenHeavy)
        ) {
            delta.revertCode = CfdEnginePlanTypes.OpenRevertCode.SKEW_TOO_HIGH;
            return;
        }

SKEW_TOO_HIGH is also CommitTimeRejectable (L79-L94), so a leg that is over the cap at commit is refused at commit. A leg that is under the cap at commit passes and is only re-checked at execution, against whatever depth exists then.

3. The two depth-dependent codes are terminal at execution and release the margin

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/CfdEnginePlanLib.sol#L119-L126

Solidity
        if (
            code == CfdEnginePlanTypes.OpenRevertCode.DEGRADED_MODE
                || code == CfdEnginePlanTypes.OpenRevertCode.SKEW_TOO_HIGH
                || code == CfdEnginePlanTypes.OpenRevertCode.SOLVENCY_EXCEEDED
                || code == CfdEnginePlanTypes.OpenRevertCode.NUMERIC_DOMAIN_EXCEEDED
        ) {
            return CfdEnginePlanTypes.ExecutionFailurePolicyCategory.ProtocolStateInvalidated;
        }

The sidecar accepts that shape as a terminal planner rejection:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L846-L853

Solidity
            if (
                knownCode && category == uint256(expectedCategory)
                    && expectedCategory != CfdEnginePlanTypes.ExecutionFailurePolicyCategory.None
            ) {
                classification.terminal = true;
                classification.plannerFailure = true;
                classification.plannerIsClose = isClose == 1;
                classification.reason = OrderV3Types.TerminalReason.PlannerRejected;

and the router releases the whole margin reservation and returns the bounty to the account when the account executed its own order:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouter.sol#L301-L312

Solidity
        _onlySelfCall();
        (, CfdTypes.Order memory order) = _pendingOrder(orderId);
        clearinghouse.releaseOrderReservationForTerminalCleanup(orderId);
        settlement =
            _settleTerminalBounty(order, success, reason, bountyRecipient, accountingPrice, accountingPublishTime);
        if (success) {
            emit OrderExecuted(orderId, executionPrice);
        }
        _deleteOrder(
            orderId, success ? IOrderRouterAccounting.OrderStatus.Executed : IOrderRouterAccounting.OrderStatus.Failed
        );

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouter.sol#L333-L341

Solidity
        if (bountyAssets != 0) {
            settlement.bountyRecipient = bountyRecipient;
            settlement.bountyDisposition = OrderV3Types.BountyDisposition.Paid;
            if (bountyRecipient == order.account) {
                clearinghouse.releaseReservedExecutionBountyToSource(order.account, bountyAssets);
            } else {
                engine.creditBounty(
                    order.account, bountyRecipient, bountyAssets, accountingPrice, accountingPublishTime
                );
            }

If an honest keeper executes the cancelled leg instead, the account loses only the open bounty, 1 bp capped to the range 0.01 to 0.20 USDG (OrderRouterBase.sol L72-L74).

4. Any caller can shrink the depth on demand

OrderRouter.settleLpEpoch is external payable (OrderRouter.sol L479-L484) and delegates to the keeper sidecar:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/router/OrderLiquidationBatchLogic.sol#L549-L565

Solidity
    function settleLpEpoch(
        bytes[] calldata pythUpdateData
    ) external payable {
        _requireDelegateCall();

        IOrderLiquidationBatchHost host = IOrderLiquidationBatchHost(address(this));
        IPletherOracle oracle = host.pletherOracle();
        uint256 pythFee = oracle.getUpdateFee(pythUpdateData);
        if (msg.value < pythFee) {
            revert IPletherOracle.PletherOracle__InsufficientFee(msg.value, pythFee);
        }

        IPletherOracle.PriceSnapshot memory snapshot =
            oracle.updatePrice{value: pythFee}(msg.sender, pythUpdateData, IPletherOracle.PriceMode.PoolReconcile);
        host.engine().updateMarkPrice(snapshot.markPrice, snapshot.publishTime);

        address pool = address(oracle.housePool());

HousePool.settleLpEpoch (HousePool.sol L797-L821) only requires that the caller be the router with a current-epoch mark when positions are open, which the router path provides. _settleLpEpoch funds every matured redemption and decrements the accounting basis:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L885-L888

Solidity
            if (juniorPhase.fundedAssets > 0) {
                juniorPrincipal -= juniorPhase.fundedAssets;
                accountedAssets -= juniorPhase.fundedAssets;
            }

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L1007

Solidity
            settlementToken.safeTransfer(vaultAddress, fundedAssets);

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L426-L429

Solidity
    function totalAssets() public view returns (uint256) {
        uint256 raw = settlementToken.balanceOf(address(this));
        return raw < accountedAssets ? raw : accountedAssets;
    }

The withdrawal floor reserves only the live book (maxLiability + traderClaims + supplemental, HousePoolAccountingLib.sol L46-L55); a committed, unexecuted open reserves nothing, so the drain is not blocked by pending orders.

5. The fresh mark installed by the drain does not prevent executing the older fill tick

settleLpEpoch installs a newer mark. The later execution of the committed order still uses its own historical fill tick (the unique first Pyth tick after commitTime, PletherOracle.sol L610-L613), and both mark-update paths ignore a non-newer time:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L1053-L1061

Solidity
    function _updateEngineMark(
        IOrderRouterExecutionHost host,
        OracleResult memory result
    ) private {
        ICfdEngineCore engine_ = ICfdEngineCore(host.engine());
        if (result.publishTime > engine_.lastMarkTime()) {
            engine_.updateMarkPrice(result.neutralMarkPrice, result.publishTime);
        }
    }

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngine.sol#L1146-L1154

Solidity
    function settlementApplyCarryAndMark(
        uint256 newMarkPrice,
        uint64 newMarkTime
    ) external onlySettlementSidecar {
        if (newMarkTime <= lastMarkTime) {
            return;
        }
        _applyCarryAndMark(newMarkPrice, newMarkTime);
    }

So the sequence "execute the winning leg at tick T, drain, execute the losing leg at the same tick T" is valid: the losing leg is priced at T and then rejected on depth.

6. Why this is an incomplete fix rather than a known issue

The pre-audit finding SC-M4 ("Risk Free Option in 60Sec Oracle Window") described three components: the 60 s keeper tick choice, the dual-order tick selection, and "Component 3: The LP Order Cancellation. When a price move is too large, the attacker can trigger a full margin refund on the losing order by manipulating the vault depth ... Executing the losing order then triggers SOLVENCY_EXCEEDED due to reduced vault depth. This propagates as ProtocolStateInvalidated, granting a full margin return." The team's response was "Fixed in Plether-Fi/plether-core#24". That PR replaced the keeper's tick choice with the unique-first-tick rule (components 1 and 2). Nothing in sections 1 to 5 above was changed: execution still re-plans on live depth, the cap still has no reservation for committed orders, the depth codes are still terminal with a full refund, and settleLpEpoch is still permissionless. Component 3 is live at the pinned commit, and SECURITY.md still states the guarantee it breaks:

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/SECURITY.md#L658-L659

Text
- binding order semantics and the lack of a user cancellation path prevent traders from turning queued intents into
  free options,

7. Attack sequence (as executed by the proof)

One untrusted actor controls three ordinary accounts: an LP account holding a junior stake R, trader A and trader B. Release risk parameters are used (maxSkewRatio 0.4, executionFeeBps 4, vpiFactor 0.01, initMarginBps 20).

  1. Epoch E: the LP account calls TrancheVault.requestRedeem for its whole junior stake (R = 400,000 USDG on a 10M USDG pool). The request matures at the start of epoch E+1 and is funded by whichever settleLpEpoch runs first after that.
  2. Epoch E+1, before the honest LP keeper has settled: trader A commits a LONG for 100,000 USDG and trader B commits a SHORT for 3,980,800 USDG, 20,000 USDG under the commit-time cap 0.4 * totalAssets(). Both pass the commit-time preview. Their fill price is the first Pyth tick after the commit block, T.
  3. T is published and the following ticks show the basket moving. In the proof the mark falls 50 bp after T (a LONG profits when the mark falls, CfdTypes.Side); the LONG is the winner and the SHORT the loser.
  4. The actor executes leg A itself at T (OrderRouter.executeOrder with the Pyth payload for T). It fills.
  5. The LP account calls OrderRouter.settleLpEpoch with a fresh Pyth payload. Its matured redemption is funded out of the pool: totalAssets() falls from 10,002,000 to 9,602,070 USDG and the execution-time cap falls to 3,840,828 USDG.
  6. The actor executes leg B at the same tick T. Post-open skew would be 3,880,800 USDG, above the new cap: SKEW_TOO_HIGH, classified ProtocolStateInvalidated, terminal PlannerRejected. The 30,000 USDG margin is released and the bounty is refunded to trader B, which withdraws its entire 40,000 USDG deposit.
  7. The actor closes leg A at the moved price and withdraws; the LP account claims its redemption.

If the move had gone the other way the actor would simply have let both legs execute (or executed none of its own and let the keeper do it) and kept the large SHORT as the winner; the small LONG is a cheap hedge. The cancellation branch is the one that needs the lever, and it is the one the proof exercises. A single order sized near the cap gives the same option without the second leg.

8. Preconditions and timing (stated honestly)

  • A matured, not yet funded LP redemption of size R with 0.4 * R larger than the headroom of the target leg under the cap. The actor can create it one epoch ahead with its own stake, or use any third party's matured request (settlement is permissionless and funds all matured requests).
  • The cycle must complete before the honest LP keeper settles the epoch (the reference keeper polls every 15 s; on the Arbitrum Sepolia v2.0.0 deployment the four settlements that had matured work landed 7, 10, 10 and 15 s after the hourly boundary), so the lever exists in the first seconds after an hourly boundary.
  • The drain and the execution of the losing leg must land before an honest order keeper executes that leg at T. The reference keeper polls every second; on the Sepolia deployment all 105 orders ever committed executed 3 to 9 s after commit (median 6 s, p95 8 s, none failed, none expired). The contract itself allows up to executionWindowSeconds (60 s by default, 1 h admin ceiling), and an order nobody executes expires with margin and bounty refunded anyway.
  • The option is therefore worth the basket move between T and the actor's decision inside that few-second window, net of the fees on the kept leg.

Impact Details

Selected impact: "Contract fails to deliver promised returns, but doesn't lose value" (Low).

Mapping, stated plainly. SECURITY.md promises LPs that committed orders are binding and that traders cannot turn queued intents into free options; this report shows that at the pinned commit any trader can cancel a committed open at no cost after the fill tick and the ticks after it are public, which means the pool is quoting a free option it does not price. In the ordinary regime the pool does not lose value: the option is only worth the basket move inside the few seconds that honest keepers leave between commit and execution, and that move is usually below the fee floor. When the move is large (a news jump landing in that window), the pool pays a stale fill to the kept leg with no offsetting losing leg, and the loss is borne by the junior tranche. No theft of principal is claimed and no LP-side timing capture is relied on; the actor's own LP leg is booked at its NAV value and is a cost in the proof.

Measured cycle economics from the proof (6-decimal USDG, release parameters, kept leg 100,000 USDG, actor junior share 10% of a 4M junior tranche, 10M pool):

Quantity Staged 50 bp move (proof run, passes) Break-even and reference figures
Cancelled leg (SHORT 3,980,800 USDG, margin 30,000) Terminal PlannerRejected / SKEW_TOO_HIGH; margin and bounty returned; trader B withdraws its full 40,000 USDG Cost of cancellation: 0 USDG when self-executed; at most 0.20 USDG (open bounty cap) if an honest keeper terminalizes it
Pool depth, before and after the actor's settleLpEpoch 10,002,000 to 9,602,070 USDG Cap moves from 4,000,800 to 3,840,828 USDG
Gross gain on the kept leg (LONG 100,000 USDG) 500 USDG Fee floor: open 4 bp plus close 4 bp = 8 bp of notional (79 USDG here)
Kept leg net after fees +420 USDG A 9 bp run of the same proof gives +10 USDG on the kept leg
Actor's LP leg (redemption minus the stake that funded it) 65 USDG below stake (its 10% share of the pool's mark-to-market loss plus settlement fee) At 9 bp: 24 USDG below stake
Actor net across the three accounts +354 USDG At 9 bp: 14 USDG below zero; break-even is about 10.5 bp at these sizes, up to about 13 bp when the live basket confidence sits at the accepted ceiling (two adverse shifts of up to 2.5 bp)
Incumbent junior principal change 659 USDG below start (actor's own R removed from the comparison) Zero or positive when the move is below the fee floor (the pool keeps the fees)
Window in which the move must occur Staged by the fixture (fill at T, mark at T minus 50 bp before the actor acts) Honest keeper latency: 3 to 9 s commit-to-execution over all 105 Sepolia v2.0.0 orders (median 6 s); 60 s contract default when no keeper executes; first roughly 15 s of an hourly epoch for the LP lever

Per-cycle gain on the kept notional X is X * (move - 8 bp) minus the actor's share of the pool's mark-to-market on its own LP stake, and zero when the actor cancels. The expected value over a distribution of moves is positive for any distribution with a tail, but the magnitude inside a 3 to 9 s window on a six-currency basket is small, and a cycle needs a fresh matured redemption (or a third party's) at the top of an hour. That is why Low is proposed: the promised binding-order property is not delivered, the pool quotes an unpriced free option, and the capital at risk for LPs is the tail of the move distribution inside the keeper latency, not principal in the ordinary case. The 50 bp move in the proof is staged to make the mechanism and the arithmetic visible; it is not a claim about how often such a move occurs in that window.

Mitigation

Any one of the following closes the lever; the first is the smallest change.

  1. Freeze the depth used for the skew and solvency checks at commit time, or evaluate them at execution against max(depthAtCommit, depthNow), so that a depth reduction after commit cannot flip a committed open into a terminal rejection. The commit-time preview already runs the same planner, so the commit-time totalAssets() can be stored on the order.
  2. Treat SKEW_TOO_HIGH and SOLVENCY_EXCEEDED at execution as retryable within the execution window instead of terminal, so an order that was valid at commit is not cancelled by a transient depth change; the margin is still refunded on expiry.
  3. Reserve committed-but-unexecuted open notional in HousePool's withdrawal floor (supplementalReservedAssets) or in computeNetPoolDepthAssets, so that redemption funding cannot reduce the depth below what pending orders were validated against.
  4. Independently of the above, update SECURITY.md so the binding-order claim is conditioned on execution-time depth, until the fix ships.

References

Proof of Concept

Proof of Concept

The proof is a Foundry test that extends the repository's own BasePerpTest fixture. Every attack step is a transaction from one of the actor's three ordinary accounts to a public entrypoint: OrderRouter.commitOrder, OrderRouter.executeOrder (the actor is its own permissionless keeper), OrderRouter.settleLpEpoch, OrderRouter.updateMarkPrice, TrancheVault.requestRedeem / claimRedeem, MarginClearinghouse.withdrawMargin. No protocol contract is pranked. Suite helpers are used only to fund the pool and the traders before the attack and to stage the out-of-scope Pyth mock (setAllUniquePrices fixes the unique post-commit tick the oracle will find).

Setup:

  1. Check out commit a82d4fefb02768e5b3bddcc97dee371eee24fea8 of https://github.com/immunefi-team/audit-comp-plether and install the Foundry dependencies as the repository README describes.
  2. Create the directory packages/perps/test/poc/lp-depth-drain-cancels-order/ and save the code below as packages/perps/test/poc/lp-depth-drain-cancels-order/ProofLpRedemptionDrainCancelsLosingLeg.t.sol.
  3. From packages/perps, run:
Bash
FOUNDRY_TEST=test/poc/lp-depth-drain-cancels-order forge test --match-path 'test/poc/lp-depth-drain-cancels-order/*.t.sol' -vv

(forge test --match-contract ProofLpRedemptionDrainCancelsLosingLeg -vv from packages/perps runs the same test with the default test root.)

Expected result: the test passes. Assertion A shows the losing leg terminating with Failed / PlannerRejected and no position, after its fill price was fixed; assertion B shows trader B's full deposit back in its wallet; assertion C shows the kept leg realizing the move minus the two execution fees; assertion D shows the actor's combined wealth up and the incumbent junior principal down. Setting MOVE_BPS to 9 makes the final net-profit assertion fail (actor net 14 USDG below zero) while assertions A and B still hold, which is the break-even check described in Impact Details.

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 {CfdEnginePlanTypes} from "@plether/perps/CfdEnginePlanTypes.sol";
import {IAsyncTrancheVault} from "@plether/perps/interfaces/IAsyncTrancheVault.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

/**
 * End-to-end proof. One untrusted actor controls three ordinary accounts:
 *   LP_ACCOUNT   junior liquidity provider holding a matured, not yet funded redemption request,
 *   TRADER_A     commits the small leg of an opposite-side pair (LONG),
 *   TRADER_B     commits the large leg of the pair (SHORT), sized just under the depth-scaled skew cap.
 *
 * Every attack step is a transaction sent by one of those accounts to a public entrypoint:
 * OrderRouter.commitOrder (production V3 bounded request), OrderRouter.executeOrder with caller-supplied
 * Pyth data (the actor is its own permissionless keeper), OrderRouter.settleLpEpoch with caller-supplied
 * Pyth data, OrderRouter.updateMarkPrice, TrancheVault.requestRedeem / claimRedeem and
 * MarginClearinghouse.withdrawMargin. No call pranks a protocol contract. Suite helpers are used only to fund
 * the pool and the traders before the attack and to stage the out-of-scope Pyth mock.
 *
 * Sequence:
 *  1. both legs are committed in one block at t1; their fill price is the first Pyth tick after t1 (T);
 *  2. the basket mark falls to P after T (staged on the Pyth mock); a LONG profits when the mark
 *     falls, so the LONG leg is the winner and the SHORT leg the loser;
 *  3. the actor executes the LONG leg at T (fills, mark moves to T);
 *  4. the actor calls settleLpEpoch with a fresh tick at P: its matured redemption is funded out of the
 *     pool, so HousePool.totalAssets() drops by the funded amount;
 *  5. the actor executes the SHORT leg at the same fill tick T: the planner re-validates it against the
 *     drained depth, returns SKEW_TOO_HIGH, the router classifies it ProtocolStateInvalidated ->
 *     terminal PlannerRejected, releases the full margin and refunds the bounty to the self-executor;
 *  6. the actor closes the LONG leg at P and withdraws; TRADER_B withdraws its full deposit.
 *
 * Assertions: the SHORT leg terminates with PlannerRejected / SKEW_TOO_HIGH after its fill price was
 * known; TRADER_B recovers its entire deposit; the kept LONG leg realizes P - T minus fees; the actor's
 * combined wealth across the three accounts rises, and the pool (the remaining LPs) pays for it.
 */
contract ProofLpRedemptionDrainCancelsLosingLeg is BasePerpTest {
    address internal constant LP_ACCOUNT = address(0xA11CE);
    address internal constant TRADER_A = address(0xA11CE0A);
    address internal constant TRADER_B = address(0xA11CE0B);
    address internal constant INCUMBENT_JUNIOR = address(0x1C1000);
    address internal constant INCUMBENT_SENIOR = address(0x5E0001);

    uint256 internal constant INCUMBENT_JUNIOR_ASSETS = 3_600_000e6;
    uint256 internal constant ACTOR_JUNIOR_ASSETS = 400_000e6; // the dr

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 execution-time skew and solvency checks use live pool depth with no reservation for committed-but-unexecuted orders, and the depth-dependent rejection codes are terminal with a full margin refund.

Impact

The pool fails to deliver the promised binding-order guarantee and quotes an unpriced free option; in the ordinary case it does not lose value, but in a fast market it could pay a stale fill against LPs, with the loss borne by the junior tranche.

What the attacker needed

A matured, unfunded LP redemption; action within seconds of an hourly boundary; orders committed near the skew cap; execution before honest keepers act

The fix

The depth used for skew and solvency checks should be frozen at commit time or evaluated against the greater of commit-time and current depth, so a later depth reduction cannot terminalise a committed order.

How it was found

  1. An LP account requests redemption of its whole junior stake, maturing at the start of the next epoch.
  2. Before the honest LP keeper settles, trader A commits a long and trader B commits a short just under the commit-time cap.
  3. After the fill tick is published and the basket moves, the actor executes the winning leg at that tick.
  4. The LP account calls settleLpEpoch, funding the matured redemption and lowering totalAssets and the execution-time cap.
  5. The actor executes the losing leg at the same tick; it is rejected as SKEW_TOO_HIGH, terminalised as PlannerRejected, and the margin and bounty are refunded.
  6. The actor closes the winning leg at the moved price and withdraws.

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 trader places an order that is meant to be binding, but the contract re-checks the order against the pool's current size when it executes. Anyone can make the pool look smaller by triggering a payout to a waiting investor, and that makes the order fail its size check. The order is then cancelled and the trader's deposit is returned, so the trader can walk away from a bet that has already gone against them.

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.