Skip to content
Business logic Audit finding Advanced

Permissionless atomic protection retries can censor owner recovery for more than 24 hours

A permissionless retry function lets any account consume the brief Latched state that the position owner needs to amend obsolete close limits, atomically terminalising the old child and queuing a fresh one with the same limits. An attacker who wins ordering at each recovery point can keep the protected position and its margin locked for over 24 hours.

adeolu Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99947 [SC-High] Permissionless atomic protection retries can censor owner recovery for more than 24 hours

Submitted on Nov 15th 2026 at 20:30:49 UTC by @adeolu for Audit Competition | Plether

Description

Brief/Intro

After a protected close fails or expires, the position protection is briefly placed in the only state in which its owner can amend obsolete close limits. However, any account can consume that state by retrying the close, including atomically in the same transaction that terminalizes the previous child. Every retry copies the unchanged limits into a fresh child with a fresh deadline, while the active protection prevents ordinary closing. An unprivileged attacker who repeatedly wins transaction ordering at those recovery points can therefore deny owner-controlled exit and keep the protected position and its recoverable margin lo'[
cked for more than 24 hours.

Vulnerability Details

The owner can amend limits only during a narrow Latched state

The owner-only amendment entrypoint accepts a protection only when it is Latched and the account has no pending child. This is the intended recovery route after a generated close becomes unusable because one of its retained financial limits is no longer sufficient.

Source: PositionProtectionBook.sol 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);
}

When a generated protection child fails or expires while the protected position still matches, handleFailedProtectionAttempt deletes the old attempt marker and restores Latched.

Source: PositionProtectionBook.sol lines 637-667

Solidity
delete _attemptProtectionIds[orderId];
retained = _positionMatches(protection);
emit PositionProtectionCloseAttemptFailed(protectionId, account, orderId, reason, retained);
if (retained) {
    protection.status = PositionProtectionTypes.PositionProtectionStatus.Latched;
    return true;
}

This transition is supposed to let the owner repair the retained limits. It does not create an owner-priority interval.

The vulnerability is not that retries are permissionless or carry zero order-execution bounty in isolation. Those mechanics are documented. The vulnerability is that an arbitrary retry caller can atomically consume the same Latched state reserved for the owner-only repair function, without an owner authorization, owner-priority interval, acknowledged limit version, or cumulative retry bound. The caller can consequently keep repinning limits that only the owner is authorized to change.

Permissionless retry accepts exactly the owner's recovery state

retryPositionProtectionClose is permissionless: it loads the active protection without checking msg.sender against protection.account. It accepts exactly the Latched and zero-pending-order state required by the owner amendment function, then asks the Router to create a replacement child.

Source: PositionProtectionBook.sol 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);
}

_recordCloseAttempt immediately changes the protection back to Triggered, closing the owner's amendment window.

Source: PositionProtectionBook.sol lines 564-577

Solidity
uint64 previousLinkedOrderId = protection.linkedOrderId;
protection.linkedOrderId = linkedOrderId;
protection.status = PositionProtectionTypes.PositionProtectionStatus.Triggered;
_attemptProtectionIds[linkedOrderId] = protection.protectionId;
emit PositionProtectionCloseAttemptQueued(
    protection.protectionId, protection.account, linkedOrderId, previousLinkedOrderId
);

An attacker contract can consequently perform either of these sequences before returning control:

Solidity
router.executeOrder(failingChildId, executionData);
protectionActions.retryPositionProtectionClose(protectionId);

or, after a later child reaches its deadline:

Solidity
router.expireOrder(expiringChildId);
protectionActions.retryPositionProtectionClose(protectionId);

The first call terminalizes and removes the old child, temporarily producing Latched with zero pending orders. The second call immediately consumes that state. Because both calls execute inside one attacker transaction, the owner cannot amend between them. The nonReentrant modifiers do not prevent this because the first external call has fully returned and released its guard before the second call begins.

Every retry copies the obsolete limits into a fresh permanent child

The delegated Router logic assigns every retry the current nextCommitId, constructs a new protocol client identity containing that ID, permanently registers it, marks it as a protection attempt, and queues it.

Source: OrderLiquidationBatchLogic.sol lines 183-210

Solidity
orderId = host.nextCommitId();
OrderV3Types.OrderRequest memory request = _protectionCloseRequest(host, protectionId, side, size);
request.clientOrderId = OrderV3Types.protocolClientOrderId(
    keccak256(
        abi.encode(
            "PLETHER_POSITION_PROTECTION_RETRY_V3", block.chainid, address(this), account, protectionId, orderId
        )
    )
);
(uint64 registeredOrderId,, bool replayed) = host.lifecycleBook().registerPending(account, orderId, request, 0);
if (replayed || registeredOrderId != orderId) {
    revert IOrderLifecycleBook.OrderLifecycleBook__OrderIdAlreadyUsed(orderId);
}
host.lifecycleBook().registerProtectionAttempt(orderId);
_queueProtectionAttempt(host, orderId, account, side, size);

The replacement reads the same retained financial limits, receives a new maximum-length execution window, and has an explicit zero order-execution bounty. This is distinct from the nonzero, governance-configured protection-trigger bounty reserved when protection is created and paid once to the original trigger caller.

Source: OrderLiquidationBatchLogic.sol lines 655-679

Solidity
PositionProtectionTypes.CloseFinancialLimits memory limits =
    host.positionProtectionBook().closeFinancialLimits(protectionId);
request.side = side;
request.sizeDelta = size;
request.targetPrice = side == CfdTypes.Side.LONG ? host.engine().CAP_PRICE() : 1;
request.isClose = true;
request.bounds.submitBy = uint64(block.timestamp);
request.bounds.executionWindowSeconds = uint32(host.maxExecutionWindowSeconds());
request.bounds.allowedExecutionModes = ALL_V3_EXECUTION_MODES;
request.bounds.expectedConfigHash = bytes32(0);
request.bounds.maxExecutionBountyAssets = 0;
request.bounds.maxExecutionNotionalAssets = limits.maxExecutionNotionalAssets;
request.bounds.maxGrossAccountDebitAssets = limits.maxGrossAccountDebitAssets;
request.bounds.maxActionChargeAssets = limits.maxActionChargeAssets;
request.bounds.maxExplicitFeesAssets = limits.maxExplicitFeesAssets;

The Router advances nextCommitId, creates a zero-valued BountyKind.Order execution reservation, and inserts a pending full close with a fresh commit clock.

Source: OrderRouter.sol lines 440-471

Solidity
if (linkedOrderId != nextCommitId) {
    revert OrderRouter__Unauthorized();
}
nextCommitId = linkedOrderId + 1;
clearinghouse.recordBountyReservation(account, IMarginClearinghouse.BountyKind.Order, linkedOrderId, 0);
_recordCommittedOrder(
    CfdTypes.Order({
        account: account,
        sizeDelta: size,
        marginDelta: 0,
        targetPrice: side == CfdTypes.Side.LONG ? engine.CAP_PRICE() : 1,
        commitTime: uint64(block.timestamp),
        commitBlock: ExecutionBlockNumberLib.current(),
        orderId: linkedOrderId,
        side: side,
        isClose: true
    })
);

The account pending-order cap is only a simultaneous-live-record limit. Terminal settlement deletes the old child and decrements pendingOrderCounts before the attacker makes its second external call. Retry then inserts the replacement and increments the count from zero back to one; there is no cumulative retry limit.

Source: OrderCommitHandler.sol lines 40-59

Solidity
function _recordCommittedOrder(
    CfdTypes.Order memory order
) internal {
    // ...
    _linkGlobalOrder(orderId);
    _linkAccountOrder(account, orderId);
    if (++pendingOrderCounts[account] > maxPendingOrders) {
        revert OrderRouter__TooManyPendingOrders();
    }
    emit OrderCommitted(orderId, account, order.side);
}

The corresponding cleanup ordering is explicit in _deleteOrder: both queue links and account aggregates are removed before the terminal hook returns control to the caller.

Source: OrderRouterBase.sol lines 117-140

Solidity
_unlinkAccountOrder(account, orderId);
_unlinkGlobalOrder(orderId);
record.status = terminalStatus;
if (account != address(0) && pendingOrderCounts[account] > 0) {
    pendingOrderCounts[account]--;
}
if (account != address(0) && record.core.isClose && pendingCloseSize[account] >= record.core.sizeDelta) {
    pendingCloseSize[account] -= record.core.sizeDelta;
}
_afterOrderDeleted(orderId, account, terminalStatus);
delete orderRecords[orderId];

The owner has no alternative exit while the replacement is live

The attacker returns the protection to Triggered with one pending child. In this state:

  • amendment reverts OrderRouter__ProtectionNotLatched;
  • direct cancellation rejects every state other than PendingOpen or Armed;
  • cancellation-and-close explicitly requires Armed; and
  • ordinary V3 close admission rejects any account with an active protection.

The cancellation restriction is at PositionProtectionBook.sol lines 408-419, while cancellation-and-close's Armed requirement is at PositionProtectionBook.sol lines 341-358.

Ordinary close admission is blocked here:

Source: OrderLiquidationBatchLogic.sol lines 302-315

Solidity
if (enforceProtectionLock && host.positionProtectionBook().activePositionProtectionId(account) != 0) {
    revert OrderRouter__ProtectionActive();
}

Once the attacker's expireOrder + retryPositionProtectionClose transaction begins executing, the owner cannot interleave an amendment between its two calls: the attacker terminalizes the child and consumes Latched before that transaction returns. A stale child can also be terminalized before expiry by executing it against a valid price that violates its retained ceiling. An EOA owner must perform terminalization and owner-only amendment as separate transactions; the PoC demonstrates an attacker inserting retry between those transactions. A contract or account-abstraction wallet can batch terminalization, amendment, and retry while preserving its identity as the protection account. The PoC includes a separate control proving that this atomic owner bundle succeeds when sequenced first. Censorship therefore depends on transaction ordering whenever such an owner actively contests recovery; it does not give the attacker exclusive access to expiry or terminalization.

Distinction from disclosed and previous findings

This report was compared against the program's published limitations and the closest previous findings concerning position protection. It has a different root cause and requires a different fix:

  • Cecuro MED-9 — retries lacked trader financial limits. MED-9 reported that protection attempts were created with effectively unlimited financial maxima. Its published fix retained the trader's limits, copied them into every attempt, and introduced the owner-only Latched amendment path. The audit response expressly says that tight limits may prevent execution until conditions improve or the owner amends them. This report begins after that fix is working: the child correctly fails its retained maxExecutionNotionalAssets ceiling, but an arbitrary caller repeatedly prevents the owner from using the new amendment path. Adding retained limits fixed MED-9 but did not fix this censorship; conversely, adding owner authorization or an owner-priority interval does not add the financial caps required by MED-9. See Cecuro MED-9, PDF page 27.
  • Published zero order-execution bounty limitation and the AI-scan keeper-incentive finding. The program discloses that failed-attempt cleanup is unpaid and that every retry creates a fresh close record whose BountyKind.Order amount is zero. The earlier scan reports that this can leave a close unprocessed because rational keepers lack compensation after the separate one-time protection-trigger bounty is paid. This report assumes the opposite behavior: a malicious caller willingly pays gas to process every expiry and append every replacement. Funding retries or delaying the trigger bounty could address the earlier incentive failure but would not remove the attacker's permission to consume the owner's repair state; a retry bounty could even subsidize the censorship. Owner authorization or priority would stop this attack but would not fund honest execution. See the earlier keeper-incentive finding.
  • Cecuro MED-15 — zero adjusted execution price. MED-15 concerned a SHORT attempt whose oracle execution price became zero and repeatedly failed slippage. Its fix rejects zero prices and constrains confidence configuration. This PoC executes at a positive 1.1e8 price and authenticates ConstraintViolation(ExecutionNotional) caused by an obsolete owner ceiling. The zero-price fix does not affect retry authorization or amendment ordering. See Cecuro MED-15, PDF page 39.
  • Cecuro MED-30 — protection triggering during frozen markets. MED-30 concerned an Armed protection that could not trigger during a frozen oracle window. Its fix added an owner-only atomic cancel-and-close path for Armed protection and expressly excluded Triggered and Latched records. This PoC uses a successfully triggered protection and attacks the later Triggered -> Latched -> Triggered recovery loop under a valid live price. Changing frozen-market trigger policy does not fix this loop, while owner-prioritized recovery does not make frozen-market activation available. See Cecuro MED-30, PDF page 69.
  • Cecuro LOW-50 — reservation-mismatch cleanup removed protection. LOW-50 concerned a special reservation-mismatch cleanup path that terminalized protection instead of relatching it. Its fix correctly routes an unchanged position back to Latched. This PoC does not create a reservation mismatch: it uses an ordinary typed constraint failure followed by canonical expiries, and correct relatching is a prerequisite to the attack. Repairing mismatch cleanup does not authorize owner recovery, and owner-prioritized recovery does not repair mismatched reservations. See Cecuro LOW-50, PDF pages 170-171.
  • Trigger-timing findings MED-8, MED-17, MED-23, and MED-28. Those findings concern L2 block-number reuse, oracle publication-time progress, mixed-time baskets, or stale arming geometry before a protection can trigger. The PoC reaches a valid trigger through the production entrypoint and begins only after its close child exists. Their block-clock and oracle-synchronization fixes neither prevent nor repair post-trigger retry censorship.

Under the program's duplicate test, fixing any of the earlier findings does not automatically fix this one, and fixing this issue does not automatically fix any of them. The shared protection state machine and zero order-execution bounty records are overlapping mechanics, not the shared root cause.

Executed attack path

  1. Alice deposits through the Clearinghouse and opens a real 10,000e18 SHORT through public commitOrder and executeOrder, supplying 2,000e6 margin at a 1e8 mark. After opening charges, the Engine stores 1,986e6 of position margin.
  2. Alice configures a trigger at 1.05e8 and a 10,605e6 execution-notional ceiling, giving one percent headroom over the 10,500e6 notional at the trigger. A snapshot control executes the original child successfully at 1.05e8, proving the retained limit was usable when the close was queued.
  3. Before delayed execution, the price moves to 1.1e8. Execution notional becomes 11,000e6, above the previously valid ceiling. The child terminally fails with authenticated ConstraintViolation(ExecutionNotional).
  4. The attacker contract forwards a nonzero mocked Pyth fee to the payable production executeOrder entrypoint and invokes permissionless retry in the same transaction. It ends with a new Triggered child rather than exposing Latched to Alice.
  5. The PoC separately has EOA Alice terminalize that replacement before expiry. Because amendment requires a second EOA transaction, the attacker inserts retry between them; Alice's amendment, cancellation, cancellation-and-close, and ordinary close then revert.
  6. After every later replacement deadline, the attacker atomically calls expireOrder(currentChildId) and retryPositionProtectionClose(protectionId). Each cycle permanently expires the old child, copies the same obsolete limit into a fresh ID and deadline, and keeps the live count exactly one.
  7. The test derives the required cycle count from the Router's execution window. At the frozen configuration it performs 1,417 renewals: 1,417 * 61 = 86,437 seconds, or 24 hours and 37 seconds. Every simulated renewal also advances the block number.
  8. One complete expiry-and-retry call runs with normal gas metering and consumes 925,161 test-EVM gas. Aggregate metering is paused only for the remaining long loop so Foundry's single synthetic outer transaction does not truncate 1,417 state transitions.
  9. Throughout that period, the complete 10,000e18 position and its stored 1,986e6 margin remain in the Engine. In the honest control, the attacker stops, Alice amends, the repaired child closes, and 995.591318 USDG of net settlement is released and actually withdrawn to Alice after price settlement and accrued charges.
  10. A separate contract-wallet control wins ordering with one atomic expire + amend + retry bundle and installs the repaired limit. This bounds the claim: the vulnerability censors recovery when the attacker consumes the repair state first; it does not make recovery impossible regardless of transaction ordering.

Recommended remediation

Reserve the first recovery opportunity after a failed attempt for the protection owner. Robust designs include requiring owner authorization for every retry or binding retry to an owner-approved close-limit version. If permissionless liveness is required, introduce an owner-only recovery interval after relatching and allow Latched cancellation or atomic owner amendment-and-retry. A cooldown alone is weaker because an attacker can still consume every window once it opens. A cumulative retry bound can provide an additional backstop but should not replace owner authority over retained financial limits.

Impact Details

Selected in-scope impact: High — Temporary freezing of funds for at least 24 hours.

The attack prevents the owner from closing the protected position and therefore prevents release of its pledged margin. The Engine's stored position record remains at 1,986e6 margin atoms throughout the attack, but that stored value is not presented as the owner's eventual net recovery: carry and close economics accrue during the 24-hour warp. The honest control measures the economically stronger result. Once censorship stops and the same position closes at 1.1e8, 995.591318 USDG of net settlement is released into Alice's free balance and successfully withdrawn to her wallet. That amount was unavailable while the complete 10,000e18 position remained open.

Continued market movement can additionally change PnL, recoverability, or liquidation risk during censorship. The demonstrated scenario holds the execution price at 1.1e8, above the stale 10,605e6 ceiling, and remains healthy through the measured interval. The impact claim assumes the child remains economically unexecutable under its retained limit, the account is not liquidated, and the attacker wins ordering whenever the owner actively contests recovery.

The PoC produces this measured state after 1,417 permissionless renewals:

Text
single expire-and-retry call gas: 925161
permissionless renewal cycles: 1417
elapsed censorship seconds: 86437
latest replacement child id: 1421
locked position size: 10000000000000000000000
locked live margin assets: 1986000000
stale execution notional ceiling: 10605000000
current execution notional: 11000000000
recoverable settlement released after censorship: 995591318

The attacker does not receive the frozen funds. Replacement children pay no order-execution bounty, although the attacker could also be the original trigger caller and receive the separate one-time protection-trigger bounty. The PoC deliberately assigns that trigger to a distinct keeper, so its renewal attacker receives no bounty. The continuing attack otherwise costs one transaction per renewal; the metered production call path consumes 925,161 test-EVM gas per expire + retry, or approximately 1.31 billion such gas units over 1,417 renewals before chain-specific transaction and data pricing. Actual Arbitrum cost depends on execution and L1 data fees at the time of attack.

A contract or account-abstraction owner can end the attack by having its atomic terminalization-and-amendment bundle sequenced first. An EOA can terminalize early but must race the attacker's retry before its separate amendment transaction. These are feasibility constraints, not hidden assumptions. The program determines impact before feasibility and separately lists temporary freezing of funds for at least 24 hours as High; the PoC directly asserts and exceeds that duration by 37 seconds.

The PoC position is a deterministic regression fixture, not an upper bound on affected value. For a valid larger protected position, the number and shape of renewal transactions remain the same: retry replaces one full-close record, and its execution cost does not scale linearly with position size or recoverable margin. The gas-to-damage ratio therefore improves as the targeted valid position grows. Transaction ordering, the victim's account type and response, current chain fees, continued price conditions, and concrete value at risk remain feasibility considerations.

This should not be classified as Critical permanent freezing. The honest control proves recovery succeeds once the attacker stops. No single renewal makes the funds irretrievable forever; the attacker must continue renewing the lock.

References

Proof of Concept

Proof of Concept

Prerequisites

  • Git
  • Foundry (verified locally with Forge v1.0.0-stable; the repository CI installs foundry-rs/foundry-toolchain@v1)
  • Solidity 0.8.35, selected according to packages/perps/foundry.toml

No RPC URL, fork, public network, or external service is required.

Fresh-clone reproduction

  1. Clone the frozen competition repository and initialize all submodules:
Bash
git clone https://github.com/immunefi-team/audit-comp-plether.git
cd audit-comp-plether
git checkout a82d4fefb02768e5b3bddcc97dee371eee24fea8
git submodule update --init --recursive

The original report as published on Immunefi, by adeolu. 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

The permissionless retry entrypoint accepts the same Latched, zero-pending-order state reserved for the owner-only amendment function, with no owner authorisation, priority interval or cumulative retry bound.

Impact

The owner cannot close the protected position or release its margin for more than 24 hours, though the report notes this depends on the attacker winning transaction ordering and does not make recovery impossible.

What the attacker needed

No special role needed; attacker pays gas for each cycle; attacker wins transaction ordering; position still matches protection

The fix

The first recovery opportunity after a failed attempt should be reserved for the protection owner, for example by requiring owner authorisation for retries or an owner-only recovery interval after relatching.

How it was found

  1. The owner opens a short position and configures a protection close with a notional ceiling that is valid at the trigger price.
  2. The price moves so the retained ceiling is exceeded and the generated child fails with a constraint violation.
  3. The attacker calls the production execute entrypoint and the permissionless retry in one transaction, leaving a new Triggered child.
  4. The owner terminalises the replacement, but the attacker inserts a retry before the owner's separate amendment transaction.
  5. After each replacement deadline the attacker atomically expires the child and retries, copying the same obsolete limit into a fresh child.
  6. The cycle is repeated 1,417 times to cover more than 24 hours while the position and margin stay locked.

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 up an automatic safety close on their position, with price limits they are allowed to update later. When that close fails, the system briefly opens a small window in which only the owner is meant to fix the limits. The report shows anyone can use that same window first to restart the failing close, so the owner never gets a turn and their money stays 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 adeolu

View all

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