Increase commitments collect accrued carry outside the caller's gross-debit and action-charge limits, and the authenticated receipt omits it
When a trader commits an increase to an existing position, the router collects all accrued carry as a real debit but reports zero carry effects to the lifecycle book, so the caller's gross-debit and action-charge limits are never applied to that debit. The authenticated receipt also records zero commitment carry, so it under-reports the trader's actual loss.
Originally disclosed on Immunefi
- Disclosed after under an hour
#97970 [SC-Low] Increase commitments collect accrued carry outside the caller's gross-debit and action-charge limits, and the authenticated receipt omits it
Submitted on Nov 4th 2026 at 05:39:49 UTC by @tinnohofficial for Audit Competition | Plether
- Report ID: #97970
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
When a trader commits an increase to an existing position through OrderRouter.commitOrder, the Router locks the opening execution bounty with MarginClearinghouse.lockReservedSettlement. That call first checkpoints and collects all the carry the position has accrued. The open-order reservation path then reports an all-zero carry effect to OrderLifecycleBook.recordCommitment. As a result, the request's inclusive maxGrossAccountDebitAssets and maxActionChargeAssets are never applied to this debit, and the order's authenticated terminal receipt never records it.
In the PoC (release risk parameters, public entrypoints only), the request allows at most 100 USDG of action charge and 100.2 USDG of gross debit:
commitOrderdebits 301.753575 USDG of carry.- The order executes.
- Its verified receipt reports a gross account debit of 34.616454 USDG, while the account actually lost 336.370029 USDG.
The Router's own policy evaluator rejects the same request before commitment, because it counts that carry. A close with the same accrued carry and the same two limits is correctly rejected at commitment.
The carry is owed and goes to LPs, so no value is stolen. What fails is the protocol's promise that every V3 order is held to its caller's financial limits and recorded in a correct receipt. This affects every increase on a position with accrued carry, whether or not the increase is ever executed: an increase that expires unexecuted keeps the commitment-time debit, and its failure receipt also records zero. Severity: Low.
Vulnerability Details
Why this is not intended behaviour
The protocol already treats this carry as a charge of the increase. It bounds it everywhere except the one place where it is actually collected:
- The in-scope lens attributes it to the increase.
CfdEngineLens.previewOpenreturns it as the increase'spendingCarryAssets(ICfdEngineTypes.solL364). In the PoC that is 301.753575 USDG, exactly the amountcommitOrderthen debits. - The Router's policy evaluator bounds it for opens and increases.
_buildOpenAssessmentadds an existing position's pending carry togrossAccountDebitAssetsandactionChargeAssessedAssets(CfdOrderPolicyEvaluatorBase.solL342-L348). If you run the Router's configuredCfdOrderPolicyEvaluator.assessOrderon the exact request before commitment, it reverts withConstraintViolation(GrossAccountDebit, 336369905, 100200000). The account then really loses 336.370029 USDG across commit and execution. That is the evaluator's figure plus 124 atoms of carry for the seconds between the two transactions. - The same commitment-time collection is bounded and recorded for closes. ACCOUNTING_SPEC L939-L945: "Collected commitment carry is included exactly once in gross account debit, assessed/collected action charges, and carry totals for the user's financial bounds. The Book records custody before and after commitment and any carry still outstanding." The PoC control shows a close with the same carry and limits reverting with
OrderLifecycleBook__CommitmentBoundExceeded(GrossAccountDebit, 301753575, 100200000). - The normative text covers every V3 order, not only closes:
OrderV3Types.solL131-L134: "Mandatory financial authority supplied with every V3 order. Maximum values are inclusive and zero is a real zero allowance …maxGrossAccountDebitAssetscovers settlement debit, trader-claim consumption, and the reserved bounty".SECURITY.mdL756-L765: "The external V3 request sets inclusive maxima for … gross account debit, assessed action charge … Gross account debit includes settlement value lost or charged …".OrderRouter.solL77-L82: a fresh request "pins … financial limits in the immutable lifecycle book".ACCOUNTING_SPEC.mdL696-L697 lists "open/modify" among the paths that collect pending carry. L723-L724 adds: "realized carry is booked as LP trading revenue once. Receipts and financial bounds include the direct collection once".IOrderLifecycleBook.solL17-L19 defines the recorded effects as "Carry and bounty effects returned by the Engine or open-order reservation path".
- No document, NatSpec comment or known issue says that an increase's commitment-time carry is exempt from the limits or the receipt.
The open evaluator's carry term (point 2) is never applied to carry accrued before commitment. The minimum open bounty can never be zero: the defaults are 0.01 to 0.20 USDG (OrderRouterBase.sol L73-L74), and OrderRouterAdmin rejects a zero minimum (L381-L389). So every open or increase takes the lockReservedSettlement branch, and that branch collects all pre-commitment carry before any limit is checked. By execution time, only the seconds since commitment remain to be bounded.
Root cause
1. The open branch collects carry but returns zero effects. packages/perps/src/router/OrderReservationAccounting.sol L108-L128:
function _reserveExecutionBounty(address account, uint256 sizeDelta, uint256 bounty, bool isClose)
internal returns (CfdEnginePlanTypes.CloseCommitment memory effects)
{
if (isClose) {
...
return _reserveCloseExecutionBounty(account, sizeDelta); // Engine returns real carry effects
}
effects.bountyFromFreeAssets = bounty; // only field set for opens
if (bounty == 0) {
return effects;
}
if (clearinghouse.getAccountAssetBuckets(account).freeSettlementAssets < bounty) {
revert OrderRouter__InsufficientFreeEquity();
}
clearinghouse.lockReservedSettlement(account, bounty); // collects all accrued carry
}
2. The bounty lock checkpoints carry first. packages/perps/src/MarginClearinghouse.sol L818-L824:
function lockReservedSettlement(address account, uint256 amountAssets) external onlyReservedSettlementLocker {
_checkpointCarryBeforeMarginChange(account); // -> CfdEngine.realizeCarryBeforeMarginChange
_lockMargin(account, IMarginClearinghouse.MarginBucket.ReservedSettlement, amountAssets);
}
CfdEngine.realizeCarryBeforeMarginChange (L535-L550) calls _realizeCarryFromSettlement (L1407-L1449). That function consumes position margin first and then free settlement, transfers the carry to the HousePool, and records it as LP revenue. This is a real debit: in the PoC, pool assets rise by exactly 301.753575 USDG during commitOrder.
3. The Book checks the limits only against the reported carry. packages/perps/src/router/OrderCommitHandler.sol L27-L32 passes the returned effects to OrderLifecycleBook.recordCommitment (OrderLifecycleBook.sol L327-L361):
uint256 gross = effects.carryCollectedAssets + pending.executionBountyAssets; // 0 + 0.2 USDG
if (gross > pending.bounds.maxGrossAccountDebitAssets) revert ...CommitmentBoundExceeded(...);
if (effects.carryCollectedAssets > pending.bounds.maxActionChargeAssets) revert ...; // 0 > 100: false
...
pending.commitment = StoredCommitment({ carryCollectedAssets: effects.carryCollectedAssets, ... }); // stores 0
The consistency check settlementBeforeAssets == settlementAfterAssets + carryCollectedAssets also passes trivially (0 == 0 + 0), because the open path never takes a custody snapshot.
4. Execution adds commitment effects only for closes. packages/perps/src/CfdOrderPolicyEvaluator.sol L64-L67:
assessment = _assessSnapshot(context, order, pending.bounds, planner, snapshot);
if (order.isClose) {
_includeCommitment(assessment, pending.commitment, pending.bounds, pending.executionBountyAssets);
}
_includeCommitment (CfdOrderPolicyEvaluatorBase.sol L474-L487) adds commitment carry to gross debit, assessed and collected action charge, and carry, then re-enforces the bounds. For an increase, the execution snapshot is taken after the commitment debit, so the evaluator sees only the carry accrued after commitment.
5. The receipt copies both incomplete sources. OrderRouterExecutionSidecar.sol L717 copies the stored zero commitment into receipt.commitment. _assessmentEconomics (L781-L799) copies the execution-only assessment and the post-commitment preSettlementBalanceAssets. So the authenticated receipt cannot reconstruct the debit, even from its own pre/post balances.
No other caller limit can stop it
For an increase, the two bypassed fields are the only debit ceilings available. A positive minPostSettlementBalanceAssets is rejected for any account that already has a position (OrderLiquidationBatchLogic.sol L307-L312; WORKING_WITH_AI_AGENTS.md L114-L116: "It is rejected for increases, closes, and overlapping orders"). The PoC confirms that an increase with a positive settlement floor reverts with OrderRouter__SettlementFloorUnsupported. The equity and leverage bounds measure risk, not cost. Fresh opens from a flat account have no carry, so increases are the affected class.
Sequence (PoC numbers)
- A trader holds a 300,000 USDG LONG with 20,000 USDG margin (about 15x, against a 500x maximum) and does not touch its margin for four weeks. At release
baseCarryBps = 500with a 1,000,000 USDG Junior pool, 301.753575 USDG of carry accrues, about 10.8 USDG per day. - The trader commits a 10,000 USDG increase with
maxActionChargeAssets = 100 USDGandmaxGrossAccountDebitAssets = 100.2 USDG(100 plus the 0.20 USDG bounty). commitOrdercollects 301.753575 USDG. The Book records commitment carry 0, carry outstanding 0,settlementAfterAssets0, and bounty 0.2 USDG.- A public keeper executes the order. It succeeds and the position becomes 310,000.
- The verified
OrderFinalizedreceipt showscommitment.carryCollectedAssets = 0,economics.carryAssets = 0.000124,actionChargeAssessedAssets = 34.416454andgrossAccountDebitAssets = 34.616454. All appear to be within the limits. The real debit was 336.370029 USDG.
After only one week of carry (75.438487 USDG), a 50 USDG action limit on the same increase is bypassed in the same way. The increase's own trade cost is 34.423196 USDG, well within the limit.
The debit does not depend on execution. In test_UnexecutedIncreaseKeepsCommitmentCarryAndItsFailureReceiptOmitsIt the same bounded increase is never executed and is expired by any caller after its deadline, leaving the position unchanged. The 301.753575 USDG taken at commitment stays with LPs, and the authenticated failure receipt reports commitment.carryCollectedAssets = 0 and grossAccountDebitAssets = 0. A trader whose increase never happens still pays a charge above its limits that no receipt records.
Impact Details
- The caller's financial limits are not enforced. On every increase of a position with accrued carry,
maxGrossAccountDebitAssetsandmaxActionChargeAssetsdo not apply to that carry, even though the protocol's lens and evaluator count it as part of the increase. The debit is unbounded and grows linearly with the time since the position was last checkpointed. An increase that its caller authorised only under a ceiling executes even though the actual charge exceeds that ceiling several times over (more than 3x in the PoC: 336.370029 against 100.2 USDG). The settlement floor cannot be used as a substitute, because it is unavailable to increases. - The authenticated receipt is wrong. The integration docs tell integrators to authenticate the receipt and treat it as the order's on-chain history (
CLOSE_PREVIEW.mdL55: "verified lifecycle receipts for history"; L109: "terminal receipts establish what happened on-chain";WORKING_WITH_AI_AGENTS.mdL298-L312). For every increase, the receipt reports zero commitment carry and a gross debit that leaves out the commitment-time collection (34.616454 vs 336.370029 USDG in the PoC). ItspreSettlementBalanceAssetsis already net of that collection. Accounting, fee reporting or limit monitoring built on receipts under-reports trader debits. - What is not claimed. The carry was owed, and it reaches LPs in full (pool assets rise by exactly the collected amount). Health projections already deduct pending carry (
ACCOUNTING_SPEC.mdL698-L699, L706-L707, L751-L752), so the early collection does not move the position toward liquidation, and this report claims no liquidation impact. No third party can trigger it on someone else's account.
Severity: Low. Impact: "Contract fails to deliver promised returns, but doesn't lose value". The documented financial-authority and receipt guarantees fail, without loss of value.
Recommendation
- In
OrderReservationAccounting._reserveExecutionBounty, return the real carry and custody effects for the open/increase branch. Either snapshotbalanceAssets,freeSettlementAssetsandunsettledCarryAssetsaroundlockReservedSettlement, or let the Engine checkpoint carry and return aCloseCommitment, as the close path already does. PopulatecarryCollectedAssets,carryOutstandingAssets,settlementBeforeAssets,settlementAfterAssetsandfreeSettlementAfterAssets.recordCommitmentwill then reject an excessive commitment debit atomically, exactly as it does for closes. - In
CfdOrderPolicyEvaluator.assessCommittedOrder, apply_includeCommitmentto opens as well as closes (remove theif (order.isClose)guard). Commitment-time and execution-time carry are then enforced against one lifecycle-wide limit and reported once in the receipt. - Add regression tests:
- commitment carry alone exceeds each limit;
- commitment carry and execution charges are each below a limit but exceed it together;
- an executed increase's receipt reconciles exactly to the account and pool balance changes.
Skipping the carry checkpoint in lockReservedSettlement is not a good fix. It would change the documented carry-before-margin-mutation order.
References
- Open-branch reservation returns zero carry: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/router/OrderReservationAccounting.sol#L108-L128
- Commit handler records the returned effects: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/router/OrderCommitHandler.sol#L21-L36
lockReservedSettlementcheckpoints carry: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/MarginClearinghouse.sol#L812-L824- Clearinghouse to Engine carry hook: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/MarginClearinghouse.sol#L1336-L1356
- Engine carry realization: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngine.sol#L535-L550 and https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngine.sol#L1407-L1449
- Close-path commitment returns real effects: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngine.sol#L592-L625
- Book commitment bound checks: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderLifecycleBook.sol#L327-L361
- Commitment effects included only for closes: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdOrderPolicyEvaluator.sol#L64-L67
- Open assessment counts pending carry against the limits: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdOrderPolicyEvaluatorBase.sol#L340-L348
_includeCommitment: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdOrderPolicyEvaluatorBase.sol#L474-L487- Receipt copies the stored commitment and the execution assessment: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L703-L718 and https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterExecutionSidecar.sol#L781-L799
ExecutionBoundsNatSpec: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderV3Types.sol#L131-L150commitOrderNatSpec: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouter.sol#L77-L82recordCommitmentinterface NatSpec: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/interfaces/IOrderLifecycleBook.sol#L17-L23- Settlement floor rejected for increases: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/router/OrderLiquidationBatchLogic.sol#L307-L312
- Minimum open bounty is always nonzero: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/router/OrderRouterBase.sol#L70-L75 and https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/OrderRouterAdmin.sol#L381-L389
previewOpenandOpenPreview.pendingCarryAssets: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngineLens.sol#L92-L100 and https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/interfaces/ICfdEngineTypes.sol#L350-L380- ACCOUNTING_SPEC carry rules ("open/modify", "Receipts and financial bounds include the direct collection once"): https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md#L690-L726
- ACCOUNTING_SPEC close commitment carry included in the bounds: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md#L939-L945
- SECURITY pinned financial policy: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/SECURITY.md#L754-L765
- Settlement floor restrictions for integrators: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/WORKING_WITH_AI_AGENTS.md#L114-L119
- Closing positions, commitment carry included in totals: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/CANONICAL_ENTRYPOINTS.md#L98-L104
Proof of Concept
Proof of Concept
A single Foundry test file runs against the unmodified audit commit (a82d4fefb02768e5b3bddcc97dee371eee24fea8) using the repository's own BasePerpTest harness.
Setup
- Release risk parameters, asserted in
setUp: VPI 0.01e18, max skew 0.4e18, maintenance/initial/FAD margin 10/20/300 bps,baseCarryBps500, execution fee 4 bps, frozen spread 50 bps, confidence ratio 10 bps with a 2,500 multiplier. - Public paths only. A 1,000,000 USDG Junior pool is funded through the public asynchronous ERC-7540 deposit flow (
requestDeposit->settleLpEpoch->claimDeposit). The trader deposits throughMarginClearinghouse.deposit. All orders use the production V3OrderRouter.commitOrder(OrderRequest)entrypoint and are executed by an unrelated keeper EOA throughexecuteOrder. The mark is installed through the publicupdateMarkPrice. - Mocks. MockPyth only supplies signed-price fixture data; Pyth is out of scope. No call is pranked as a protocol contract. The harness Router is
LegacyOrderRouterHarness is OrderRouter; that subclass only adds a legacy scalarcommitOrderoverload, which this PoC does not use. - Position. The trader opens a 300,000 USDG LONG with 20,000 USDG margin and then does not touch its margin. Time advances while keeping the same weekday and hour, so the market stays live.
Tests
| Test | What it shows |
|---|---|
test_Control_CloseWithSameLimitsIsRejectedAtCommitment |
Control. After 28 days, a full close with the same limits (100 USDG action charge, 100.2 USDG gross debit) reverts with OrderLifecycleBook__CommitmentBoundExceeded(GrossAccountDebit, 301753575, 100200000). Trader and pool balances roll back. |
test_IncreaseCommitmentCollectsCarryAboveLimitsAndReceiptOmitsIt |
The bug. The steps are below. |
test_SettlementFloorIsUnavailableToIncreases |
A positive minPostSettlementBalanceAssets on an increase reverts with OrderRouter__SettlementFloorUnsupported, so no other caller limit can cap the debit. |
test_OneWeekOfCarryExceedsAFiftyUsdgLimit |
Realism. After only 7 days, 75.438487 USDG is collected at commitment despite a 50 USDG action limit. The increase's own quoted trade cost is 34.423196 USDG. The order executes and the receipt reports 34.423319 USDG. |
test_UnexecutedIncreaseKeepsCommitmentCarryAndItsFailureReceiptOmitsIt |
Breadth. The same 10,000 USDG increase is never executed; any caller expires it after its deadline and the position is unchanged. The 301.753575 USDG of carry taken at commitment is not returned (pool assets keep the full amount), and the authenticated failure receipt reports commitment carry 0 and gross account debit 0. |
Steps in test_IncreaseCommitmentCollectsCarryAboveLimitsAndReceiptOmitsIt (same account and time as the control, a 10,000 USDG increase):
-
CfdEngineLens.previewOpenattributes 301.753575 USDG of pending carry to this increase. -
The Router's configured
CfdOrderPolicyEvaluator.assessOrder, run on the same request before commitment, rejects it:ConstraintViolation(GrossAccountDebit, 336369905, 100200000). -
commitOrdersucceeds anyway and debits exactly 301.753575 USDG. HousePool assets rise by the same amount. The Book stores commitment carry 0, carry outstanding 0,settlementAfterAssets0, and bounty 0.2 USDG. -
The keeper executes the order, and the position becomes 310,000.
-
The verified
OrderFinalizedreceipt reports:commitment.carryCollectedAssets = 0;economics.carryAssets = 124atoms;actionChargeAssessedAssets = 34.416454 USDG;grossAccountDebitAssets = 34.616454 USDG;- a
preSettlementBalanceAssetsalready net of the commitment debit.
Across commit and execution, the trader actually lost 336.370029 USDG. That is the evaluator's 336.369905 USDG plus 124 atoms of carry accrued between the two transactions.
How to run
Save the file below as packages/perps/test/poc/IncreaseCommitmentCarryBypassesFinancialBounds.t.sol in the audit repository, then run from the repository root:
forge test --root packages/perps --match-path test/poc/IncreaseCommitmentCarryBypassesFinancialBounds.t.sol -vv
Output
The test was run twice. Logs and gas figures were identical; only the wall-clock timings differ. Compiler warnings printed before the results come from pre-existing repository and forge-std code and are omitted.
Run 1:
Ran 5 tests for test/poc/IncreaseCommitmentCarryBypassesFinancialBounds.t.sol:IncreaseCommitmentCarryBypassesFinancialBoundsTest
[PASS] test_Control_CloseWithSameLimitsIsRejectedAtCommitment() (gas: 1506322)
Logs:
close: accrued carry (actual reported by Book) 301753575
close: caller maxGrossDebit 100200000
[PASS] test_IncreaseCommitmentCollectsCarryAboveLimitsAndReceiptOmitsIt() (gas: 3778983)
Logs:
pre-commit lens pendingCarryAssets 301753575
pre-commit policy gross debit (rejected) 336369905
caller maxActionCharge 100000000
caller maxGrossDebit 100200000
carry debited at commitment 301753575
Book commitment carryCollectedAssets 0
Book commitment settlementAfterAssets 0
Book commitment bountyFromFreeAssets 200000
receipt commitment.carryCollectedAssets 0
receipt economics.carryAssets 124
receipt economics.actionChargeAssessedAssets 34416454
receipt economics.grossAccountDebitAssets 34616454
receipt economics.preSettlementBalanceAssets 99128944629
settlement balance before commit 99430698204
actual total settlement debit, commit + execution 336370029
[PASS] test_OneWeekOfCarryExceedsAFiftyUsdgLimit() (gas: 3609440)
Logs:
one week: quoted trade cost (fee + VPI) 34423196
one week: caller maxActionCharge 50000000
one week: carry debited at commitment 75438487
one week: receipt actionChargeAssessedAssets 34423319
[PASS] test_SettlementFloorIsUnavailableToIncreases() (gas: 386620)
[PASS] test_UnexecutedIncreaseKeepsCommitmentCarryAndItsFailureReceiptOmitsIt() (gas: 2484584)
Logs:
expired: caller maxActionCharge 100000000
expired: carry debited at commitment 301753575
expired: trader settlement debit after expiry 301953575
expired: LP pool asset increase 301753575
expired: receipt commitment.carryCollectedAssets 0
expired: receipt economics.grossAccountDebitAssets 0
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 10.29ms (8.48ms CPU time)
Ran 1 test suite in 11.01ms (10.29ms CPU time): 5 tests passed, 0 failed, 0 skipped (5 total tests)
Run 2:
Ran 5 tests for test/poc/IncreaseCommitmentCarryBypassesFinancialBounds.t.sol:IncreaseCommitmentCarryBypassesFinancialBoundsTest
[PASS] test_Control_CloseWithSameLimitsIsRejectedAtCommitment() (gas: 1506322)
Logs:
close: accrued carry (actual reported by Book) 301753575
close: caller maxGrossDebit 100200000
[PASS] test_IncreaseCommitmentCollectsCarryAboveLimitsAndReceiptOmitsIt() (gas: 3778983)
Logs:
pre-commit lens pendingCarryAssets 301753575
pre-commit policy gross debit (rejected) 336369905
caller maxActionCharge 100000000
caller maxGrossDebit 100200000
carry debited at commitment 301753575
Book commitment carryCollectedAssets 0
Book commitment settlementAfterAssets 0
Book commitment bountyFromFreeAssets 200000
receipt commitment.carryCollectedAssets 0
receipt economics.carryAssets 124
receipt economics.actionChargeAssessedAssets 34416454
receipt economics.grossAccountDebitAssets 34616454
receipt economics.preSettlementBalanceAssets 99128944629
settlement balance before commit 99430698204
actual total settlement debit, commit + execution 336370029
[PASS] test_OneWeekOfCarryExceedsAFiftyUsdgLimit() (gas: 3609440)
Logs:
one week: quoted trade cost (fee + VPI) 34423196
one week: caller maxActionCharge 50000000
one week: carry debited at commitment 75438487
one week: receipt actionChargeAssessedAssets 34423319
[PASS] test_SettlementFloorIsUnavailableToIncreases() (gas: 386620)
[PASS] test_UnexecutedIncreaseKeepsCommitmentCarryAndItsFailureReceiptOmitsIt() (gas: 2484584)
Logs:
expired: caller maxActionCharge 100000000
expired: carry debited at commitment 301753575
expired: trader settlement debit after expiry 301953575
expired: LP pool asset increase 301753575
expired: receipt commitment.carryCollectedAssets 0
expired: receipt economics.grossAccountDebitAssets 0
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 10.00ms (8.99ms CPU time)
Ran 1 test suite in 10.54ms (10.00ms CPU time): 5 tests passed, 0 failed, 0 skipped (5 total tests)
Test file
// 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 {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {ICfdOrderPolicyEvaluator} from "@plether/perps/interfaces/ICfdOrderPolicyEvaluator.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 {console2} from "forge-std/console2.sol";
/// @notice An open/increase commitment locks the execution bounty through
/// `MarginClearinghouse.lockReservedSettlement`, which checkpoints and collects the position's accrued carry.
/// `OrderReservationAccounting._reserveExecutionBounty` then hands the lifecycle Book an all-zero carry effect,
/// so the request's inclusive `maxGrossAccountDebitAssets` / `maxActionChargeAssets` are never applied to that
/// debit, and the authenticated terminal receipt never reports it. A close with the same accrued carry and the
/// same limits is correctly rejected at commitment.
/// @dev Release risk parameters. Every protocol action goes through a public entrypoint from an EOA; MockPyth only
/// supplies signed-price fixture data. The Router is the production `OrderRouter` (the test subclass only adds an
/// unused legacy overload); the V3 `commitOrder(OrderRequest)` entrypoint is called directly.
contract IncreaseCommitmentCarryBypassesFinancialBoundsTest is BasePerpTest {
address internal constant LP = address(0x1A11CE);
address internal constant TRADER = address(0x7A0E);
address internal consta
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 open/increase reservation branch collects accrued carry via the clearinghouse but returns an all-zero carry effect, so the commitment bound checks and the stored receipt never see the debit.
Impact
The caller's financial limits are not enforced on commitment-time carry and the authenticated receipt under-reports the debit, though the carry is owed and reaches LPs so no value is lost.
What the attacker needed
An existing position with accrued carry; trader submits an increase order; a keeper executes or the order expires
The fix
The open/increase reservation branch should return the real carry and custody effects so the commitment bounds reject excessive debits, and the commitment effects should be included for opens as well as closes.
How it was found
- A trader holds a large long position with margin untouched for weeks, so carry accrues.
- The trader commits a small increase with tight action-charge and gross-debit limits.
- commitOrder collects the accrued carry but the book records zero commitment carry.
- A keeper executes the order and the position grows.
- The finalised receipt reports zero commitment carry and a gross debit far below the real loss.
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 maximum amount they are willing to be charged when placing an order. Here, a particular charge (called carry, a fee that builds up over time on an open position) is taken from the trader's balance when they increase their position, but the code forgets to count it against that maximum. The receipt the trader gets afterwards also shows zero for that charge, so the numbers do not match what actually left their account.
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.