Skip to content
Business logic Audit finding Advanced

A skew-reducing open funds its VPI reserve from withdrawable free settlement, so withdrawing after the fill tick cancels the open and binding opens become free options

A skew-reducing open funds its negative-VPI reserve from the trader's withdrawable free settlement, so the trader can withdraw that settlement after committing and make the queued open fail its initial-margin check. Because the fill price is fixed at the first tick after commitment, the trader can decide after seeing later prices whether to let the open fill, turning a binding open into a free option paid for by LPs.

tinnohofficial Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99813 [SC-Low] A skew-reducing open funds its VPI reserve from withdrawable free settlement, so withdrawing after the fill tick cancels the open and binding opens become free options

Submitted on Nov 15th 2026 at 11:33:16 UTC by @tinnohofficial for Audit Competition | Plether

Description

Brief/Intro

A fresh open that reduces skew earns a VPI rebate and must back a larger negative-VPI reserve. The planner funds that reserve from the account's free settlement first and only otherwise from the new position's pledge, then checks initial margin on what is left. If the committed margin sits inside a band up to one execution fee wide, the open fills when the trader keeps free settlement and fails terminally (PlannerRejected) when the trader withdraws it before execution. withdrawMargin is allowed while the open is pending. The fill price is fixed at the first tick after commitment, so the trader decides whether the queued open fills after that price, and several seconds of later prices, are public. No signed bound and no existing position are needed, and a cancelled open costs at most the 0.20 USDG open bounty.

Vulnerability Details

  1. Reserve sourcing depends on live free settlement. _planOpenReserveFunding takes the reserve increase from resultingFreeSettlementAssets and charges the rest to the new pledge (CfdEnginePlanLib.sol L561-L579):
Solidity
uint256 vpiReserveFromFreeAssets = vpiReserveIncreaseAssets < openCostPlan.resultingFreeSettlementAssets
    ? vpiReserveIncreaseAssets
    : openCostPlan.resultingFreeSettlementAssets;
delta.vpiRebateReserveFromPledgeAssets = vpiReserveIncreaseAssets - vpiReserveFromFreeAssets; // <-@ depends on live free settlement
...
delta.positionMarginAfterOpen =
    openCostPlan.resultingPositionMarginAssets - delta.vpiRebateReserveFromPledgeAssets - reserveIncreaseAssets;

The reserve target is the gross rebate, while only the rebate net of the fee is credited. With no free settlement, the fee-sized difference comes out of the pledge.

  1. Initial margin is then checked on that pledge (CfdEnginePlanLib.sol L429-L436). INSUFFICIENT_INITIAL_MARGIN is a user-invalid terminal execution failure (CfdEnginePlanLib.sol L113-L130; OrderRouterExecutionSidecar.sol L564-L576, L834-L852). Committed margin and the bounty stay reserved; free settlement does not.

  2. Withdrawals ignore a pending open. For a flat account, validateWithdraw enforces only a positive settlement floor (CfdEngineSettlementSidecar.sol L255-L272; MarginClearinghouse.sol L416-L478; OrderLiquidationBatchLogic.sol L302-L311). The spec states that guard's purpose: "This protection prevents owner withdrawals from manufacturing a settlement-minimum failure" (ACCOUNTING_SPEC.md L930). Here a withdrawal manufactures an initial-margin failure instead, and that failure does not depend on the market.

  3. The fill is the first unique tick after commitTime (PletherOracle.sol L610-L622), however late the order executes.

Attack:

  • Commit the skew-reducing open with margin inside the band (computable from the commit-time price), and withdraw free settlement in the same transaction.
  • Left alone, any execution fails with PlannerRejected, and the keeper takes the bounty.
  • If the move after the fill tick favours the open, deposit and execute it yourself: it fills at the old tick.

The switch does not need a withdrawal after commitment. A later own open can do the same job: its committed margin locks the remaining free settlement, and it then fails on its own bound at the cost of its bounty. A deposit, or a depositFor from another address the trader controls, switches the open back on. In the PoC, the open as committed fails with PlannerRejected; after depositFor(5,000 USDG) from another address it fills.

On the public Arbitrum Sepolia v2.0.0 deployment, the reference keeper executed all 278 live orders 0-8 s after the fill tick's publish second. It polls every 5 s when idle, so a commit just after a poll leaves 7-8 s to decide.

The pre-audit reported this impact as SC-M4 ("Risk Free Option in 60Sec Oracle Window", fixed): the losing queued open was cancelled after commit by a withdrawal (an LP withdrawal causing SOLVENCY_EXCEEDED -> refund). The fix removed that refund path, but the fix at a82d4fef is incomplete. A withdrawal after commit still cancels the losing open, now through the trader's own withdrawMargin and the planner's sourcing of the VPI reserve from live free settlement.

Contradicted text: SECURITY.md L658-L659 ("binding order semantics and the lack of a user cancellation path prevent traders from turning queued intents into free options").

Impact Details

Low. The stated security property does not hold, and LPs pay the option value.

PoC: Foundry, unmodified contracts, public entry points only, release parameters (fee 4 bp, VPI 1%, IM 0.2%, MM 0.1%, open bounty 1 bp in [0.01, 0.20] USDG, 60 s window, 10M Junior + 40M Senior, six release feeds). Price path: the real Pyth six-feed basket of 14 Oct 2026 12:10-12:49 UTC (US data at 12:30, -23 bp in 18 s), interpolated per second. An honest account holds 2.9M USDG of exposure, so the trader's 961k USDG open reduces skew. The control makes the same trades with ordinary binding orders committed at the decision time.

One open (12:29:50 UTC, 961k LONG, committed margin 3,077.99 USDG):

  • free settlement kept: Executed (pledge 2,116.12, reserve 462.60);
  • free settlement withdrawn: Failed / PlannerRejected, cost 0.20 USDG.
Run Exercised Trader vs control LPs vs control
SHORT-heavy book (the LONG open reduces skew), commits timed after the keeper's poll, 39 min, decide at 7 s, exercise above the 8.5 bp round trip 1 (12:30 release, edge 8.93 bp) +955.63 USDG (+300.02 net vs -655.61) -981.82
Trader opens anyway, keeps every favourable fill, cancels the rest; measured keeper delays, 25 min, decide at 3 s 68 +2,095.82 -2,120.67
Same, commits timed after the keeper poll, 39 min, decide at 6 s 103 +4,630.34 -4,632.19
  • A trader that opens anyway enters 0.32-0.47 bp better per open, and LPs lose the same amount.
  • No view on direction is needed. An unused attempt costs at most one bounty, and nothing when the trader executes its own order.
  • Attempts can be repeated every few seconds whenever the book is skewed.

Recommendation

Fund an open's negative-VPI reserve only from value reserved at commitment. Applying the settlement-floor withdrawal predicate to pending opens is not enough on its own, because another own order or a depositFor can move free settlement without a withdrawal.

References

Proof of Concept

Proof of Concept

The full Foundry tests and their run output are in this gist: https://gist.github.com/tinnohofficial/6429b22cb04ae17c7645ce0140d81c24

  • WithdrawFillSwitch.t.sol: 12 tests
  • WithdrawFillSwitchNoWithdrawal.t.sol: 13 tests
  • *.output.txt: the output of each suite

The tests use the repository's own harness (BasePerpTest), its Pyth mock and the six release basket feeds. They call public entry points only (commitOrder, executeOrder, updateMarkPrice, withdrawMargin, depositFor), and no in-scope contract is modified.

How to run

  1. Check out immunefi-team/audit-comp-plether at a82d4fefb02768e5b3bddcc97dee371eee24fea8 and install the dependencies as in the repository README.
  2. Copy both test files into packages/perps/test/poc/.
  3. From the repository root, run:
forge test --root packages/perps --match-path test/poc/WithdrawFillSwitch.t.sol -vv
forge test --root packages/perps --match-path test/poc/WithdrawFillSwitchNoWithdrawal.t.sol -vv

The suites pass 12/12 and 13/13, and repeated runs give identical output.

Step by step: one open, two outcomes (test_Switch_OneOpenTwoOutcomes)

  1. Setup: release parameters, a 10M Junior and 40M Senior pool, and an honest account holding a 2.9M USDG SHORT, so a LONG open reduces skew and earns a VPI rebate.
  2. Commit: at 12:29:50 UTC on the real 14 Oct 2026 path, a flat trader commits a 961k USDG LONG with 3,077.99 USDG of committed margin. That is inside the band where the reserve sourcing decides the initial-margin check.
  3. Prices: the fill tick is 0.961877. Seven seconds later the price is 0.961526, so the LONG is 3.64 bp in profit at the fill price.
  4. Control (free settlement kept): the open ends Executed, with a position margin of 2,116.12 USDG and a negative-VPI reserve of 462.60 USDG. The log line is "free settlement kept: status / reason 2 1".
  5. Attack branch (free settlement withdrawn at decision time): the trader calls withdrawMargin before execution, and the same open ends Failed / PlannerRejected, because the planner now takes the reserve from the pledge and initial margin fails. The log lines are "free settlement withdrawn: status / reason 3 7" and "trader cost of the cancelled open (USDG atoms) 200000", i.e. 0.20 USDG.

Step by step: no withdrawal (test_Switch_NoWithdrawal_LaterOrderLocksFreeSettlement)

  1. The trader commits the open, then commits a second own order whose committed margin locks the remaining free settlement. Its execution-notional bound guarantees it fails.
  2. As committed, the open fails PlannerRejected ("as committed: open status / reason 3 7").
  3. After depositFor(5,000 USDG) from another address the trader controls, the open fills ("after depositFor: open status / reason 2 1"), and the locking order fails on its bound ("locking order status / reason 3 8").

Real-path results (14 Oct 2026 Pyth basket; trader vs control, LPs vs control, USDG)

  • SHORT-heavy book, commits timed after the keeper poll, exercised only above the round-trip cost, decide at 7 s: +955.63 / -981.82. The trader ends +300.02 USDG net, while the control loses 655.61.
  • Opens anyway, measured keeper delays, decide at 3 s: +2,095.82 / -2,120.67
  • Opens anyway, commits timed after the keeper poll, decide at 6 s: +4,630.34 / -4,632.19

Each *_Control test makes the same trades with ordinary binding orders committed at the decision time.

The original report as published on Immunefi, by tinnohofficial. 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 planner sources an open's negative-VPI reserve from live free settlement rather than from value locked at commitment, so a later withdrawal changes the initial-margin outcome of an already-committed open.

Impact

The stated binding-order property does not hold and LPs could bear the option value, though the report rates this Low and the trader's gain is bounded by the open bounty and keeper timing.

What the attacker needed

A flat account with free settlement; commit timed after the keeper poll; no signed bound or existing position needed

The fix

An open's negative-VPI reserve should be funded only from value reserved at commitment, since applying the settlement-floor withdrawal check to pending opens is not sufficient on its own.

How it was found

  1. Set up release parameters, liquidity pools and an honest account holding a large SHORT so a LONG open reduces skew.
  2. Commit a LONG open with committed margin inside the band where reserve sourcing decides the initial-margin check.
  3. Observe the fill tick and later prices; if the move favours the open, deposit and execute it, otherwise withdraw free settlement.
  4. Withdrawing free settlement before execution makes the same open fail with PlannerRejected at a cost of the open bounty.

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 system lets them take back some of the money backing it before the order executes. If prices then move against them, the order fails and they lose only a small fee; if prices move in their favour, they top up and the order fills at the old price. That is like being allowed to cancel a bet after seeing the result, and the losses land on the pool that backs the trades.

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 tinnohofficial

View all

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