Skip to content
Business logic Audit finding Advanced

Third party can force a stop-loss latch and pre-empt the owner's standalone amendment via permissionless retry, blocking the exit

A stop-loss or take-profit close that fails on the trader's retained close ceilings becomes Latched, and the only owner remedy requires the protection to be Latched with an empty order queue. Because retryPositionProtectionClose is permissionless, a third party can settle each failing attempt and immediately re-queue it in the same transaction, so the owner's standalone amendment always reverts and the position stays open and unwithdrawable.

tinnohofficial Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#97967 [SC-High] Third party can force a stop-loss latch and pre-empt the owner's standalone amendment via permissionless retry, blocking the exit

Submitted on Nov 4th 2026 at 05:36:34 UTC by @tinnohofficial for Audit Competition | Plether

Description

Brief/Intro

A take-profit/stop-loss close that fails on one of the trader's retained financial ceilings (the ceilings added by the MED-9 fix) becomes Latched. From then on the owner has one lever, amendLatchedPositionProtectionCloseLimits, and it requires the protection to be Latched and the owner's order queue to be empty. Cancel, cancel-and-close, replace and every ordinary close are rejected for a triggered or latched protection.

retryPositionProtectionClose is permissionless and immediately re-queues the same failing close, which moves the protection back to Triggered and fills the queue. A third party can therefore settle each failing attempt and re-queue the next one in the same transaction, so no transaction boundary ever shows Latched with an empty queue. An owner who uses the remedy as the project ships it, a standalone amendment (the SDK's single-call action), cannot land it while the third party keeps re-queueing. The position stays open and its margin stays unwithdrawable until the market comes back inside the ceiling, the position is liquidated, or the owner escapes with a custom batched transaction from its trading account (see Limits).

The third party does not need a price gap. If it holds an opposite position when the stop fires, the trader's protective close becomes skew-increasing and its VPI charge breaks an ordinary max-loss ceiling at the stop price itself. Without the third party the same stop fills.

Evidence (every test was run twice with identical logged values):

  • Deployed Arbitrum Sepolia v2.0.0 contracts (local fork at block 325,698,463; nine runtime code hashes asserted against the release manifest; only the out-of-scope Pyth and the ArbSys precompile are replaced). Without the third party the stop fills at +0.5% with a loss of 5,804.44 USDG. After a gap to +0.6%, the third party re-queues every attempt, the owner's amend, cancel, cancel-and-close and ordinary close revert after every cycle, and the trader is liquidated at +2.70% with a loss of 30,000.40 USDG. A second test holds the lock for 61 minutes with oracle-free calls only, defeats the owner's two-transaction remedy, and shows that the owner's amendment works at once when the third party stops.
  • Forced latch, no gap (repository harness, release risk parameters): a 2,000,000 USDG opposite position held when a 1,000,000 USDG stop fires turns a 5,152 USDG close (inside a 5,500 ceiling) into a 6,159 USDG failure. The trader loses 29,650.38 USDG instead of 5,802.40. The third party's cost, excluding the price PnL of its own position, is 1,626.20 USDG.
  • Duration: against an owner limited to the standalone actions, the lock is held for 48 h across a weekend (2,833 cycles) with 49,350.02 USDG of the trader's balance unwithdrawable. The control withdraws everything 2 s after the same latch.
  • Gas: about 1.03M gas per oracle-free cycle, about $0.047 at the Arbitrum One base fee and ETH price of block 520,933,248 (2026-11-03), i.e. about $2.8 per hour of lock.

Severity: Medium. Impacts: "Griefing" (no profit for the attacker; the trader loses the exit its stop-loss was meant to provide, 22-24k USDG of extra loss in each liquidation example, for under $1 of gas or about 1.6k USDG of fees in the forced variant) and "Temporary freezing of funds for at least 1 hour" (61 minutes demonstrated on the deployed contracts) for owners who use the documented remedy.

Why this is not intended behaviour

  • The documented protection lifecycle depends on an observable Latched window, and the MED-9 remedy is designed for it.
    • Keeper flow, CANONICAL_ENTRYPOINTS.md L281-L285: "Keeper infrastructure should process the terminal attempt, observe Latched, confirm the exact position and retry preconditions, and submit the separate retry transaction". SECURITY.md L1356-L1359: "Liveness depends on keepers processing the terminal attempt and separately appending a retry".
    • The project's own test of the remedy encodes that window. test_ProtectionCloseLimits_OnlyOwnerCanAmendLatchedLimitsForNextRetry: a keeper expires the attempt, the protection relatches ("first attempt must relatch before amendment"), the owner amends, and only then a third party (CAROL) retries with the amended limits, which execute. The attack removes the step between settlement and retry.
    • MED-9 fix comment: "Only the owner may amend the retained ceilings while protection is Latched; keepers cannot relax them. … Tight limits may prevent execution until conditions improve or the owner amends them." CANONICAL_ENTRYPOINTS.md L145-L148: the owner may amend "when the account has no pending Router order. This changes the limits used for a future retry".
    • The project's client SDK ships the remedy as one standalone owner action: "buildAmendLatchedProtectionCloseLimitsAction lets the owner change the close limits of a Latched protection before a permissionless retry" (perps-aa-client README L204-L205). That single call reverts whenever a third party has re-queued first.
    • The official sponsored path cannot bundle the amendment with the settlement step: the sponsorship gateway must reject "keeper/admin methods" (perps-aa SECURITY.md L34-L37), and executeOrder, expireOrder and retryPositionProtectionClose are the documented Keepers entrypoints (CANONICAL_ENTRYPOINTS.md L245-L258).
  • The keeper runbook tells workers not to do what the attacker does, and the contract does not enforce it. DEPLOYMENT.md L419-L421: "A conservative worker retries expiry failures only after confirming the account has no pending orders … Investigate planner, constraint, or other persistent failures before retrying; do not continuously queue the same failing attempt." This is operational guidance, not an on-chain rule. Keepers are untrusted under the program rules, and any contract-permitted keeper behaviour is in scope.
  • The trigger of the lock is the ceiling working as designed. In the forced variant the ceiling correctly refuses a close whose VPI was inflated by another account's position, which is the protection MED-9 promised. The defect is that once a ceiling has done its job, a third party can keep the owner from ever adjusting it or leaving.
  • No document gives a third party a veto over the amendment, and this report does not contest the documented properties. The fix below keeps all of them: an irreversible trigger (SECURITY.md L547-L552), permissionless retry, and "users cannot manually cancel queued intents" (SECURITY.md L1345). Neither "Known Limitations" nor "Router and keeper limitations" lists a third-party denial of the amendment.
  • No privileged action releases the state. PositionProtectionBook has no privileged function, and retry stays available while the Router is paused, degraded or frozen (the project test test_RetryPositionProtectionClose_RemainsAvailableAcrossSafetyModes). The alert on "prolonged Latched state without a live child" (SECURITY.md L1359) does not fire, because under attack the record is Triggered with a live child almost all the time.

Vulnerability Details

Code at commit a82d4fef:

  1. The amendment needs Latched and an empty queue. amendLatchedPositionProtectionCloseLimits reverts:
    • OrderRouter__ProtectionNotLatched unless the status is Latched (L320-L322);
    • OrderRouter__PendingOrdersExist unless pendingOrderCounts(owner) == 0 (L323-L325).
  2. Retry is permissionless. retryPositionProtectionClose has no caller check.
  3. A failed or expired attempt only relatches.
  4. Every other exit is closed once triggered.
    • cancelPositionProtectionAndCommitClose requires Armed (PositionProtectionBook.sol L345-L348).
    • cancelPositionProtection (_cancel, L412-L419) and replacePositionProtection (L270-L277) require PendingOpen/Armed.
    • Every ordinary commit reverts with OrderRouter__ProtectionActive (OrderLiquidationBatchLogic.sol L313-L315).
    • Size or side can change only through orders or liquidation, so the owner cannot make the position stop "matching" and release the lock (_positionMatches, L1010-L1015).
    • addMargin, deposits and free-settlement withdrawals still work. None of them changes the outcome.
  5. Ceilings are checked only at execution, never when the trigger or a retry queues the attempt.
    • Protection attempts are appended through executePositionProtectionTriggerItem → _recordCommittedOrder (OrderRouter.sol L440-L472; OrderCommitHandler.sol L43-L60). That skips the commitment path that bounds ordinary orders (_createPendingOrder → recordCommitment, OrderCommitHandler.sol L21-L36).
    • The first evaluation is _enforceBounds at execution (CfdOrderPolicyEvaluatorBase.sol L499-L508). A trigger whose attempt is certain to fail is therefore accepted, and the protection can no longer be cancelled or replaced.
    • Generated closes have no price limit (targetPrice = CAP_PRICE for a LONG, 1 for a SHORT; OrderLiquidationBatchLogic.sol L667). The four retained ceilings are the only bound a trader can put on a protective fill, and the SDK requires all four to be set explicitly ("Builders reject missing or invalid close limits; they do not insert unlimited defaults", perps-aa-client README L213-L214).

A helper contract can call executeOrder (or expireOrder) and then retryPositionProtectionClose in one transaction, so the protection goes Triggered → Latched → Triggered atomically. If someone else settles an attempt (an honest keeper, or the owner), a plain retry closes the window again before a separately submitted amendment lands.

How the latch is reached

Any of the following makes the first attempt fail on a retained ceiling. The first three are tested.

  • Forced by a third party, no gap.
    • Close VPI depends on the skew at execution: C(S) = k·S²/(2D), k = 1%.
    • An account that holds an opposite position of size A when the stop fires raises the trader's close charge by k·N·A/D (N = trader notional, D = pool depth).
    • With a 20M pool (as in the PoC), N = 1M and a ceiling of the loss at the stop plus 10%, the 348 USDG of headroom disappears at A ≈ 0.7M. The test uses 2M.
    • The attacker's own VPI round trip is about zero (its open and close move the skew symmetrically). Its cost is the 4 bp execution fee each way plus carry.
  • A gap through the stop with a max-loss (gross-debit) ceiling.
  • A gap with only the mandatory notional ceiling. For a LONG USD stop-loss, the close notional lots × price grows with the same move that triggers it, so a ceiling at the stop notional plus 10 bp latches on any gap beyond 10 bp, with no max-loss guard configured. A SHORT USD take-profit on a favourable gap follows the same code path (not separately tested).
  • The weekend. While the oracle is frozen, every attempt also carries the 0.50% frozen-close spread, counted in explicit fees (CfdOrderPolicyEvaluatorBase.sol L416) and in the collected action charge. A maxExplicitFeesAssets ceiling below the execution fee plus the 50 bp spread fails every frozen attempt; gross-debit and action-charge ceilings fail when the spread pushes those totals over their limits. Notional ceilings are unaffected, and the full-close waiver of an uncollectible spread can change the gross debit.

Attack

  1. A trader has an armed stop-loss with a reasonable ceiling, for example maximum gross debit = loss at the stop + 10%.

  2. The ceiling is made to bind, in either of two ways:

    • the third party opens the opposite side while the price nears the stop, and the stop fires at its own price;
    • the price gaps through the stop.

    Any keeper triggers the stop.

  3. The third party settles the first attempt itself (permissionless, zero bounty) and re-queues it in the same transaction. It repeats this for every attempt: on the live route with the attempt's qualifying post-commit tick, or oracle-free after the 60 s deadline. It back-runs any settlement made by someone else with a plain retry.

  4. The owner's standalone amend, cancel, replace and close all revert. The position stays open until the market returns inside the original ceiling (then any executor fills the queued attempt), the position is liquidated, or the owner escapes as described under Limits.

Impact Details

Test (release risk parameters; positions opened via the production V3 commit/execute path) Result
Deployed v2.0.0 fork, control: stop fires at +0.5%, no third party fills inside the 5,500 ceiling (gross debit 5,002), loss 5,804.44 USDG
Deployed v2.0.0 fork, gap to +0.6%, third party settles and re-queues every attempt owner locked out after every cycle, liquidated at +2.70%, loss 30,000.40 USDG (+24,195.96)
Deployed v2.0.0 fork, oracle-free cycles only lock held 3,660 s; the owner's settle-then-amend is defeated by a back-run retry; once the third party stops, the owner amends and exits
Local, control: stop at 1.005, no third party gross debit 5,152 of 5,500, fills; loss 5,802.40 USDG
Local, forced latch: third party holds a 2M SHORT, stop fires at exactly 1.005 gross debit 6,159 > 5,500, latched, locked, liquidated; loss 29,650.38 USDG (+23,847.98); third-party cost excluding its own price PnL 1,626.20 USDG
Local, notional ceiling only (stop notional + 10 bp), gap to 1.0065 control with unlimited ceiling: loss 7,303.00; attack: latched, locked, liquidated, loss 29,650.38 (+22,347.38)
Local, weekend, control: Friday 13:00 New York latch, no third party owner amends, exits and withdraws all 93,197.20 USDG within 2 s
Local, weekend, attack (owner limited to standalone actions) free settlement (49,999.60) withdrawable; 49,350.02 USDG stays unwithdrawable for 172,814 s (48 h), 2,598 of the 2,833 cycles while the oracle is closed (stored mark constant); 9 owner exit-and-withdraw attempts all revert

Cost. Inputs read at Arbitrum One block 520,933,248 (2026-11-03 17:03 UTC; read-only commands in the PoC section): base fee 0.020 gwei, ArbGasInfo L1 calldata price 0 wei per byte, Chainlink ETH/USD $2,296.44. Gas was measured cold (--isolate) on the deployed bytecode.

  • Oracle-free cycle (expire + retry): 1,026,424 gas, about $0.047. One cycle every 61 s is about $2.8 per hour of lock and $67 per day.
  • Plain back-run retry: 784,851 gas, about $0.036.
  • Live-route cycle, needed only against owners who batch (see Limits): about 2.3-2.7M gas, $0.11-0.12. This adds the retry to the gas of real keeper executeOrder transactions on the deployed release: 2,436 bytes of calldata with a six-feed Hermes payload and 1.51-1.89M gas in the eight cited in the PoC section.
  • The forced latch additionally costs the third party about 8 bp of its position in fees, plus carry (1,626 USDG in the test).
  • If honest keepers execute each failing attempt promptly, every execution relatches the protection and the third party must back-run it with a retry. The cost then follows the keepers' cadence, about $26 per hour at one execution every 5 s, which is still small against the funds held.

Severity: Medium. Impact "Griefing (no profit motive for an attacker, but damage to the users)": a trader who set an ordinary ceiling loses its protective exit and, in each liquidation example, 22-24k USDG beyond the loss its stop would have realised; the third party spends under $1 of gas (gap variants) or about 1.6k USDG of fees (forced variant) and gains nothing. Impact "Temporary freezing of funds for at least 1 hour": the position-backed margin cannot be withdrawn while the lock lasts (61 minutes demonstrated on the deployed contracts; 48 h against an owner limited to the standalone actions). No trusted role is involved.

Limits (stated so they need not be discovered)

  • A retained ceiling must bind. With all four ceilings unlimited, an attempt simply fills. The SDK makes the trader choose all four explicitly, and the forced variant makes an ordinary max-loss ceiling bind without any market move.
  • An owner who can send one multi-call transaction can escape; owners on the documented path cannot. The batch is: settle the live attempt, amend, retry, all from the trading account (for example SimpleAccount.executeBatch sent and paid by the owner directly, or an EIP-7702 account).
    • Live market: a freshly re-queued attempt cannot be settled in its own commit block (Pending, SameBlock), so such an owner must land its batch in a later block before the third party's next settle-and-requeue. Against the cheap oracle-free variant the attempt is executable for about 59 s, so this owner escapes at once. Against a third party that settles each attempt at its first executable block, the owner must win one ordering race; the third party must win all of them.
    • Oracle frozen: execution has no same-block delay, so such an owner can settle the live attempt, amend, retry and execute the amended close in one transaction whatever the ordering. The 48 h weekend result therefore holds only against an owner limited to the standalone actions.
    • The documented remedy, a standalone amendment sent through the sponsored SDK flow, cannot do either: it reverts while Triggered, and the sponsor rejects keeper methods in a batch. Separate back-to-back transactions can still be back-run.
  • The lock ends when the market comes back inside the ceiling (any executor then fills the queued attempt), at liquidation, or when the owner escapes as above. Adding margin only postpones liquidation.
  • The weekend run needs the latch before the Friday close and margin above the 3% FAD requirement. Positions below that are liquidated in the FAD window, which ends the lock with a liquidation loss. While frozen, the stored mark is constant but pending carry still accrues.

Why this is not a known issue

  • MED-9. The amendment is the MED-9 remediation ("… or the owner amends them"). This report shows that any third party can deny it to an owner using it as documented, and that a third party can even cause the failing condition. The fix is incomplete and introduces a new lock.
  • AI-scan Low "Protection trigger bounty is paid before a zero-bounty close is executed".
    • That item is about nobody being paid to execute the close. There, the owner can execute or expire its own attempt and then amend, so the remedy is reachable.
    • Here, a third party actively re-queues, which defeats the owner's own actions.
    • The scan quotes pre-amendment code (triggerBountyUsdc, executionBountyUsdc != 0). The amendment was added later, in the protection-fix commit eadc5c58 (2026-10-23) that carries the MED-9/MED-30 fixes.
    • Root cause and fix differ.
  • MED-30. Its remedy, cancelPositionProtectionAndCommitClose, is Armed-only by design ("Pending-open, Triggered and Latched records cannot use this action"). That is why the amendment is the only lever once a protection has triggered.
  • Other items. MED-15, LOW-50, MED-8, MED-17, MED-23, MED-28 and LOW-73 have different root causes.
    • The VPI items in the AI scan concern value extraction through depth or skew changes. This report does not claim VPI extraction: the skew change is only a way to make a ceiling bind before the lock.
    • SECURITY.md documents unpaid failed-attempt cleanup, keeper-appended retries and Latched alerting, but not a third-party denial of the amendment.

Recommendation

  • Let the owner amend while Triggered or Latched, regardless of queued attempts. The live attempt keeps its pinned bounds, and the next attempt uses the new ceilings.
    • The trigger stays irreversible and retry stays permissionless.
  • Alternatively, either of these:
    • an owner-only action that turns a Triggered/Latched protection into an ordinary owner-bounded close replacing the live attempt;
    • restricting retry to the owner for a short window after a ConstraintViolation or PlannerRejected failure.
  • As a complement, evaluate the retained ceilings at trigger time while the trigger mark is known (for example lots × triggerMark > maxExecutionNotionalAssets), and keep a doomed protection Armed so the owner keeps replace and cancel-and-close.

References

  • PositionProtectionBook.sol:
  • OrderRouter.sol: L292-L344 terminal settlement and relatch; L440-L472 attempt queueing without commitment checks.
  • router/OrderLiquidationBatchLogic.sol: L186-L211 retry host; L313-L315 trade lock; L657-L680 retained ceilings.
  • CfdOrderPolicyEvaluatorBase.sol: L410-L416 gross debit and explicit fees; L499-L508 bound order.
  • OrderRouterExecutionSidecar.sol L447-L452 (same-block and post-commit boundaries, live market only); PletherOracle.sol L610-L614 (unique historical parse).
  • Documentation:
    • DEPLOYMENT.md L391 and L419-L421;
    • CANONICAL_ENTRYPOINTS.md L142-L148, L245-L258 and L281-L285;
    • SECURITY.md L547-L552, L647-L648, L1345 and L1356-L1359;
    • perps-aa-client README L204-L205 and L213-L214; perps-aa SECURITY.md L34-L37.
  • Project tests: PositionProtection.t.sol L954-L1000 (owner amends in the Latched window before a third-party retry) and L1611 (retry available across safety modes).
  • Cecuro MED-9 and MED-30 comments (audits/plether-ai-audit-report-2026-10-26.pdf).
  • Deployment: deployments/releases/2026-10-28-perps-arbitrum-sepolia-v2.0.0 (manifest runtime code hashes asserted in the fork test).

Proof of Concept

Proof of Concept

Two Foundry test files, run against unmodified packages/perps/src at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8. The third party is a plain contract that only calls permissionless entrypoints.

Setup

  1. git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether.git && cd audit-comp-plether && git checkout a82d4fefb02768e5b3bddcc97dee371eee24fea8 && git submodule update --init --recursive
  2. Save file 1 as packages/perps/test/poc/LatchedProtectionRetryLockout.t.sol and file 2 as packages/perps/test/poc/DeployedReleaseRetryLockout.t.sol.

File 1: repository harness (BasePerpTest; release risk parameters from DEPLOYMENT.md; 20M USDG pool; 2-feed mock basket; positions opened through the production V3 commitOrder(OrderRequest) and permissionless executeOrder).

`for

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 amendment requires an observable Latched state with an empty order queue, while the permissionless retry can atomically move the protection back to Triggered and refill the queue, so no transaction boundary ever exposes the state the owner needs.

Impact

A trader can lose the protective exit its stop-loss was meant to provide, suffering roughly 22-24k USDG of extra loss in the liquidation examples, and position-backed margin can stay unwithdrawable for at least an hour (61 minutes demonstrated, 48 hours against an owner limited to standalone actions); an owner able to send one multi-call transaction can escape.

What the attacker needed

A retained close ceiling that binds; a stop-loss or take-profit armed; attacker pays gas per cycle; owner limited to standalone actions

The fix

The amendment should be allowed to land even while a retry has re-queued the protection, for example by letting the owner amend during Triggered or by not requiring an empty queue, so a third party cannot veto the remedy.

How it was found

  1. A trader arms a stop-loss with a retained close ceiling, for example maximum gross debit equal to the loss at the stop plus 10%.
  2. The ceiling is made to bind, either by a third party holding an opposite position when the stop fires or by a price gap through the stop.
  3. A keeper triggers the stop, and the first close attempt fails on the ceiling and latches.
  4. The third party settles the failed attempt and re-queues it in the same transaction, repeating for every attempt.
  5. The owner's standalone amend, cancel, replace and ordinary close all revert, so the position stays open until the market returns inside the ceiling, liquidation, or a custom batched escape.

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 sets a stop-loss with limits on how much the closing trade may cost. If the market moves so the close would exceed those limits, the protection gets stuck in a 'latched' state, and the owner is supposed to be able to raise the limits. Here anyone can keep re-queueing the same failing close, which keeps the protection out of that latched state, so the owner's fix never lands and the position cannot be closed or its margin withdrawn.

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.