Any account can keep a triggered stop-loss owner trapped in their position by consuming the only exit state, amendLatchedPositionProtectionCloseLimits
A triggered stop-loss protection can be kept permanently un-amendable because a permissionless retry function consumes the only Latched state the owner needs, and the relatch happens inside the same transaction so the window never appears at a block boundary. An unprivileged attacker can therefore keep a victim's position open and its margin locked indefinitely, and can also manufacture the failing close charge by holding opposite-side skew.
- Disclosed after under an hour
#99206 [SC-High] Any account can keep a triggered stop-loss owner trapped in their position by consuming the only exit state, amendLatchedPositionProtectionCloseLimits
Submitted on Nov 12th 2026 at 11:50:47 UTC by @Naveen0x for Audit Competition | Plether
- Report ID: #99206
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Summary
A TP/SL protection that triggers queues a zero-bounty full-position close attempt. If that attempt fails on the owner's stored close limits, the protection relatches and the position stays open with the account trade-locked. The only remedy left to the owner is amendLatchedPositionProtectionCloseLimits, which exists because of the MED-9 fix, and which is owner-only and requires the protection to be Latched with zero pending orders for that account.
retryPositionProtectionClose requires the identical state and is permissionless, free, uncapped in frequency and indifferent to who calls it. Because a failed attempt relatches inside the executing transaction, a single transaction executes the doomed attempt and immediately queues a fresh one. At every transaction boundary the protection is Triggered with a live child, so the owner's amend reverts with ProtectionNotLatched, cancel, replace and cancel-and-close revert with ProtectionNotArmed, and every ordinary commitOrder reverts with ProtectionActive. The owner cannot close, reduce or withdraw the position margin, and the position stays exposed to the market throughout.
The attacker can also manufacture the failure that starts this. Close VPI is part of the action charge, and the skew cap constrains opens only, so a fresh account can hold up to 0.4 × pool depth of opposite-side skew. Closing the victim then moves absolute skew further from zero and pushes the victim's close charge above its own maxActionChargeAssets. In the PoC an attacker holding 25,000 USDG raises the victim's close charge from 4.13 USDG to 53.29 USDG against a 30.25 USDG stored ceiling — a 25 bp ceiling on a close that normally costs 3.4 bp.
At release parameters this holds an owner for 24 hours with 982.48 USDG of position margin frozen, at one griefer transaction per 60-second execution window and with no sequencing advantage whatsoever. A faster variant also defeats an owner who batches executeOrder + amend + retry twice per second, though that one does assume the griefer is sequenced first within each second, which is stated plainly in the limitations.
Affected code
All references are against packages/perps/src at the commit in scope.
PositionProtectionBook.sol:315-328—amendLatchedPositionProtectionCloseLimits. The owner's only post-trigger remedy. Requiresstatus == LatchedandpendingOrderCounts(msg.sender) == 0.PositionProtectionBook.sol:382-406—retryPositionProtectionClose. Resolves the record through_activeProtection, not_ownedActiveProtection, so any address may call it. Gates on the same two conditions and ends in_recordCloseAttempt, which sets the status back toTriggered. No cooldown, no fee, no owner priority.PositionProtectionBook.sol:637-675—handleFailedProtectionAttempt. On a retryable failure with the protected position unchanged it setsLatched(:663-666) inside the transaction that executed the failing attempt.OrderRouter.sol:240-247—executeOrder, and:256-262executeOrderBatch:external payable nonReentrant, with no caller restriction. These are what let an arbitrary account drive the failing attempt to its terminal state on demand.OrderRouter.sol:324-329— the execution path that callshandleFailedProtectionAttempton a terminal, retryable close attempt.OrderRouter.sol:191-230is the equivalent expiry path, which relatches the same way.router/OrderLiquidationBatchLogic.sol:313-315— the commit-time protection lock: anycommitOrderfrom an account with an active protection revertsOrderRouter__ProtectionActive.router/OrderLiquidationBatchLogic.sol:657-680— the retry attempt copies the protection's stored close limits, so a persistent failure reproduces identically on every attempt.CloseAccountingLib.sol:107-109andCfdEnginePlanLib.sol:1041-1044— signed VPI is part of the close action charge.CfdOrderPolicyEvaluatorBase.sol:509-513— the evaluator compares that charge against the storedmaxActionChargeAssetsand fails the order withConstraintViolation(ActionCharge, ...).interfaces/IPositionProtectionActions.sol:32— the documented contract the code does not keep: the owner may change close limits "after a failed attempt relatches, before a fresh retry".interfaces/IPositionProtectionActions.sol:69-72— the retry's own NatSpec, which frames permissionless retry as a safety action that keeps the mandated close alive.
Root cause
1. The owner's only post-trigger exit needs a state that a third party can take first.
amendLatchedPositionProtectionCloseLimits:
StoredProtection storage protection = _ownedActiveProtection(protectionId, msg.sender);
if (protection.status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
revert OrderRouter__ProtectionNotLatched();
}
if (IPositionProtectionRouterHost(ROUTER).pendingOrderCounts(msg.sender) != 0) {
revert OrderRouter__PendingOrdersExist();
}
retryPositionProtectionClose gates on the same two conditions, but resolves the record with _activeProtection, so there is no msg.sender check at all:
StoredProtection storage protection = _activeProtection(protectionId);
if (protection.status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
revert OrderRouter__ProtectionNotLatched();
}
_requireMatchingPosition(protection);
...
if (router.pendingOrderCounts(protection.account) != 0) {
revert OrderRouter__PendingOrdersExist();
}
...
_recordCloseAttempt(protection, linkedOrderId); // status back to Triggered
The two functions are in a race, with no cooldown, rate limit or grace period reserved for the owner, and the owner can only win it by being sequenced first.
2. The relatch happens inside the failing transaction, so the window can be closed atomically. OrderRouter.sol:324-329 calls handleFailedProtectionAttempt while finalizing the terminal attempt, and that sets Latched at PositionProtectionBook.sol:663-666. A caller that executes the attempt therefore observes Latched with zero pending orders inside its own transaction and consumes it immediately. Triggered → Latched → Triggered completes within one transaction, so no block boundary ever shows Latched. This is the whole mechanism: not a race the owner sometimes loses, but a window that never opens.
3. Both halves of the attack are permissionless. executeOrder and executeOrderBatch carry no caller restriction, so the attacker does not need to wait for an honest keeper to process the doomed attempt — it drives the failure itself and consumes the resulting window in the same transaction. If it skips a window the attempt expires, and the permissionless expiry path relatches the protection in the same way, so the attacker must act once per window to hold the lock. That is the cadence the PoC pays for.
4. Every retry reuses the stored limits. The attempt is rebuilt from the protection's retained close limits, so a cause that persists fails identically on attempt 1 and attempt 1,496. Nothing in the retry path escalates, loosens, or gives up.
5. The other exits being shut is intended, and is not the claim. _cancel requires PendingOpen or Armed, cancelPositionProtectionAndCommitClose and replacePositionProtection require Armed, and commitOrder is blocked by ProtectionActive. The project documents all of this: triggering is irreversible by design, and the disposition of MED-30 states explicitly that pending-open, Triggered and Latched records cannot use the atomic manual exit. I am not asking for any of that to change. The point is the consequence: because every other door is intentionally shut, the amend is not merely the recommended remedy, it is the only one — and it is the one that can be starved.
6. The attacker can create the failing condition and hold it. The close action charge includes signed VPI, and the evaluator compares it to the victim's stored maxActionChargeAssets. maxSkewRatio is enforced on opens only, so an attacker may sit at up to 0.4 × depth of opposite skew indefinitely, and closing the victim's position raises the victim's charge. The attacker also triggers the protection itself and collects the trigger bounty, so the opening move is mildly income-positive. The starvation does not depend on this step: whenever a close fails on the owner's own notional or gross-debit ceilings because the price itself moved, the same lock applies with no attacker position at all.
Attack path
Victim: a LONG of 100 lots — 12,000 USDG notional at 1.20, 1,000 USDG margin — with a stop-loss at 1.21 and ordinary finite close limits (notional +2%, gross debit = loss at the stop +1%, action charge 25 bp = 30.25 USDG, explicit fees 10 bp). The SDK requires explicit close limits on every protection, so this is the normal shape of a protected position. With no attacker present the stop close at 1.212 costs 4.13 USDG and executes at the first attempt.
- The basket reaches 1.212 — a 1% move from entry, 0.17% past the stop. In one block a fresh attacker account holding 25,000 USDG deposits, commits a SHORT of 3,350 lots (406,020 USDG notional, inside the skew cap), and calls
triggerPositionProtectionfor the victim, collecting the trigger bounty. The attempt is queued behind the attacker's own open in FIFO. - One griefer transaction — a contract deployed by a fresh EOA with no relationship to the protocol — calls
executeOrderBatch, so the attacker's SHORT executes and the victim's close attempt then fails withConstraintViolation(ActionCharge, 53.29 USDG > 30.25 USDG)and relatches; in the same transaction it callsretryPositionProtectionClose, queueing a fresh attempt. - For each new attempt the griefer repeats
executeOrder(attempt)+retryPositionProtectionClosein one transaction, once per execution window, or at commit + 1 second against an owner actively trying to escape. - At every transaction boundary the victim's exits revert: the amend with
ProtectionNotLatched; cancel, cancel-and-close and replace withProtectionNotArmed;commitOrderwithProtectionActive. Position margin cannot be withdrawn. - The lock lasts as long as the griefer keeps paying gas. If the market keeps moving against the victim the position is liquidated while locked, the protection is marked
Liquidated, and the griefer can collect the liquidation bounty too.
Impact
All figures are measured by the PoC at release parameters.
What is frozen. For the whole lock the victim cannot close, reduce, cancel, replace or amend anything. Its 982.48 USDG of position margin cannot be withdrawn — the clearinghouse rejects it on the free-equity / open-position guard — and stays exposed to price moves. addMargin and withdrawal of free, non-margin settlement still work, which only lets the victim postpone liquidation.
Measured results.
- Owner that does not process its own attempt: locked for 86,711 seconds (over 24 hours) across 1,496 griefer transactions, with every documented exit reverting after every one. After 24 hours the close still fails on the same constraint, 53.30 USDG against the 30.25 USDG ceiling.
- Owner that fights back with a batching contract wallet sending
executeOrder + amend + retrytwice per second: locked for 3,660 seconds, with all 7,320 escape batches reverting — the same-block one onOrderNotQueueHead, the next-block one because the fresh attempt is not yet executable. - Market drifting against the victim at +0.1% per minute: locked 4,061 seconds, then liquidated. The victim ends with 509.08 USDG where an executed stop would have left 1,369.95 USDG — 859.87 USDG of damage, of which 810.72 USDG is attributable to the starvation rather than to the attacker's skew, measured against a same-state control in which the owner is allowed its one amend. The griefer also collects the 6 USDG liquidation bounty.
- Control without an attacker: the stop executes at 1.212 at the first attempt, well inside every stored limit.
- Control with the attacker's skew but no griefer: the first attempt fails, the owner gets its
Latchedwindow, amends, and exits on the retry. This isolates the starvation, rather than the skew, as the cause of the lock.
Attacker cost. The skew position costs about 334 USDG for 24 hours — a one-off 8 bp round-trip fee plus roughly 9 USDG per day of carry. Griefer transactions run about 1.25M gas each, roughly 3 USD per hour at the 58-second cadence, or about 166 USD per hour at the 1-second cadence used against a responsive owner, assuming 0.01 gwei and 3,000 USD per ETH. There is no attacker revenue beyond the trigger bounty and a possible liquidation bounty, which is why I am filing this as griefing.
Attacker requirements and limitations
- No special access. A fresh account with about 25,000 USDG. No privileged role, no oracle manipulation, no protocol impersonation, no keeper status — and per the program's own scope, keepers hold no special privileges and harm caused by any caller acting as a keeper is in scope.
- Victim precondition. The victim's action-charge ceiling must sit below the charge the attacker can induce, roughly the VPI factor times the induced skew ratio plus the execution fee — about 44 bp of close notional in the PoC, 53.29 USDG on 12,120 USDG. Ceilings around 0.5% or higher, and unlimited ceilings, are immune to the skew route.
- An informed owner can beat the cheap cadence. An owner who knows to call the permissionless
executeOrderon its own pending attempt and then amend immediately does recover the window, either in one batched transaction from a contract wallet or in back-to-back transactions. The PoC includes that escape as a passing test rather than hiding it. The 1-second cadence closes that gap only if the griefer is sequenced first in every second, which a local test cannot prove; on an FCFS sequencer this is realistic but it is an assumption, not a result. What keeps the limitation narrow in practice is that the SDK's amend builder is a single call and a UI polling the status always seesTriggered, so an ordinary user has no prepared escape and no reason to suspect one is needed. - Other orders in the queue. When other users' orders sit behind the attempt, honest keepers process it in FIFO order and briefly reopen the window without retrying. The griefer then needs only a cheap retry-only backrun after each relatch, about 0.67M gas, which is again an ordering assumption rather than a guarantee.
- What stays available to the victim. The position stays live;
addMarginand free-settlement withdrawal work. The position margin is locked and the position cannot be reduced or closed.
Relationship to known issues, prior findings and documented limitations
I would rather put all of the overlap in front of triage myself than have it found later. I checked the prior audit report, the repository scan report, the perps SECURITY.md limitations and the upstream fix history before writing this.
MED-9 — this is the fix being shown incomplete, and the starvation is a product of that fix. MED-9 ("Keepers can retry protection closes without the trader's financial limits") reported that internally generated protection closes carried maxed-out financial bounds. Its disposition says the protection now retains the trader's ceilings and copies them into the initial close and every permissionless retry, that only the owner may amend the retained ceilings while the protection is Latched, that keepers cannot relax them, and that tight limits may prevent execution until conditions improve or the owner amends them. Two things follow. First, the failure mode this report exploits — a protection close that fails on the owner's own stored limits and relatches — exists because of that fix; before it, the bounds were maxed and such a close did not fail that way. Second, the remedy the fix introduced, named in its own disposition as the thing that makes tight limits survivable, can be denied indefinitely by an unprivileged third party. That is both halves of the program's carve-out for fixed findings: the fix at this commit is incomplete, and it introduced a new reachable state.
MED-30 (open) — adjacent, and deliberately not what I am claiming. MED-30 concerns an armed protection during frozen markets and was addressed by adding the atomic manual exit for Armed records; its disposition states that pending-open, Triggered and Latched records cannot use that action, and the finding itself notes that ProtectionActive blocks any new manual close while a protection is active. So the fact that a triggered owner has no cancel path and no manual close is documented and acknowledged, and I am not reporting it. My claim is specifically that the one remedy Triggered/Latched records do have is consumable by a third party. MED-30 and MED-9 are complementary dispositions — the manual exit for Armed, the amend for Latched — and this report shows the second one does not hold up.
MED-15 (fixed) — same shape of outcome, unrelated cause. MED-15 described a triggered SHORT protection that could never execute because synthesized closes used targetPrice = 1 against a zero oracle execution price, so every attempt terminalized as Slippage and relatched. Its impact paragraph reads much like mine — the close repeatedly fails, the protection stays latched instead of executing, the user stays exposed. The root cause is entirely different, it was fixed, and its accepted residual limitation is temporary unavailability when no positive valid quote exists. Here the close is perfectly executable the moment the owner amends; what is unavailable is the amend, and it is unavailable because someone is actively taking it.
The repository scan report's trigger-bounty item (low) — keeper inaction, not adversarial pre-emption. That item observes that the trigger bounty is paid on trigger while the queued close and every retry carry zero execution bounty, so a caller can take payment and abandon the flow, leaving the protection Triggered or later Latched, not cancellable through the pre-trigger path, with the position open past its threshold and exposed to further loss or liquidation. Its own evidence cites PositionProtectionBook.sol:297 for the cancellation check, which sits at :408-419 at this commit, and the report contains no reference to the amend entrypoint at all — it was produced against code that had no amend lane. So it describes the absence of an incentive to finish the close, and better keeper incentives fix it. This report describes an active party pre-empting the owner's remedy, where better keeper incentives make matters worse, because every honest execution hands the griefer a fresh relatch to consume.
The excluded SECURITY.md limitations do not cover it, and the attack inverts their detection assumption. The Known Limitations section on the router and keepers — which the program excludes — states that failed protection-attempt cleanup is deliberately unpaid, that each retry creates a fresh zero-bounty close record, that liveness depends on keepers processing the terminal attempt and separately appending a retry, and that operators must alert on a prolonged Latched state without a live child. Every one of those is about keepers not acting. This attack is the opposite: the terminal attempt is always processed, immediately, and a retry is always appended. The acknowledged monitoring signal is a prolonged Latched state without a live child, and under this attack the record is never Latched at a transaction boundary and always has a live child, so the prescribed alert cannot fire for the entire lock. The main protection section separately documents that retry is permissionless and that a recovered price cannot cancel the close mandate; it presents permissionless retry as what keeps the mandated close alive. Used as described here it does the reverse — it guarantees the close never completes while blocking the only action that would let it complete. A mechanism being deliberately permissionless is why this is reachable by anyone; it is not a reason the outcome is intended.
The spec test does not cover it. PositionProtection.t.sol:983-990 checks that one third-party retry made after the owner has amended causes a second amend to revert. It never tests repeated pre-emption of the owner's first amend, which is the whole bug.
No prior public disclosure of this root cause. The MED-9 fix commit 8a2853f80bce067656c1fd0fcf2dadc5892e2aee and its disposition PR #124 are public in the upstream repository. Neither the PR description, its commits, nor its review discussion mentions a retry pre-empting, racing or starving the owner's amend window, and neither proposes a cooldown or an owner grace period. The upstream artifacts disclose the amend's existence, not the defect in it.
Parameters are not the cause. Release parameters only bound how much VPI an attacker can induce, and therefore which victims the skew route reaches. The starvation is a state-machine flaw that holds at any parameter set, and it also reaches victims whose close fails for reasons no attacker created.
Recommended fix
Give the owner an exit that a third party cannot consume. Any one of these is sufficient:
- Let the amend work against a live attempt. Accept the
Triggeredstate when the single pending order is the protection's own close attempt, cancelling that attempt and applying the new limits atomically. This is the smallest change that honours the entrypoint's documented contract, because it stops requiring the owner to win a race.
// PositionProtectionBook.amendLatchedPositionProtectionCloseLimits
PositionProtectionTypes.PositionProtectionStatus status = protection.status;
if (status == PositionProtectionTypes.PositionProtectionStatus.Triggered) {
// the only permitted pending order is this protection's own child
if (protection.linkedOrderId == 0) revert OrderRouter__ProtectionNotLatched();
IPositionProtectionRouterHost(ROUTER).cancelProtectionCloseAttempt(protection.linkedOrderId);
protection.status = PositionProtectionTypes.PositionProtectionStatus.Latched;
} else if (status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
revert OrderRouter__ProtectionNotLatched();
}
if (IPositionProtectionRouterHost(ROUTER).pendingOrderCounts(msg.sender) != 0) {
revert OrderRouter__PendingOrdersExist();
}
_setCloseLimits(protection, limits);
- Reserve the window. Record the relatch timestamp and let only the owner call
retryPositionProtectionClosefor a grace period after each relatch. One execution window is enough, and it costs honest keepers at most one window of liveness per failure — a cost the project already accepts implicitly, since failed-attempt cleanup is unpaid and retry timing is already nobody's obligation.
// retryPositionProtectionClose
if (msg.sender != protection.account && block.timestamp < protection.latchedAt + OWNER_RETRY_GRACE) {
revert OrderRouter__ProtectionOwnerGrace();
}
- Let the owner cancel out of
LatchedorTriggered, cancelling any linked attempt, so the owner can always fall back to an ordinary close. This one changes the documented irreversibility of a trigger, so it is the most invasive of the three and I would not choose it first.
Option 2 is the most robust on its own, because it also protects owners whose close fails for reasons no attacker created and who are not watching the chain at all. Option 1 is the most faithful to the documented behaviour of the function. Together they close both the atomic starvation and the sequencing-race variant, and neither changes anything in normal operation: with no griefer present the owner reaches the same amend it reaches today.
Independently of the chosen fix: because retryPositionProtectionClose is permissionless, free and unlimited in frequency, nothing currently bounds how often one protection can be re-queued. A per-protection cooldown is cheap and closes the whole class of attacks that depend on re-queuing at machine speed.
Proof of concept
Two files. ProtectionAmendStarvation.t.sol holds the attack, the two controls, the honest-flow and responsive-owner variants, the limitation test, and the two unprivileged helper contracts — the griefer, and the batching owner wallet used only to demonstrate the escape route. PocBase.sol is the shared fixture: it reproduces the release deployment on top of the repository's own BasePerpTest, applies the release wrapper values through the ordinary owner timelocks at deployment, and asserts every release value through live getters at the end of each test.
On the program's PoC rules: this runs in the repository's own Foundry suite at the commit in scope, no in-scope contract is modified, and the only mocked components are Pyth and USDG. The fixture inherits the repository's BasePerpTest, which wires the production OrderRouter bytecode through its LegacyOrderRouterHarness test wrapper and uses a two-feed mock basket in place of the six FX feeds; both are the repository's own test infrastructure rather than changes to in-scope code, and the attack uses only the production V3 commit path. Every attack step is a public entrypoint called by a fresh address. No protocol contract is impersonated, there is no vm.store, no vm.mockCall on protocol contracts, and no privileged action after deployment. vm.snapshotState and vm.revertToState are used solely to compute the no-attack and no-griefer controls from the identical pre-attack state inside the same test.
Place both files in a PoC directory under the perps test tree and run them from the repository root at commit a82d4fe:
mkdir -p packages/perps/test/perps/poc
cp PocBase.sol ProtectionAmendStarvation.t.sol packages/perps/test/perps/poc/
FOUNDRY_PROFILE=quick forge test --root packages/perps \
--match-path test/perps/poc/ProtectionAmendStarvationPoc.t.sol -vvv
Expected output, trimmed to the lines that matter:
Ran 7 tests for test/perps/poc/ProtectionAmendStarvation.t.sol:ProtectionAmendStarvationTest
[PASS] test_control_noAttacker_protectionClosesAtTrigger()
controlA action charge assessed (USDG atoms) 4128002
[PASS] test_control_attackerSkew_noGriefer_ownerAmendsAndExits()
controlB failing constraint: ActionCharge actual (USDG atoms) 53285479
controlB failing constraint: ActionCharge limit (USDG atoms) 30250000
[PASS] test_protlock_attackerInduced_lock24h()
owner exits all reverted for >= 1h; cycles so far 64
lock duration (s) 86711
griefer cycles (txs) 1496
victim position margin frozen (USDG atoms) after 24h 982480002
after 24h: ActionCharge actual (USDG atoms) 53301740
[PASS] test_protlock_responsiveOwner_1sCadence_1h()
fast cadence: lock duration (s) 3660
fast cadence: owner escape batches tried, all reverted 7320
[PASS] test_protlock_attackerInduced_driftToLiquidation()
lock duration until liquidation (s) 4061
victim damage vs control (USDG atoms) 859872778
griefer-attributable damage vs control B (USDG atoms) 810715301
[PASS] test_protlock_liveOrderFlow_retryBackrun()
[PASS] test_limitation_batchingOwnerWalletEscapesIfFirst()
Suite result: ok. 7 passed; 0 failed; 0 skipped
One note on measurement: the 24-hour and 1-hour tests pause gas metering after the first metered hour, or the first 240 transactions, because 1,496 transactions of about 1.25M gas exceed Foundry's per-test gas cap. Gas is therefore metered and reported for a representative prefix and extrapolated. The Router only requires gasleft() above a fixed reserve, so paused metering does not change behaviour, and the lock assertions run under both.
Proof of Concept
ProtectionAmendStarvationPoc.t.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
// Self-contained PoC: permissionless retryPositionProtectionClose starves the owner's only
// post-trigger exit, amendLatchedPositionProtectionCloseLimits. Place at
// packages/perps/test/perps/poc/ProtectionAmendStarvationPoc.t.sol and run:
// FOUNDRY_PROFILE=quick forge test --root packages/perps \
// --match-path test/perps/poc/ProtectionAmendStarvationPoc.t.sol -vvv
// Code comments and fixture assertion messages were stripped to fit the 65,536-character
// submission field; each test is described in the report body.
import {BasePerpTest} from "../BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {ICfdEngineAdminHost} from "@plether/perps/interfaces/ICfdEngineAdminHost.sol";
import {ICfdEngineRiskParamsView} from "@plether/perps/interfaces/ICfdEngineRiskParamsView.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.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 "@
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
The owner-only amend and the permissionless retry require the same Latched state, and the retry relatches and re-triggers within one transaction, so a third party can always consume the window first.
Impact
The victim cannot close, reduce, cancel, replace or amend, its position margin stays locked and exposed, and in the PoC a drifting market led to liquidation with about 810 USDG of damage attributable to the starvation; an informed owner batching its own execute and amend can recover the window, and ceilings around 0.5% or higher are immune to the skew route.
What the attacker needed
A fresh account with about 25,000 USDG; victim has a triggered protection with tight close limits; attacker pays gas each execution window
The fix
The owner should be given an exit a third party cannot consume, for example letting the amend cancel the protection's own live attempt and apply new limits atomically, or reserving a grace period after each relatch for the owner only.
How it was found
- The attacker deposits funds and opens a large opposite-side position within the skew cap, then triggers the victim's protection.
- In one transaction the attacker executes the queued close attempt, which fails on the victim's stored action-charge ceiling and relatches, then calls the permissionless retry to queue a fresh attempt.
- The attacker repeats execute plus retry once per execution window, or at a faster cadence against an owner trying to escape.
- At every transaction boundary the victim's amend, cancel, replace and new orders all revert, and the margin cannot be withdrawn.
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 a stop-loss fires, the system tries to close the position but can fail if the cost of closing is above a limit the owner set. The owner is then supposed to be able to raise that limit, but only while the protection sits in a particular waiting state. A retry function anyone can call immediately moves it out of that state again, so the owner never gets a turn and the position stays open and stuck.
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.