Trigger-bounty carry checkpoint lets an owner-triggered protected close exceed its stored charge ceilings
When the owner of a take-profit/stop-loss protection triggers it herself, the trigger bounty credit checkpoints her accrued carry inside the same transaction that queues the close, so the evaluator only sees the close's own charges. The close then executes even though trigger carry plus close charges exceed the stored maxActionChargeAssets and maxGrossAccountDebitAssets ceilings, which a third-party trigger would have enforced.
Originally disclosed on Immunefi
- Disclosed after under an hour
#99862 [SC-Low] Trigger-bounty carry checkpoint lets an owner-triggered protected close exceed its stored charge ceilings
Submitted on Nov 15th 2026 at 14:34:02 UTC by @songthuy307 for Audit Competition | Plether
- Report ID: #99862
- 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
A take-profit/stop-loss protection stores four close ceilings chosen by its owner. The documentation says they bound each protected close attempt, "including commitment charges". When the owner herself calls triggerPositionProtection, the trigger bounty is credited back to her through CfdEngine.creditBounty, which first checkpoints the beneficiary's carry. The carry accrued on her position is therefore collected inside the trigger transaction, after the close attempt has been queued, and it is neither bounded by the ceilings nor recorded for that attempt. The evaluator then sees only the charges of the close itself, so the close executes although trigger carry plus close charges exceed maxActionChargeAssets and maxGrossAccountDebitAssets. In the PoC the same protection triggered by another address fails on the ceiling, and a 100 USDG action-charge ceiling does not stop a protected close for which 163.33 USDG is collected: 75.33 USDG of carry in the trigger transaction and 88.00 USDG at execution. The PoC shows this with the repository's test parameters and again with the release risk parameters. No value is lost, because the carry was owed. What fails is the documented ceiling. Only the owner's own trigger call has this effect; a third party cannot cause it.
Code reviewed at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8 (in-scope freeze). Paths are relative to packages/perps/.
Vulnerability Details
1. What the ceilings promise.
- A protection "must explicitly supply" four close limits; each is "a
uint256ceiling in 6-decimal USDG units for future triggered or retried close attempts" (CANONICAL_ENTRYPOINTS.md:121-126). maxGrossAccountDebitAssetsis the "Maximum aggregate settlement debit, consumed trader claims, and reserved bounty", andmaxActionChargeAssetsis the "Maximum assessed action charge after carry, signed virtual price impact (VPI), fees, and frozen spread are combined" (WORKING_WITH_AI_AGENTS.md:102-103).- "These limits apply per attempt, including commitment charges, not cumulatively across retries. If commitment would exceed a limit, triggering reverts and the owner can replace the
Armedprotection." (WORKING_WITH_AI_AGENTS.md:282-283) - The paragraph that defines the ceilings ends: "The separately reserved trigger bounty is paid when the protection fires; these ceilings apply to its generated close attempt." (
CANONICAL_ENTRYPOINTS.md:125-126) It names the trigger bounty as the amount paid at trigger time outside the ceilings. It does not mention carry.
2. A trigger by another account leaves the carry to be assessed with the close.
The specification describes this transition directly. ACCOUNTING_SPEC.md lists "Protection trigger/retry" with the accounting "Queue through the protection path without ordinary commitment carry effects" and the note "carry is assessed at execution" (ACCOUNTING_SPEC.md:954). The integration guide says: "A trigger or retry queues a new close without ordinary commitment carry effects; its execution still settles carry." (CANONICAL_ENTRYPOINTS.md:112-113)
That is what happens when anyone other than the owner triggers. The trigger queues the close attempt with a zero bounty record and no commitment (OrderRouter.sol:440-472) and pays the trigger bounty to the caller. The owner's accrued carry stays pending. At execution the evaluator assesses it together with the close: carry is part of both grossAccountDebitAssets and actionChargeAssessedAssets (CfdOrderPolicyEvaluatorBase.sol:409-415). If the total exceeds a ceiling, the attempt fails with ConstraintViolation and the protection relatches.
3. A trigger by the owner moves the carry outside the ceilings.
triggerPositionProtectionforwardsmsg.senderas the bounty recipient (PositionProtectionBook.sol:371-379); the Router decodes it asrefundRecipient(OrderLiquidationBatchLogic.sol:593-601).- The trigger branch activates the protection, queues the attempt and only then calls
engine.creditBounty(plan.account, refundRecipient, ...)(OrderLiquidationBatchLogic.sol:611-620). creditBountycalls_checkpointBountyRecipient(beneficiary, ...)before the transfer (CfdEngine.sol:471-493). If the beneficiary has a position, this realizes its accrued carry from settlement (CfdEngine.sol:203-217).- When the beneficiary is
plan.account, the owner's accrued carry is collected here, as far as her margin and free settlement cover it. The attempt's commitment keepscarryCollectedAssets == 0, and that field is the only commit-time carry the evaluator adds back (CfdOrderPolicyEvaluator.sol:65-67,CfdOrderPolicyEvaluatorBase.sol:474-487).
The close is therefore assessed without the carry and executes. The carry was charged in the same transaction that created the attempt, but it is not counted against the ceilings stored for it. For an owner trigger, "carry is assessed at execution" does not hold: the trigger transaction itself collects her carry, and nothing is left for the execution to assess.
4. Elsewhere the code base avoids this checkpoint when a bounty returns to its own source.
creditBounty documents why it checkpoints: "For a beneficiary with an open position, carry is checkpointed before the settlement credit changes reachable collateral." (CfdEngine.sol:461-462) For a bounty that returns to the account that funded it, the clearinghouse has a separate function. Its NatSpec reads: "Releases a settled order or protection-trigger bounty back to the same account that funded it. [...] Unlike the general Engine bounty-credit path, this exact self-transfer changes only the reserved classification and deliberately skips carry checkpointing. [...] Atomic protection cancellation uses this before bounded close carry collection." (MarginClearinghouse.sol:716-732)
The Router uses that function in three places where a bounty goes back to its source account:
- Terminal order settlement, when the bounty recipient is the order's own account (
OrderRouter.sol:333-343). - Recovery of an expired order's bounty (
OrderRouter.sol:217-222). - Cancel-and-close of an armed protection, where the comment gives the reason in terms of the close bounds: "Release it without a carry checkpoint so all commitment carry is collected, bounded and recorded by the ordinary close path below." (
OrderLiquidationBatchLogic.sol:174-181)
For the cancel-and-close path the same intent is stated three more times:
SECURITY.md: "The Router releases the unused trigger bounty without checkpointing carry before ordinary close commitment. All commitment carry is then collected and recorded by the canonical close path, including its gross-debit and action-charge bounds" (SECURITY.md:535-539).- The team's response to Cecuro MED-30: "commitment carry is collected and checked against the close limits" (audit report p. 69).
- The repository's tests
test_CancelAndCommitClose_AccruedCarryCannotBypassGrossDebitBoundandtest_CancelAndCommitClose_AccruedCarryCannotBypassActionChargeBound. They assert that accrued carry is counted against the close's gross-debit and action-charge bounds when a protection is cancelled and closed in one call (PositionProtection.t.sol:1969-2007).
The trigger branch does not use it. When the trigger caller is the account that funded the protection-trigger bounty, the bounty goes through the general creditBounty path. A plain cancellation of an armed protection also checkpoints carry when it releases the bounty (MarginClearinghouse.sol:826-839), but it creates no close. The trigger does: the checkpoint happens inside the entrypoint that creates the bounded close, which is the kind of bypass those two tests exclude for cancel-and-close.
5. Relation to earlier findings and documentation.
- The ceilings were introduced by the fix for Cecuro MED-9 ("Keepers can retry protection closes without the trader's financial limits", audit report p. 27). The team's response says the protection "copies them into both the initial close and every permissionless retry". The copy is correct, and this report is not MED-9. It concerns the mechanism that fix introduced: for an owner-triggered attempt, carry collected by the trigger transaction stays outside the copied ceilings.
- The checkpoint on a bounty credit is itself documented and tested.
ACCOUNTING_SPEC.mdstates that "keeper bounty credits first collect all available margin and free settlement toward carry" (ACCOUNTING_SPEC.md:702-705),SECURITY.mdsays the same for claim and bounty credits (SECURITY.md:954-957), and the Engine testtest_SelfBountyProtectsReserveThenReleasesFullCreditcallscreditBountywith the same account as source and beneficiary (CarryCreditCheckpoint.t.sol:275-289). None of these covers the interaction reported here. They do not say that carry collected this way is outside the ceilings of a close queued in the same transaction, and I found no repository test in which the protection owner is the trigger caller. - An owner can also realize her carry deliberately before a close, for example with a zero-amount withdrawal;
SECURITY.mdmentions these "User-triggered checkpoints, including zero-amount withdrawals" (SECURITY.md:1423-1427). That is a separate action she chooses. Here the checkpoint is a side effect of the trigger entrypoint itself, inside the transaction that creates the bounded attempt, which is the situation the cancel-and-close path was written to avoid. - For transparency: my earlier report in this competition (confirmed, Low) covers carry collected at the commit of a public V3 open/increase, which escapes that order's signed bounds. This report is related but concerns a different defect. The entrypoint is
triggerPositionProtection, notcommitOrder. The sink isCfdEngine.creditBountyand_checkpointBountyRecipient, not the clearinghouse checkpoint taken when order margin is locked. The bypassed limits are the protection's stored close ceilings, not an order's request bounds. The fix is different, and fixing either one leaves the other in place. - The behaviour is not listed in
SECURITY.md"Known Limitations" or "Router and keeper limitations". The AI scan finding "Protection trigger bounty is paid before a zero-bounty close is executed" is about keeper incentives after the bounty is paid; it does not mention the carry checkpoint.
Limits of the issue.
- It occurs only when the trigger caller is the owner's own account, for example an owner who runs her own trigger bot so that she does not depend on third-party keepers, or to keep the trigger bounty. A third party cannot cause it.
- The carry is owed in any case, so nobody loses value. The effect is that the ceilings the owner stored do not bound what is collected from her for the protected close, and the close executes where a trigger by anyone else would have failed and left the decision to her.
- It affects
maxActionChargeAssetsandmaxGrossAccountDebitAssets, the two ceilings that include carry.maxGrossAccountDebitAssetsadds the carry in full. FormaxActionChargeAssetsthe evaluator nets a VPI rebate against the carry (CfdOrderPolicyEvaluatorBase.sol:562-572), so a close that earns a VPI rebate at least as large as its carry is not affected on that ceiling.
Impact Details
Selected impact: Contract fails to deliver promised returns, but doesn't lose value (Low).
The contract does not deliver a documented guarantee: the owner's stored ceilings are meant to bound each protected close attempt including the charges taken when it is created, and for an owner-triggered attempt they do not.
Numbers from the PoC with the repository's test risk parameters (Alice: LONG 200,000 USDG notional at 1.00, 60,000 USDG margin, stop-loss at 1.10, position held 28 days; accrued carry 75.33 USDG; execution fee of the close 88.00 USDG):
maxActionChargeAssets = 100 USDG.- Trigger by a keeper: the evaluator assesses 163.33 USDG (carry 75.33 + fee 88.00) against the ceiling and rejects the attempt with
ConstraintViolation(ActionCharge, 163.328469, 100.000000). The protection relatches and the position stays open. - Trigger by Alice: the trigger transaction debits 75.33 USDG of carry. The evaluator then assesses 88.00 USDG and the close executes. Collected in total across the trigger and the close: 163.33 USDG, 63.33 USDG above her ceiling.
- Trigger by a keeper: the evaluator assesses 163.33 USDG (carry 75.33 + fee 88.00) against the ceiling and rejects the attempt with
maxGrossAccountDebitAssets = 20,100 USDG.- Trigger by a keeper: 20,163.33 USDG assessed (price loss 20,000 + carry 75.33 + fee 88.00), rejected.
- Trigger by Alice: 20,088.00 USDG assessed, executed. Total across the trigger and the close: 20,163.33 USDG.
The PoC repeats the four tests with the release risk parameters from DEPLOYMENT.md (DEPLOYMENT.md:128-151): VPI factor 0.01e18, maintenance margin 10 bps, initial margin 20 bps. The execution fee and the trigger bounty already have their release values in the fixture. In that run a second trader holds a larger SHORT, so that Alice's close is assessed a VPI charge and not a rebate. Accrued carry is 75.23 USDG:
maxActionChargeAssets = 600 USDG. A keeper trigger is rejected at 646.21 USDG. Alice's trigger debits 75.23 USDG of carry, the evaluator assesses 570.97 USDG and the close executes. Total across the trigger and the close: 646.21 USDG.maxGrossAccountDebitAssets = 20,600 USDG. A keeper trigger is rejected at 20,646.21 USDG. After Alice's trigger the evaluator assesses 20,570.97 USDG and the close executes. Total across the trigger and the close: 20,646.21 USDG.
In both parameter sets the amount outside the ceiling is the carry accrued since the position's last checkpoint and collected by the trigger transaction, so it grows with position size, utilization and holding time.
References
- Trigger path:
PositionProtectionBook.sol:371-379,OrderLiquidationBatchLogic.sol:593-601,OrderLiquidationBatchLogic.sol:611-620,OrderRouter.sol:440-472. - Carry checkpoint on bounty credit:
CfdEngine.sol:461-462,CfdEngine.sol:471-493,CfdEngine.sol:203-217. - Evaluator:
CfdOrderPolicyEvaluator.sol:65-67,CfdOrderPolicyEvaluatorBase.sol:409-415,CfdOrderPolicyEvaluatorBase.sol:474-487,CfdOrderPolicyEvaluatorBase.sol:562-572. - Own-account bounty release without a checkpoint:
MarginClearinghouse.sol:716-732,OrderRouter.sol:333-343,OrderRouter.sol:217-222,OrderLiquidationBatchLogic.sol:174-181. - Release parameters:
DEPLOYMENT.md:128-151. - Documentation:
CANONICAL_ENTRYPOINTS.md:121-126,WORKING_WITH_AI_AGENTS.md:102-103,WORKING_WITH_AI_AGENTS.md:282-283,CANONICAL_ENTRYPOINTS.md:125-126,SECURITY.md:535-539,SECURITY.md:954-957,SECURITY.md:1423-1427,ACCOUNTING_SPEC.md:954,CANONICAL_ENTRYPOINTS.md:112-113,ACCOUNTING_SPEC.md:702-705. - Repository tests: the cancel-and-close bound tests
PositionProtection.t.sol:1969-2007; the Engine self-bounty testCarryCreditCheckpoint.t.sol:275-289. - Cecuro AI audit, MED-9 and the team response:
audits/plether-ai-audit-report-2026-10-26.pdf, pp. 27-28; MED-30 team response, p. 69.
Recommendation
Either of the following closes the gap:
- In the trigger branch, when
refundRecipient == plan.account, return the trigger bounty withreleaseReservedExecutionBountyToSource(no carry checkpoint), as terminal order settlement andcommitProtectedClosealready do. The carry then stays pending and is assessed against the ceilings at execution. - Alternatively, record the carry collected by the trigger transaction in the attempt's commitment so that
_includeCommitmentcounts it, and revert the trigger when it exceeds a ceiling, as the documentation describes.
Proof of Concept
Runs in the repository's own Foundry suite at the in-scope commit. The PoC contract inherits the repository's PositionProtectionTest (packages/perps/test/perps/spec/trader/PositionProtection.t.sol) to reuse its fixtures and helpers. BasePerpTest deploys the in-scope contracts unmodified, with mocked Pyth updates and mock USDG only, which the rules allow because both are out of scope. Its Router is the repository's LegacyOrderRouterHarness, a test-only subclass of the production OrderRouter that adds a legacy commitOrder overload; the PoC does not call it. The fixture helpers _fundTrader and _open fund Alice and create her position (_open is the repository helper that books the position directly through the Engine). Everything after that uses production entrypoints only: createPositionProtection, triggerPositionProtection, executeOrder, and the public view CfdOrderPolicyEvaluator.assessCommittedOrder.
The file contains two contracts. ProtectionOwnerTriggerCarryPocTest runs on the repository's test risk parameters (zero VPI factor). ProtectionOwnerTriggerCarryReleaseParamsPocTest repeats the same four tests with the release risk parameters from packages/perps/DEPLOYMENT.md (VPI factor 0.01e18, maintenance margin 10 bps, initial margin 20 bps; the 4 bps execution fee and the 0.20 USDG trigger bounty already have their release values in the fixture). With a non-zero VPI factor the evaluator nets a VPI rebate against carry in the assessed action charge, so in the release contract Bob 0xB0B holds a larger SHORT first and Alice's close is assessed a VPI charge instead of a rebate. In each contract the two tests of a pair differ only in who calls the trigger.
Save the file below as packages/perps/test/perps/spec/trader/ProtectionOwnerTriggerCarryPoc.t.sol and run:
cd packages/perps
forge test --match-path test/perps/spec/trader/ProtectionOwnerTriggerCarryPoc.t.sol --match-test "test_(Control|Poc)_" -vv
--match-test selects the four PoC tests of each contract, because both contracts also inherit the repository's own protection tests.
Setup of the first contract (test parameters): Alice 0xA11CE opens LONG 200,000 USDG notional at 1.00 with 60,000 USDG margin and arms a stop-loss at 1.10 with one finite close ceiling. The position is held for 28 days, during which 75.33 USDG of carry accrues. The market then trades at 1.10; the protected close has an 88.00 USDG execution fee and a 20,000 USDG price loss.
test_Control_ThirdPartyTriggerFailsOnActionChargeCeiling(maxActionChargeAssets = 100 USDG): the keeper0x7106triggers. Alice pays only the reserved 0.20 USDG trigger bounty and her carry stays pending. The production evaluator rejects the attempt withConstraintViolation(ActionCharge, 163.328469, 100.000000); the test reads these values from the evaluator's revert data and also checks that the amount without the carry would be inside the ceiling. ThenexecuteOrderterminalizes it asFailed / ConstraintViolation, the protection isLatchedand the position is still open.test_Poc_OwnerTriggerExecutesAboveActionChargeCeiling(same ceiling): Alice triggers. The trigger transaction debits 75.33 USDG of carry from her account, the attempt recordscarryCollectedAssets == 0, the evaluator assesses 88.00 USDG, andexecuteOrderexecutes the close. Trigger carry plus close charge is 163.33 USDG against a 100 USDG ceiling.test_Control_ThirdPartyTriggerFailsOnGrossDebitCeiling(maxGrossAccountDebitAssets = 20,100 USDG): as test 1; the evaluator rejects 20,163.33 USDG.test_Poc_OwnerTriggerExecutesAboveGrossDebitCeiling(same ceiling): as test 2; the evaluator assesses 20,088.00 USDG and the close executes. The total is 20,163.33 USDG.
The release-parameter contract runs the same four tests with Bob's SHORT of 300,000 USDG notional opened first, and with ceilings of 600 USDG (maxActionChargeAssets) and 20,600 USDG (maxGrossAccountDebitAssets). Accrued carry is 75.23 USDG. The keeper-triggered attempts are rejected at 646.21 USDG and 20,646.21 USDG. After Alice's own trigger the evaluator assesses 570.97 USDG and 20,570.97 USDG, and both closes execute.
Output:
Ran 4 tests for test/perps/spec/trader/ProtectionOwnerTriggerCarryPoc.t.sol:ProtectionOwnerTriggerCarryPocTest
[PASS] test_Control_ThirdPartyTriggerFailsOnActionChargeCeiling() (gas: 3132170)
Logs:
third-party trigger: ceiling: 100.000000
third-party trigger: carry counted at execution: 75.328469
third-party trigger: amount assessed against the ceiling (rejected): 163.328469
[PASS] test_Control_ThirdPartyTriggerFailsOnGrossDebitCeiling() (gas: 3132988)
Logs:
third-party trigger: ceiling: 20100.000000
third-party trigger: carry counted at execut
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 trigger branch pays the bounty through the general creditBounty path, which checkpoints the beneficiary's carry before the queued close is evaluated, instead of using the self-transfer release that deliberately skips checkpointing so carry is bounded by the close path.
Impact
The documented per-attempt ceilings are not enforced for an owner-triggered close, so more is collected than the owner allowed; no value is lost because the carry was owed, and only the owner's own trigger call has this effect.
What the attacker needed
Owner triggers her own protection; position has accrued carry; carry plus close charges exceed a ceiling
The fix
The trigger branch should release a bounty returning to the funding account without a carry checkpoint, as the cancel-and-close path does, so all carry is collected and bounded by the close path.
How it was found
- The owner arms a protection with the four close ceilings and holds a position with accrued carry.
- The owner calls triggerPositionProtection herself, so she is the bounty recipient.
- The trigger queues the close attempt and then credits the bounty, which checkpoints her carry and collects it in the same transaction.
- The evaluator assesses only the close's own charges, which fall under the ceilings, and the close executes.
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 up an automatic stop-loss or take-profit with limits on how much a close may cost. Normally those limits are checked when the close runs, and the cost of holding the position (called carry) is counted. Here, if the trader presses the trigger button herself, part of that cost is taken earlier in the same step, so the later check only sees the smaller remaining amount and lets the close through.
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.