Skip to content
Business logic Audit finding Advanced

Missing owner priority in retryPositionProtectionClose allows any caller to keep amendLatchedPositionProtectionCloseLimits reverting and hold a triggered stop-loss position open

A permissionless retry function can be called in the same transaction that ends a failed stop-loss close attempt, keeping the protection in Triggered state so the owner's amend function always reverts. An attacker can therefore hold a triggered stop-loss position open while the price moves against the victim, causing losses.

Persona404 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#99945 [SC-High] Missing owner priority in retryPositionProtectionClose allows any caller to keep amendLatchedPositionProtectionCloseLimits reverting and hold a triggered stop-loss position open

Submitted on Nov 15th 2026 at 20:20:44 UTC by @Persona404 for Audit Competition | Plether

Description

Brief/Intro

A stop-loss or take-profit that has triggered cannot be closed, cancelled or replaced by its owner. If its close attempt fails on the owner's own fee ceilings, the protection becomes Latched, and the one remedy the project documents is for the owner to change the ceilings with amendLatchedPositionProtectionCloseLimits. That call only works while the protection is Latched. retryPositionProtectionClose is open to anyone, needs the same state, and can run in the same transaction that ends the failed attempt. A caller who ends every attempt and retries in one transaction keeps the protection in Triggered at every transaction boundary. The owner's amend reverts each time, and she stays in a position whose stop has already fired while the price keeps moving. The same caller can cause the failure in the first place by adding skew, which lifts the victim's close VPI above her ceiling when that ceiling is below about 47 bps of the close notional. The amend path was added by the MED-9 fix (PR #124) after the commit Cecuro audited, so this is a new bug introduced by a fix. I claim Griefing, Medium, and nothing above it.

Vulnerability Details

The state machine. A protection stores four close ceilings chosen by the owner: execution notional, gross account debit, action charge and explicit fees. Every close attempt, including every retry, copies them. When an attempt is executed and an assessed amount is above its ceiling, the attempt ends as Failed with ConstraintViolation and handleFailedProtectionAttempt moves the protection from Triggered to Latched (PositionProtectionBook.sol:637-675).

In Triggered and in Latched the owner has no ordinary exit. Each of these reverts, and the PoC asserts every one in both states:

  • a manual close through OrderRouter.commitOrder: OrderRouter__ProtectionActive (router/OrderLiquidationBatchLogic.sol:313-315)
  • cancelPositionProtection, cancelPositionProtectionAndCommitClose and replacePositionProtection: OrderRouter__ProtectionNotArmed (PositionProtectionBook.sol:413-419, 346-348, 272-277)

What is left is the amend (PositionProtectionBook.sol: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 retry (PositionProtectionBook.sol:382-405) starts with the same two conditions and has no caller check and no delay:

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();
    }
    // linked-order checks, then the new attempt is committed and the status is Triggered again

The lock. The attacker uses a small contract with no role (RetryLocker in the PoC) that does one of two things in a single transaction:

  1. router.executeOrder(attempt, pythData), then book.retryPositionProtectionClose(id). The attempt fails on the ceiling, the protection is Latched only inside that transaction, and the retry puts it back in Triggered with a fresh attempt.
  2. router.clearInvalidOrders([attempt]), then the same retry. This ends an attempt whose execution window has passed (60 seconds in the repository fixture) and needs no price data.

Either way the owner never finds the protection Latched between two transactions, and her amend reverts with OrderRouter__ProtectionNotLatched. Variant 2 needs one transaction per execution window.

How the attempt comes to fail. Three ways:

a. Forced by the attacker in a live market. The policy evaluator counts close VPI in the action charge that is tested against maxActionChargeAssets (CfdOrderPolicyEvaluatorBase.sol:412-414 and 509-513). The attacker opens a position on the other side up to just under the skew cap. The victim's close then adds to the skew and is charged VPI instead of getting a rebate. Measured: 51.906870 USDG on an 11,000 USDG close (47.18 bps), against 3.900999 USDG quoted when the stop was armed. b. Without the attacker's help in a frozen market. A frozen close pays the 0.50 % frozen spread on top of the fee. Measured: 58.904793 USDG on the same close, above a ceiling of 0.50 % of notional. c. Without the attacker's help in a live market, whenever the owner's ceilings are too tight for the conditions at execution. This is the case the documentation describes.

In (b) and (c) the attacker needs no capital, only the retry transactions.

Guards on the path.

Guard Predicate Does the attack bypass it? Invariant it protects
amend status is Latched and the owner has no pending order No. It is simply never true when the owner's transaction runs. A live attempt keeps the ceilings that applied when it was committed.
retry status is Latched, position unchanged, account has no pending order, previous attempt is terminal No. The attacker meets every condition. One live attempt per protection, one pending order per account.
ceilings at execution assessed amount is at most the owner's ceiling No. The attempt fails exactly as the ceiling requires. The owner's fee policy for an automated close.

The invariant that is broken is a separate one: the owner's documented right to change the ceilings between two attempts. Nothing in the code reserves any moment for her to do it.

What the owner can still do. I state this plainly because it limits the finding.

  • She can act as her own keeper: execute the live attempt herself with a signed Pyth update, or clear it after expiry, and send the amend as her next transaction. If no retry is sequenced between the two, the amend succeeds and she gets out (PoC test 5, case B). If the attacker's retry lands between them, the amend reverts again (case A). In the same block as the attacker's transaction there is no exit, because the new attempt cannot be executed yet (test 5). I cannot show on a local chain who wins that ordering on Arbitrum, so I do not claim a freeze.
  • Collateral outside the position is not affected. She can withdraw free balance (test 5).
  • The lock ends when the attacker stops, when the skew is removed (test 7), or when the position is liquidated (test 8). A price back inside the stop does not end it, because a retry never checks the trigger again (test 7).

Why this is not a known issue. The program page says: "For findings marked as fixed or Acknowledged in the reports above, a report on the same root cause is valid only if it shows that the fix at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8 is incomplete or introduces a new bug." MED-9 is such a finding. amendLatchedPositionProtectionCloseLimits does not exist at the audited commit 6d6622f2. PR #124 (commit eadc5c58) added it as the owner's remedy inside the MED-9 fix.

These are the project statements I found that touch the behaviour, each quoted in full.

  1. Cecuro report, MED-9, status Acknowledged. The project comment is labelled Addressed and reads: "The protection retains trader-selected ceilings for execution notional, gross account debit, action charges and explicit fees, and copies them into both the initial close and every permissionless retry. Only the owner may amend the retained ceilings while protection is Latched; keepers cannot relax them. Limits use six-decimal USDC: zero means zero allowance and uint256.max explicitly opts into unlimited allowance. A triggered close remains a market close, so these financial ceilings do not guarantee a fill at the trigger price. Tight limits may prevent execution until conditions improve or the owner amends them." This accepts that tight limits can stop execution, and it names two ways out: conditions improve, or the owner amends. This report is about the second way out being closable by anyone, for as long as they like. In variant (a) the same party also prevents the first.

  2. PR #124, section "Accepted trade-offs and known limitations": "Financial ceilings apply per close attempt and can prevent execution; the owner may amend limits after relatch. They are not a cumulative budget across retries." The same PR lists as a security property: "Triggered and retried closes retain the owner's financial ceilings. Only the owner can amend latched limits." Same answer. The second sentence says who is allowed to amend. It does not say the owner is able to.

  3. AI scan, "State-driven VPI increases are classified as user-invalid margin failures" (info), claim: "An open can be valid when committed and later fail with MARGIN_DRAINED_BY_FEES solely because other accounts change global side skew or pool depth, increasing its VPI charge before execution. planOpen uses the resulting state-dependent tradeCostUsdc in planOpenCostApplication, but getExecutionFailurePolicyCategory classifies every MARGIN_DRAINED_BY_FEES result as UserInvalid rather than ProtocolStateInvalidated. An unprivileged account can therefore move skew ahead of a tightly funded victim order and cause the victim's execution to enter the router's user-fault failure lifecycle, potentially forfeiting/absorbing the victim's reserved execution bounty even though the invalidation came from protocol-wide market state rather than the victim changing inputs or collateral." This is the skew primitive I use in (a), described for opens. I am not reporting it. On its own it only makes the victim pay 48.005871 USDG more after she amends (test 2). The harm in this report comes from the amend being unreachable.

  4. AI scan, "Protection trigger bounty is paid before a zero-bounty close is executed" (low), claim: "A permissionless caller can collect the entire position-protection trigger bounty as soon as a trigger is observed and a close attempt is merely queued, while the queued close and every retry carry a zero execution bounty. The caller can abandon the flow after receiving payment; because same-block execution is normally disallowed and later execution requires another oracle-funded transaction, unrelated keepers have no order-specific compensation to finish the close. The protection becomes Triggered (and later Latched on expiry/failure), cannot be cancelled through the pre-trigger cancellation path, and the protected position can remain open through its stop-loss/take-profit threshold and incur further loss or liquidation." Its evidence adds: "Official linked implementation only permits cancellation before triggering; a Triggered or Latched protection cannot be cancelled to regain ordinary close control." This establishes that a Triggered or Latched protection cannot be cancelled, which is why the amend is the only remedy. It describes a keeper that walks away. It does not describe a caller that keeps the amend unreachable.

  5. SECURITY.md, protection lifecycle: "Triggering is irreversible. Triggered means the Book has exactly one current live child; Latched means the trigger evidence and account trade lock remain but no child is live. A non-liquidation terminal child failure relatches only when the protected position still has the exact recorded account, side, and size; otherwise the protection fails and releases the active lock. Retry is permissionless and validates the latest child/reverse mapping so an old or spoofed callback cannot replace the current attempt. It does not re-evaluate the threshold, and a recovered price cannot cancel the close mandate." Permissionless retry is documented and I do not dispute it. What is not documented is that a retry made in the same transaction as the failure removes the Latched window the amend depends on.

  6. SECURITY.md, Known Limitations: "failed protection-attempt cleanup is deliberately unpaid; each retry creates a fresh zero-bounty close record. The separate trigger reward is paid once on the original trigger. Liveness depends on keepers processing the terminal attempt and separately appending a retry, and operators must alert on prolonged Latched state without a live child," This is about too little keeper activity. The attack is the opposite, and it never leaves the protection Latched without a live attempt, so the alert it asks for does not fire.

  7. DEPLOYMENT.md: "A trigger queues a close; it promises neither its execution price nor execution before liquidation." and, for the reference worker: "A conservative worker retries expiry failures only after confirming the account has no pending orders, queue capacity is available, and valid execution data is obtainable. Investigate planner, constraint, or other persistent failures before retrying; do not continuously queue the same failing attempt." The first accepts that a close may not execute. It does not accept that the owner loses the means to make it execute. The second is advice for the project's own worker. The program page says: "Keepers are not trusted: anyone can execute orders, liquidations, price updates and protections, so harm caused by any caller acting as a keeper is in scope." and "Researchers should consider any contract-permitted behavior, including deviations from the reference implementation."

  8. The documents that promise the remedy. WORKING_WITH_AI_AGENTS.md: "If a queued close fails and the protected side and size still match, protection becomes Latched; the owner may amend its limits before retrying." CANONICAL_ENTRYPOINTS.md: "The owner may amend the close ceilings of a Latched protection with PositionProtectionBook.amendLatchedPositionProtectionCloseLimits(uint64,CloseFinancialLimits) when the account has no pending Router order."

I searched the documents in packages/perps, the audit reports in the repository and PR #124 for the amend and for statements about retries. None of them says that a third party can keep the amend unreachable.

Impact Details

Selected impact: Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol). Severity Medium. The attacker earns nothing from the lock.

What the PoC measures. Release risk parameters, pool 1.0M USDG, victim LONG 10,000 tokens with 2,000 USDG margin and a stop-loss at 1.10:

  • Control, no attacker: the stop-loss closes at 1.10 and the victim's balance goes from 19,995.300999 to 18,991.200000 USDG.
  • Lock held for 8 attacker transactions while the price goes from 1.10 to 1.17: the victim ends at 18,236.675417 USDG, 754.524583 worse than the control. 700.000000 of that is the price move while she was locked, 54.524583 is extra fees and VPI.
  • Lock held until liquidation at 1.20: the victim loses 1,995.700999 USDG from trigger to liquidation, against 1,004.100999 in the control.
  • Lock held for 3,721 seconds with 61 transactions and no price data (test 6), and the same in a frozen market with no attacker funds in the protocol (test 9).

The price path in these tests is my assumption. The lock does not move the price. What it takes from the victim is the exit her stop-loss had already ordered. She carries the full price risk of the position for as long as the lock holds, up to the loss of her whole margin, and she pays the higher VPI when she does get out.

Who is affected:

  • Variant (a) only reaches victims whose action-charge ceiling is below what the attacker's skew can add. In the tested state a ceiling of 0.44 % of close notional fails, 0.50 % executes and unlimited executes (test 3). The assessed charge was 47.18 bps at the 1.0M pool and 46.65 bps at a 50M pool. There is no protocol default for the ceilings. The project's client fixtures (packages/perps-aa-client/test/protection.test.ts, out of scope) use 0.50 %, and the project's own Solidity tests use unlimited. A user with the client-fixture ratio is not affected by (a). A user with unlimited ceilings is not affected at all.
  • Variant (b) reaches ceilings up to the frozen cost, 58.904793 USDG or about 53.5 bps of this close, which includes the 0.50 % client-fixture ratio (test 9 uses exactly that ratio). Its precondition is not created by the attacker: the protection must already be Triggered or Latched when the market freezes, because triggers do not fire in a frozen market. In test 9 the first attempt expires unexecuted on Friday before the close.
  • In every variant a victim who ends the attempt herself and gets her amend in as the very next transaction escapes.

Attacker cost, against the program's baseline: "Applies to High or Critical findings where the attacker gains no profit. The baseline is that spending USD 1 to cause USD 10 or less in damage is Griefing, while spending USD 1 to cause USD 100 or more in damage is not. Ratios between these are evaluated case by case."

  • Variant (a), 1.0M pool: the attacker deposits 10,020.004990 USDG and opens a SHORT of 398,700 tokens. After unwinding, the attack cost it 346.274574 USDG in test 4 and 335.108742 USDG for an immediate unwind in test 6, plus 0.922592 USDG for holding 3,721 seconds. Against the 754.524583 USDG victim loss in test 4 that is about 2.2 USD of damage per USD spent. Only 54.524583 of the damage is independent of the price path, about 0.16 USD per USD spent.
  • Variant (a), 50M pool: deposit 500,020.000099 USDG, SHORT of 19,410,700 tokens, 16,305.223316 USDG for an immediate unwind (test 10). Against one victim of this size the attacker spends far more than the damage. The same position locks every victim on that side whose ceiling is below the threshold. I did not test more than one victim.
  • Variant (b): no capital, 61 transactions per hour, gas only.

The cost figures leave out the market move on the attacker's own SHORT, which is ordinary exposure and not a result of the attack. Every ratio above is at or below 1 to 10, which is Griefing under the baseline.

Not claimed: "Temporary freezing of funds for at least 1 hour" and "Temporary freezing of funds for at least 24 hours". An owner who executes the attempt herself and amends in two uninterrupted transactions gets out, and I cannot show locally that the attacker wins the ordering against such an owner. Tests 6 and 9 hold the lock for over an hour only against an owner who does not do that.

On the out-of-scope row "Impacts requiring basic economic and governance attacks (e.g. 51% attack)": variant (a) needs a large position, which the attacker gets back minus fees. The lock itself needs no capital, and variants (b) and (c) use none.

Recommended fix, any one of:

  1. Let the owner amend while an attempt is live: accept Triggered in the amend, cancel the live zero-bounty attempt, store the new ceilings and queue the next attempt.
  2. Give the owner priority after a failed attempt: for a short period after an attempt ends on a ceiling, only the owner may retry, or at least a retry may not share a transaction with the end of the previous attempt.
  3. Let the owner cancel a Triggered or Latched protection into an ordinary bounded close, as cancelPositionProtectionAndCommitClose already does for Armed.

Options 1 and 3 remove the dependence on transaction ordering.

References

I am happy to address any technical concerns, clarify assumptions, or provide additional evidence. If any aspect of the report may affect its validity or severity assessment, please let me know so I can respond before a final determination is made.

Proof of Concept

The PoC is a Foundry test in the repository's own test suite at the commit in scope. It changes no contract in scope. Pyth and USDG are the repository mocks, which the program allows. Risk parameters are the release values from packages/perps/DEPLOYMENT.md (maintenance margin 10 bps, initial margin 20 bps, frozen-market margin 300 bps, vpiFactor 0.01e18, maxSkewRatio 0.4e18, carry 500 bps), set through the fixture hook _riskParams. Everything else is the repository fixture test/perps/BasePerpTest.sol: execution fee 4 bps, frozen-close spread 50 bps, trigger bounty 0.20 USDG, execution window 60 s, pool 1,002,000 USDG in tests 1 to 9 and 50M USDG in test 10.

Victim, attacker, keeper and bystander are plain addresses with no role. Every position is opened and closed through the production OrderRouter.commitOrder(OrderRequest) and OrderRouter.executeOrder. The fixture deploys the Router as LegacyOrderRouterHarness, which inherits OrderRouter unchanged; the PoC does not use its legacy helper. Accounts are funded by minting the mock USDG, and prices are set through the Pyth mock. The test uses cheatcodes only to set msg.sender, move time and blocks, expect reverts, record logs and take snapshots for control branches. It uses no deal and no vm.store on a contract in scope. One fixture shortcut is outside my test: BasePerpTest.setUp seeds the LP pool before the scenario starts and, while doing so, installs the first mark and settles the first LP epoch as the Router.

The victim's ceilings are my example, since the protocol has no default: in tests 1, 2, 4 to 8 and 10 they are three times the close charge that the in-scope CfdEngineLens.previewClose quotes at the stop price when the stop is armed. Test 3 varies the ceiling and test 9 uses the ratios of the project's client fixtures.

Environment setup:

  1. Install Foundry. I ran forge 1.7.1 (commit 4072e48). The program names Forge 1.5.1, which I did not have installed. Solidity 0.8.35 is downloaded by forge.
  2. Clone the repository at the commit in scope:
Bash
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether.git
cd audit-comp-plether
git checkout --detach a82d4fefb02768e5b3bddcc97dee371eee24fea8
git submodule update --init --recursive
mkdir -p packages/perps/test/poc

Reproduction:

  1. Save the following file as packages/perps/test/poc/ProtectionAmendLock.t.sol:
Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IOrderLifecycleBook} from "@plether/perps/interfaces/IOrderLifecycleBook.sol";
import {IOrderRouterErrors} from "@plether/perps/interfaces/IOrderRouterErrors.sol";
import {IPositionProtectionActions} from "@plether/perps/interfaces/IPositionProtectionActions.sol";
import {IPositionProtectionViews} from "@plether/perps/interfaces/IPositionProtectionViews.sol";
import {PositionProtectionTypes as P} from "@plether/perps/interfaces/PositionProtectionTypes.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";

/// @notice The attacker's contract. It holds no role. Each function ends the owner's current close attempt and
///         queues the next one in the same transaction, so the protection is never Latched between transactions.
contract RetryLocker {

    /// Ends a live attempt by executing it (it fails on the owner's ceiling), then retries.
    function executeAndRetry(
        OrderRouter router,
        IPositionProtectionActions book,
        uint64 attemptId,
        bytes[] calldata pythData,
        uint64 protectionId
    ) external returns (OrderV3Types.LifecycleStatus status, uint64 nextAttemptId) {
        status = router.executeOrder(attemptId, pythData).status;
        nextAttemptId = book.retryPositionProtectionClose(protectionId);
    }

    /// Ends an expired attempt without any price data, then retries.
    function clearAndRetry(
        OrderRouter router,
        IPositionProtectionActions book,
        uint64 attemptId,
        uint64 protectionId
    ) external returns (uint256 cleared, uint64 nextAttemptId) {
        uint64[] memory ids = new uint64[](1);
        ids[0] = attemptId;
        (, cleared) = router.clearInvalidOrders(ids);
        nextAttemptId = book.retryPositionProtectionClose(protectionId);
    }

}

/// @dev Shared setup. Risk parameters are the release values from packages/perps/DEPLOYMENT.md. Everything else is
///      the repository fixture BasePerpTest (execution fee 4 bps, frozen-close spread 50 bps, execution window 60 s,
///      MockPyth, mock USDG). Victim, attacker and keeper are plain addresses without roles. Every position is
///      opened and closed through the production OrderRouter.commitOrder(OrderRequest) and executeOrder.
abstract contract AmendLockBase is BasePerpTest {

    uint256 internal constant PRICE_OPEN = 1e8; // 1.00
    uint256 internal constant STOP = 110_000_000; // victim stop-loss at 1.10 (a LONG loses when the price rises)
    uint256 internal constant SIZE = 10_000e18;
    uint256 internal constant MARGIN = 2000e6;

    address internal victim = makeAddr("poc victim");
    address internal attacker = makeAddr("poc attacker");
    address internal keeper = makeAddr("poc honest keeper");
    address internal bystander = makeAddr("poc bystander");

    IPositionProtectionActions internal book;
    IPositionProtectionViews internal bookViews;
    RetryLocker internal locker;
    uint256 internal nonce;
    uint256 internal attackerDeposit;
    uint256 internal quotedCharge;

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

    function setUp() public virtual override {
        super.setUp();
        book = IPositionProtectionActions(address(router.positionProtectionBook()));
        bookViews = IPositionProtectionViews(address(book));
        _fundTrader(victim, 20_000e6);
        _refreshMark(PRICE_OPEN);
        _startRecordingLogs();
    }

    // ---------------------------------------------------------------- oracle and order helpers

    function _livePriceData(
        uint256 price
    ) internal view returns (bytes[] memory data) {
        bytes32[] memory ids = _basePythFeedIds();
        MockPyth.FeedUpdate[] memory ticks = new MockPyth.FeedUpdate[](ids.length);
        for (uint256 i; i < ids.length; ++i) {
            ticks[i] = MockPyth.FeedUpdate(
                ids[i], MockPyth.MockPrice(int64(uint64(price)), 0, -8, vm.getBlockTimestamp(), engine.lastMarkTime())
            );
        }
        data = new bytes[](1);
        data[0] = abi.encode(ticks);
    }

    function _refreshMark(
        uint256 price
    ) internal {
        if (vm.getBlockTimestamp() <= engine.lastMarkTime()) {
            vm.warp(uint256(engine.lastMarkTime()) + 1);
        }
        router.updateMarkPrice(_livePriceData(price));
    }

    /// A V3 order request with the caller's own bounds left wide open.
    function _request(
        CfdTypes.Side side,
        uint256 size,
        uint256 margin,
        bool isClose
    ) internal returns (OrderV3Types.OrderReque

The original report as published on Immunefi, by Persona404. 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 retry function is permissionless and can be called in the same transaction that ends a failed attempt, so the protection never remains in the Latched state that the owner's amend function requires.

Impact

The victim's stop-loss cannot be amended or cancelled, so the position remains open and the victim bears full price risk, potentially losing the entire margin; the attacker gains nothing.

What the attacker needed

Victim has a triggered stop-loss; victim's fee ceiling is low enough to fail; attacker can call retry in same transaction

The fix

The owner should be allowed to amend while an attempt is live, or given priority after a failed attempt, or allowed to cancel a Triggered or Latched protection into an ordinary close.

How it was found

  1. The victim's stop-loss triggers and the close attempt fails on the owner's fee ceiling, moving the protection to Latched.
  2. The attacker calls executeOrder on the failed attempt and then retryPositionProtectionClose in the same transaction, which puts the protection back into Triggered with a fresh attempt.
  3. The owner's amendLatchedPositionProtectionCloseLimits call reverts because the protection is no longer Latched.
  4. The attacker repeats this for each execution window, keeping the position open while the price moves.

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 stop-loss is an automatic order to close a position when the price hits a certain level. Here, if that automatic close fails because of fee limits, the owner is supposed to be able to change those limits and try again. But another person can repeatedly restart the failed close in the same transaction, so the owner never gets a chance to change the limits, and the position stays open while the price keeps moving.

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 Persona404

View all

1 more disclosed report, 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.