Skip to content
Business logic Audit finding Advanced

Permissionless protection retry loop can block EOA position exits for over 24 hours

The owner-only amendment path for a protected position only accepts a Latched state with no pending order, while the retry entrypoint is permissionless and moves the protection back to Triggered with a live child. A third party can repeatedly expire and retry the child so an EOA owner cannot amend an explicit-fee ceiling that the frozen-market spread makes insufficient, blocking the position exit for over 24 hours.

xRakan Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99304 [SC-High] Permissionless protection retry loop can block EOA position exits for over 24 hours

Submitted on Nov 13th 2026 at 03:00:27 UTC by @xRakan for Audit Competition | Plether

Description

Summary

A protected position can become unrecoverable to its EOA owner when an otherwise executable normal-market close limit becomes insufficient in the oracle-frozen regime. In a matched public-Router test, a 5 USDG explicit-fee ceiling permits the same protection close in Friday Afternoon Deleveraging (FAD) mode, but the documented 50-basis-point frozen spread raises assessed explicit fees to 54.054 USDG. A permissionless caller can then atomically retry the failed close and maintain a live child for more than 24 hours, preventing the owner from reaching the MED-9 amendment path. The test leaves 1,985.500999 USDG of position margin inaccessible. A separate 20-basis-point reversal test measured a 20.990997 USDG worse settlement balance; that is not the loss measured in the 24-hour lock test.

Root Cause

The owner amendment entrypoint authenticates the account owner, but only accepts Latched protections with no pending Router orders. The source implementation is linked at the exact lines below.

PositionProtectionBook.sol, amendment gate, lines 315–328

Solidity
function amendLatchedPositionProtectionCloseLimits(
    uint64 protectionId,
    PositionProtectionTypes.CloseFinancialLimits calldata limits
) external nonReentrant {
    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();
    }
    _setCloseLimits(protection, limits);
    _emitCloseLimitsUpdated(protection);
}

The owner check is enforced by _ownedActiveProtection: the supplied account must match the protection's recorded account. The amendment then rejects Triggered, and also rejects any Latched state with a pending order. PositionProtectionBook.sol, owner check, lines 983–991

Retry is permissionless. It requires the protection to be Latched and the account queue to be empty, then asks the Router to create a fresh child and records that child as the current attempt. It does not check that the caller owns the protected account.

PositionProtectionBook.sol, retry entrypoint, lines 382–405

Solidity
function retryPositionProtectionClose(
    uint64 protectionId
) external nonReentrant returns (uint64 linkedOrderId) {
    StoredProtection storage protection = _activeProtection(protectionId);
    if (protection.status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
        revert OrderRouter__ProtectionNotLatched();
    }
    _requireMatchingPosition(protection);

    IPositionProtectionRouterHost router = IPositionProtectionRouterHost(ROUTER);
    if (router.pendingOrderCounts(protection.account) != 0) {
        revert OrderRouter__PendingOrdersExist();
    }

    if (protection.linkedOrderId == 0 || _attemptProtectionIds[protection.linkedOrderId] != 0) {
        revert PositionProtectionBook__InvalidLinkedOrder();
    }
    uint64 expectedOrderId = router.nextCommitId();
    linkedOrderId = IPositionProtectionCloseAttemptHost(ROUTER)
        .commitProtectionCloseAttempt(protectionId, protection.account, protection.side, protection.size);
    if (linkedOrderId != expectedOrderId) {
        revert PositionProtectionBook__InvalidHostResponse();
    }
    _recordCloseAttempt(protection, linkedOrderId);
}

The generated close copies the stored four financial ceilings into the child order. The child keeps that committed policy even if the owner later changes stored limits; an amendment affects a future retry. Each retry receives the Router's maximum execution window, which is 60 seconds in this source configuration.

OrderLiquidationBatchLogic.sol, retry bounds, lines 655–680
OrderExecutionOrchestrator.sol, default window, lines 10–14

The second reproduction isolates a legitimate later mode change. The release close execution fee is 4 basis points and the frozen-close spread is 50 basis points. CloseAccountingLib assesses both on the close notional; CfdOrderPolicyEvaluatorBase adds them into explicitFeesAssets and compares that value with the order's stored maxExplicitFeesAssets. The normal and Friday Afternoon Deleveraging (FAD) control pays 4.004 USDG within its 5 USDG limit. The same-size protected position is then attempted in Frozen mode: the receipt records 54.054 USDG against that same 5 USDG limit and fails specifically with ConstraintKind.ExplicitFees. The user's ceiling is enforced as designed; the defect is that the owner cannot amend it once the protection is returned to Latched and permissionlessly retried.

CloseAccountingLib.sol, execution fee and frozen spread formula, lines 120–126
CfdOrderPolicyEvaluatorBase.sol, close fee aggregation, lines 409–416
CfdOrderPolicyEvaluatorBase.sol, financial-bound enforcement, lines 495–515
SECURITY.md, documented frozen-close spread, lines 1332–1335

Retry changes the protection status to Triggered while the child is live. If that attempt fails or expires while the exact protected position remains, the failure handler returns the protection to Latched. The loop is therefore:

Latched → permissionless retry → Triggered → permissionless expiry → Latched

PositionProtectionBook.sol, child registration, lines 565–578
PositionProtectionBook.sol, failure relatch, lines 637–668
OrderRouter.sol, public expiry entrypoint, lines 191–196
OrderRouterExecutionSidecar.sol, expiry settlement, lines 371–394

Expiry is permitted only after the stored deadline; the lifecycle book sets that deadline from the committed execution window. OrderLifecycleBook.sol, deadline creation, lines 287–295

The protection is an account-level trade lock. The ordinary V3 commit path rejects a new order when an active protection exists. Triggered and Latched protections cannot use the normal cancellation path, and cancelPositionProtectionAndCommitClose accepts only Armed. OrderLiquidationBatchLogic.sol, active-protection guard, lines 302–315 PositionProtectionBook.sol, cancellation state guard, lines 408–428 PositionProtectionBook.sol, cancel-and-close state guard, lines 341–359

The resulting impact is limited to funds committed to the open position and the owner's ability to exit. The owner can still withdraw free settlement assets. The withdrawal path rejects an amount that would leave less than required locked margin. MarginClearinghouse.sol, withdrawal entrypoints, lines 403–417 MarginClearinghouse.sol, locked-margin checks, lines 441–477

Preconditions and Attack Path

Preconditions

  • The victim has a live position with an active protection whose trigger has already been recorded.
  • The owner configures a finite but executable normal-market or Friday Afternoon Deleveraging (FAD) explicit-fee ceiling; in the supplemental test the ceiling is 5 USDG and the live/FAD close fee is 4.004 USDG.
  • A child remains pending across the Friday close-only transition and reaches the frozen-market boundary. The release frozen-close spread is 50 basis points.
  • The attacker can call the permissionless Router and protection entrypoints and fund repeated transactions; no owner, oracle-publisher, or keeper privilege is required.
  • The owner is a standard EOA without an account-level batching mechanism. The attack wins only when the third-party expiry/retry transaction is sequenced before an owner recovery transaction at an available Latched boundary.
  • A successful close within the committed bounds, a wallet that atomically expires and amends, or an owner transaction sequenced first can end the lock. The PoC does not establish transaction priority or continuous real-world inclusion.

Calls

  1. The owner opens matched public-V3 SHORT positions and gives both protections the same limits: maximum execution notional 10,020 USDG, maximum explicit fees 5 USDG, and permissive values for the other two bounds.
  2. Before the frozen-market boundary, the control's protected close executes in FAD mode with 4.004 USDG of explicit execution fees and no frozen spread. This proves the stored limit is initially executable.
  3. The victim's protected child is committed shortly before the Friday market-freeze boundary. A third party waits until the child expires at that boundary, then calls expireOrder and retryPositionProtectionClose in one transaction.
  4. The third party executes the replacement child in Frozen mode and immediately retries in the same transaction after the close fails. The authenticated receipt reports 54.054 USDG of explicit fees against the unchanged 5 USDG ceiling; the 50.05 USDG increase is the frozen spread on the 10,010 USDG notional.
  5. The protection ends the transaction in Triggered with a live child. The EOA cannot amend, cancel, or commit an ordinary close. The attacker then repeats permissionless expiry/retry cycles for 86,437 seconds during the frozen weekend window.
  6. An owner-authorized batching account can instead atomically expire the child and amend the stored limits; the existing contract-wallet PoC proves this escape. It does not create an Ethereum Improvement Proposal 7702 (EIP-7702) authorization transaction.

The local test chooses the transaction order and advances block time; it proves the state transition and accounting, not sequencer preference, public-mempool priority, or guaranteed attacker inclusion. A standard EOA cannot atomically expire the child and amend through a helper because the amendment checks msg.sender against the protected account. The attack relies on the permissionless expiry/retry transaction being sequenced before owner recovery each time a live child expires. A smart account can batch recovery and a successful keeper close can end the lock.

Impact Details

Measurement Reproduced result
Matched explicit-fee ceiling 5.000000 USDG
Pre-freeze Friday Afternoon Deleveraging (FAD) control fee 4.004000 USDG; close executes with zero frozen spread
Frozen-mode assessed explicit fees 54.054000 USDG; execution fails against the 5.000000 USDG ceiling
Frozen-spread component 50.050000 USDG (50 basis points on 10,010 USDG notional)
Continuous EOA lock in frozen market 86,437 seconds (24 hours and 37 seconds)
Permissionless expiry/retry cycles 1,417
Position margin left locked 1,985.500999 USDG
EVM call gas per expiry/retry pair 1,086,812 gas, excluding transaction intrinsic gas and Layer 1 data fees
Separate matched reversal balance difference 20.990997 USDG after a 20-basis-point price reversal

The frozen-spread test uses two matched 10,000-unit SHORT positions with identical stored limits. Just before the frozen-market boundary, BOB's protected close executes in FAD mode: the explicit fee is 4.004000 USDG, the frozen spread is zero, and the 5 USDG ceiling is satisfied. ALICE's protected close is committed shortly before the same boundary and is left pending until expiry. A permissionless bot expires and retries it atomically at the boundary. In Frozen mode the same close assessment is 54.054000 USDG, comprising the 4.004000 USDG normal execution fee and 50.050000 USDG frozen spread. The terminal receipt identifies ExplicitFees, with actual 54.054000 USDG and limit 5.000000 USDG. The bot retries in the same transaction after this failure and then expires/retries each child for 86,437 seconds while the market remains frozen.

This is the primary realistic limit scenario: the owner-supplied fee ceiling permits an actual close in the control before the regime changes. The original 10,005 USDG versus 10,010 USDG notional test remains a separate deterministic demonstration of the lock mechanism; its ceiling is already insufficient at trigger time and it is not presented as evidence for the new valid-at-trigger condition.

The frozen-spread 24-hour test leaves 1,985.500999 USDG in the open position's margin bucket. A separate withdrawal test verifies that free settlement can still be withdrawn, a request for the position-margin amount reverts without token transfer, and the released settlement can be withdrawn after owner amendment and a normal close. The impact is the blocked exit and inaccessible position margin, not a freeze of every settlement asset in the account or a direct theft.

The 20.990997 USDG matched balance difference comes from a separate scenario: identical 10,000-unit positions exit on opposite sides of a 20-basis-point price reversal after one owner amends and the other does not. It is not the financial loss measured during the frozen 24-hour run, is not pure price profit and loss, and is not attacker profit.

High maps to the demonstrated temporary freeze of funds for at least 24 hours (Scope row 6400). The assessment remains conditional: the attacker must send about one transaction every 61 seconds, keep winning transaction ordering at recovery boundaries, and avoid a successful close. The measured pair of calls consumes 1,086,812 gas, or about 1.54 billion call gas for 1,417 cycles. At Arbitrum One's currently documented 0.02 gwei minimum Layer 2 (L2) gas price, this call gas alone converts to 0.03080025208 ETH before transaction overhead and L1 data fees; this is a lower-bound conversion, not measured spend. The attacker receives no bounty. The Scope no-profit attack-cost rule could support Medium Griefing if actual costs outweigh the damage assessable from the secondary reversal and the conditional capital lock; the whole locked margin is not treated as a realized loss. A successful keeper close within limits, an owner transaction sequenced first, or the demonstrated atomic wallet recovery ends the lock. No direct-theft or insolvency impact is claimed.

Relation to Known Issues

Cecuro MED-9 (marked Addressed). The published finding concerned missing trader-selected financial ceilings on initial protection closes and permissionless retries. Its report marks that issue addressed and describes the owner amendment added for Latched protections; it also notes that a tight ceiling may prevent execution until market conditions improve or the owner changes the ceiling. The pinned code now stores and copies all four configured ceilings into both initial and retried closes. This report does not claim that missing ceilings are still present. It concerns the recovery boundary: the amendment path only accepts Latched with no pending order, while the retry remains permissionless and changes the state back to Triggered. The demonstrated repeated retry therefore prevents the owner from using the MED-9 remedy during the pending child.

AI-scan finding (Low): “Protection trigger bounty is paid before a zero-bounty close is executed.” That finding describes a caller receiving a one-time trigger bounty before a close executes, then potentially abandoning the zero-bounty close and leaving the protection active. The present PoC does not rely on trigger-bounty payment, abandonment after triggering, or an unpaid keeper. Its attacker spends gas to call expiry and retry repeatedly, keeping the owner amendment unavailable. The shared Triggered/Latched irreversibility and zero-bounty retry behavior are acknowledged as overlap. The retry constructor sets the child maximum execution bounty to zero. OrderLiquidationBatchLogic.sol, retry bounds, lines 655–680

AI-scan finding (Info): “Failed protection attempts unconditionally pay the bounty instead of retaining it for retry.” That finding concerns terminal bounty accounting. The reproduced retry child has a zero bounty, the production retry host enforces that value, and this report claims no bounty transfer or accounting loss. The finding is adjacent to expiry handling but is not the root cause or impact demonstrated here.

Published protection behavior and incomplete MED-9 remedy. The repository documentation describes permissionless retries, irreversible protection triggering, and the account-level trade lock. It also states that the owner may amend limits only while Latched and no Router order is pending. It does not identify the interaction demonstrated here: repeated third-party expiry/retry transactions can continuously prevent an EOA owner from reaching the amendment mechanism added to address MED-9. The vulnerability is the inability to exercise that recovery route under adversarial transaction ordering, not the documented protection lifecycle itself. The underlying irreversibility, lock, permissionless retry, and frozen spread are disclosed; this report does not present those individual behaviors as new. The competition's published known-issue and public-disclosure rules leave the incomplete-fix distinction material.

Canonical protection entrypoints, lines 142–148
SECURITY.md, irreversible protection state and retry, lines 547–555

Monitoring blind spot described in SECURITY.md. The runbook tells operators to alert on a prolonged Latched protection with no live child. In the PoC, the attacker's same-transaction expiry/retry sequence leaves the persisted state Triggered with one live child after each transaction, so that specific current-state alert predicate may never remain true long enough to fire. The Book also emits a failed-attempt event during the transition; this PoC does not test off-chain event monitoring and does not claim all production monitoring is bypassed.

SECURITY.md, alert condition, lines 1356–1359
PositionProtectionBook.sol, Triggered child state, lines 565–575
PositionProtectionBook.sol, failed-attempt event and relatch, lines 662–668

Mitigation

Recommended change

Permit the owner to amend the stored close ceilings while exactly one matching protection child is pending. Keep the current child's committed execution bounds immutable; the amended ceilings apply only if that child fails or expires and a later retry is created. Continue to require the owner account for the amendment, reject inconsistent child mappings and any unexpected pending-order count, and keep cancellation restricted to its existing states.

Diff
diff --git a/packages/perps/src/PositionProtectionBook.sol b/packages/perps/src/PositionProtectionBook.sol
index 08359c0f..86117a68 100644
--- a/packages/perps/src/PositionProtectionBook.sol
+++ b/packages/perps/src/PositionProtectionBook.sol
@@ -317,12 +317,22 @@ contract PositionProtectionBook is IPositionProtectionBook, IOrderRouterErrors,
         PositionProtectionTypes.CloseFinancialLimits calldata limits
     ) external nonReentrant {
         StoredProtection storage protection = _ownedActiveProtection(protectionId, msg.sender);
-        if (protection.status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
+        IPositionProtectionRouterHost router = IPositionProtectionRouterHost(ROUTER);
+        if (protection.status == PositionProtectionTypes.PositionProtectionStatus.Latched) {
+            if (router.pendingOrderCounts(msg.sender) != 0) {
+                revert OrderRouter__PendingOrdersExist();
+            }
+        } else if (protection.status == PositionProtectionTypes.PositionProtectionStatus.Triggered) {
+            // The committed child retains its original financial bounds. Owner changes here apply to a later retry.
+            if (
+                protection.linkedOrderId == 0 || router.pendingOrderCounts(msg.sender) != 1
+                    || _attemptProtectionIds[protection.linkedOrderId] != protectionId
+            ) {
+                revert OrderRouter__PendingOrdersExist();
+            }
+        } else {
             revert OrderRouter__ProtectionNotLatched();
         }
-        if (IPositionProtectionRouterHost(ROUTER).pendingOrderCounts(msg.sender) != 0) {
-            revert OrderRouter__PendingOrdersExist();
-        }
         _setCloseLimits(protection, limits);
         _emitCloseLimitsUpdated(protection);
     }
diff --git a/packages/perps/src/interfaces/IPositionProtectionActions.sol b/packages/perps/src/interfaces/IPositionProtectionActions.sol
index bfad2783..63e2b128 100644
--- a/packages/perps/src/interfaces/IPositionProtectionActions.sol
+++ b/packages/perps/src/interfaces/IPositionProtectionActions.sol
@@ -29,8 +29,8 @@ interface IPositionProtectionActions {
         PositionProtectionTypes.PositionProtectionParams calldata params
     ) external;
 
-    /// @notice Lets the owner change close limits after a failed attempt relatches, before a fresh retry.
-    /// @dev The trigger and any terminal attempts remain recorded. A live child cannot be changed.
+    /// @notice Lets the owner amend stored close limits after an attempt fails or while one child is pending.
+    /// @dev A pending child's committed bounds remain unchanged; an amendment while `Triggered` applies to a later retry.
     function amendLatchedPositionProtectionCloseLimits(
         uint64 protectionId,
         PositionProtectionTypes.CloseFinancialLimits calldata limits

References

Proof of Concept

Proof of Concept

Environment and clean-checkout reproduction

The proof uses Solidity 0.8.35 and Foundry 1.8.3; packages/perps/foundry.toml enables optimizer and via-IR. The primary PoC source uses the repository's concrete PositionProtectionTest fixture. That fixture instantiates the test-only LegacyOrderRouterHarness, a subclass of the production OrderRouter; the PoC uses the inherited V3 commitOrder(OrderRequest) path and production execution, protection, and expiry functions. It does not call the test-only scalar-commit adapter. The test uses the repository's local Pyth and USDG doubles; it does not modify in-scope production contracts or use a fork/RPC endpoint.

LegacyOrderRouterHarness.sol, test-only adapter inherits production OrderRouter, lines 9–40

The main PoC sets launch risk parameters from [p

The original report as published on Immunefi, by xRakan. 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 owner amendment gate rejects any protection that is not Latched with zero pending orders, while the permissionless retry moves the protection to Triggered with a live child, so an attacker can keep the owner out of the amendment path.

Impact

The owner's position margin of 1,985.500999 USDG stays locked and the exit is blocked for over 24 hours, though free settlement assets can still be withdrawn and the lock ends if a close succeeds or the owner transacts first.

What the attacker needed

Victim has a live protected position; owner set a finite explicit-fee ceiling; child pending across the market freeze; attacker pays gas for repeated retries

The fix

The owner should be allowed to amend the stored close ceilings while exactly one matching child is pending, with the amended limits applying only to later retries.

How it was found

  1. The owner opens matched short positions and gives both protections the same limits, including a 5 USDG explicit-fee ceiling.
  2. Before the freeze, the control protected close executes in FAD mode at 4.004 USDG, showing the stored limit is executable.
  3. The victim's protected child is committed shortly before the Friday market-freeze boundary.
  4. A third party waits for the child to expire at the boundary, then calls expireOrder and retryPositionProtectionClose in one transaction.
  5. The replacement child fails in Frozen mode at 54.054 USDG against the 5 USDG ceiling, and the attacker retries in the same transaction, leaving the protection Triggered with a live child.
  6. The attacker repeats the expiry and retry cycles for 86,437 seconds while the market stays frozen.

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 can set a protection on their position that closes it automatically, with a cap on the fees they are willing to pay. When the market freezes, the fee needed jumps above that cap, so the close fails. The only way to raise the cap is a function that refuses to run while a close attempt is in progress, and anyone can start a new attempt, so an outsider can keep the trader 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.

More by xRakan

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.