Skip to content
Business logic Audit finding Intermediate

ClosePreview.executionFeeAssets NatSpec says the fee is assessed, but the field returns the capped and credited value, which is zero when a VPI rebate absorbs the fee

The close preview's executionFeeAssets field is documented as the assessed protocol fee, but it returns the capped and credited value, which is zero when a VPI rebate absorbs the fee. An integrator displaying this field would show a trader a zero fee for a close that actually incurs the 4 bps fee, though the trader's net payout is unchanged.

crypt0n1337 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#99192 [SC-Insight] ClosePreview.executionFeeAssets NatSpec says the fee is assessed, but the field returns the capped and credited value, which is zero when a VPI rebate absorbs the fee

Submitted on Nov 12th 2026 at 10:43:32 UTC by @crypt0n1337 for Audit Competition | Plether

Description

ClosePreview.executionFeeAssets is documented in interfaces/ICfdEngineTypes.sol:268 as "Protocol execution fee assessed on the close notional". The word assessed means the fee computed on the notional, 4 bps of close size, regardless of how it is settled. The implementation does not return that value: CfdEngineLens.previewClose (:399) copies delta.executionFeeAssets, which the planner caps at the assets actually eligible to pay it (libraries/CfdEnginePlanLib.sol:1066-1068): executionFeeEligibleAssets = nonClawbackWithheldAssets + nonVpiReserveCollectedAssets, and delta.executionFeeAssets = min(cs.executionFeeAssets, executionFeeEligibleAssets).

The divergence appears on skew-reducing closes, where the VPI rebate is larger than the fee. In that case executionFeeEligibleAssets is zero, so delta.executionFeeAssets is zero, and the preview reports zero fee for a close that actually incurs the 4 bps fee, absorbed into the VPI netting rather than charged.

The inconsistency is visible against the other read surfaces. previewOpen reports the full assessed fee in the same field even when the open is VPI-rebated, because the open path keeps the fee separate (CfdEnginePlanLib.sol:399). The order receipt (CfdOrderPolicyEvaluatorBase.sol:431) also reports the full assessed fee for the same close. Only the close preview reports the capped value, because it mirrors the planner's netted figure rather than the assessed charge.

The practical consequence is disclosure: an integrator that displays executionFeeAssets to a trader before closing shows zero fee for any skew-reducing close, while the trader's net payout already reflects the fee inside the VPI netting. The trader pays the same net amount either way, so this is a documentation and API-semantics defect rather than a value leak, but it is exactly the kind of read-surface mismatch that misleads integrations and support.

Recommendation: either rename the NatSpec to "Protocol execution fee credited on the close" and add a separate assessedExecutionFeeAssets field carrying the full 4 bps, or change CfdEngineLens.sol:399 to copy cs.executionFeeAssets from CloseAccountingLib so the preview matches its documentation.

Proof of Concept

This is a read-surface semantics insight, so the reproduction compares the preview against the receipt for the same close.

Step 1. Construct a skew-reducing close whose VPI rebate is larger than the 4 bps execution fee. On the release configuration the fee on a 100,000 notional close is 40.000000 USDG, and a rebate of that size is reachable because the VPI rebate is proportional to the skew reduction.

Step 2. Call CfdEngineLens.previewClose for that close and read executionFeeAssets. It returns 0, because CfdEnginePlanLib caps delta.executionFeeAssets at executionFeeEligibleAssets, and the eligible assets are zero when the rebate absorbs the charge.

Step 3. Execute the same close through the production path and read the order receipt. CfdOrderPolicyEvaluatorBase reports the full assessed fee (40.000000) for the same close, because the receipt field carries the assessed charge rather than the capped one.

Step 4. Compare with previewOpen on an open of the same size that is also VPI-rebated: the open preview reports the full assessed fee, not zero.

The observable inconsistency is therefore: two read surfaces for the same close disagree, and the documented meaning of the field (assessed) matches the receipt, not the close preview.

Suggested fix verification: after either renaming the field and adding assessedExecutionFeeAssets, or switching the copy source to cs.executionFeeAssets, the close preview and the receipt should report the same fee for the step 1 close.

The original report as published on Immunefi, by crypt0n1337. 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 close preview copies the planner's capped and netted executionFeeAssets value instead of the assessed fee, so the field's documented meaning does not match its implementation.

Impact

An integrator displaying executionFeeAssets would show zero fee for a skew-reducing close, misleading traders and support, though the trader's net payout is unchanged and this is a documentation and API-semantics defect rather than a value leak.

What the attacker needed

A skew-reducing close; VPI rebate larger than the 4 bps fee

The fix

Either rename the NatSpec to describe the credited fee and add a separate assessedExecutionFeeAssets field, or change the preview to copy the assessed fee from CloseAccountingLib so it matches its documentation.

How it was found

  1. Construct a skew-reducing close whose VPI rebate is larger than the 4 bps execution fee.
  2. Call CfdEngineLens.previewClose for that close and read executionFeeAssets, which returns zero.
  3. Execute the same close through the production path and read the order receipt, which reports the full assessed fee.
  4. Compare with previewOpen on an open of the same size that is also VPI-rebated, which reports the full assessed fee.

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 smart contract has a preview function that tells a trader what fee they will pay before closing a position. The documentation says the field shows the fee that is charged, but the code actually returns the fee after a rebate has cancelled it out, so it shows zero. The trader still pays the same net amount, but anyone building a user interface on top of this preview would display misleading information.

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 crypt0n1337

View all

23 more disclosed reports, best first.

More from Plether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.