Commission share-burn distribution is JIT-capturable when builderCode == 0 (default)
When builderCode is zero, commission fees are burned as shares from the option owner without removing assets, which instantly raises the share price for all current shareholders. An attacker can deposit just before such a burn to capture most of the value, or a fee payer can recapture their own fee.
Submitted by fuzious, also found by kind0dev and Valves
CollateralTracker.solL1558-L1561CollateralTracker.solL1637-L1640RiskEngine.solL253-L264PanopticPool.solL839PanopticPool.solL1634
Summary
When builderCode == 0 (i.e., feeRecipient == address(0)), commissions in CollateralTracker.settleMint() / CollateralTracker.settleBurn() are implemented as a share burn from the option owner without removing assets. This reduces totalSupply() while keeping totalAssets() roughly constant, immediately increasing assetsPerShare for whoever holds shares at that instant (including same-block entrants). MEV searchers can JIT-deposit immediately before these commission-burn events to capture the majority of the value.
A stronger implication than “LP yield leakage” also exists: fee self-rebating / fee bypass. If a fee payer (or flash-funded actor in an active-trigger flow) can temporarily dominate the share supply at the moment their commission is burned, they can reclaim most of the fee back via the share-price uplift, undermining the commission’s intended economic purpose.
Finding description and impact
Panoptic distributes some value to shareholders by burning shares (reducing totalSupply() without removing assets), which increases assetsPerShare immediately for whoever holds shares at that moment. This is inherently Just-In-Time (JIT) liquidity-capturable: an MEV searcher can temporarily deposit to become a dominant shareholder right before a burn event, then unwind after, capturing most of the distribution that was economically intended for incumbent LPs.
Root cause mechanics
The share price is defined by ERC4626-style conversions:
assetsPerShare ≈ totalAssets() / totalSupply()totalAssets()includes tracked pool assets, assets in AMM, and unrealized interesttotalSupply()is_internalSupply + s_creditedShares
Any event that burns shares but does not remove assets causes:
totalSupply()↓ (burn)totalAssets()≈ constantassetsPerShare↑ instantly
That instant uplift is captured pro-rata by whoever is a shareholder at that exact moment.
Why builderCode == 0 is not “rare misconfiguration”:
In CollateralTracker.settleMint():
// CollateralTracker.sol:1558-1561
if (riskParameters.feeRecipient() == 0) {
_burn(optionOwner, sharesToBurn);
emit CommissionPaid(optionOwner, address(0), commissionFee, 0);
}
Critically, feeRecipient == 0 is produced by the DEFAULT builder flow:
RiskEngine.getRiskParameters()computesfeeRecipientfrombuilderCode_computeBuilderWallet(builderCode)returnsaddress(0)ifbuilderCode == 0
More importantly, several critical protocol maintenance paths HARDCODE getRiskParameters(0):
_burnAllOptionsFrom(...)(used by liquidations):(RiskParameters riskParameters, ) = getRiskParameters(0);(Line 839)_forceExercise(...):(RiskParameters riskParameters, ) = getRiskParameters(0);(Line 1634)
This means an attacker can actively trigger commission-burn distributions by initiating liquidation/forced-exercise flows when a target account is eligible, rather than passively waiting to sandwich a victim’s optional builderCode==0 transaction.
Attack flow
Passive MEV Sandwich (around user transaction with builderCode = 0):
- Victim tx pending: a user submits an option interaction via
PanopticPool.dispatch(...)withbuilderCode = 0. - Attacker front-runs: attacker calls
CollateralTracker.deposit(...)to mint a very large share balance right before the victim tx executes. - Victim tx executes:
PanopticPoolcallsCollateralTracker.settleMint/settleBurnand the commission path burnssharesToBurnfrom the option owner (supply decreases, assets do not). - Attacker back-runs: attacker unwinds, capturing the share price uplift.
Active Trigger (Liquidation-style):
- Attacker identifies a margin-called account eligible for liquidation.
- Attacker deposits large liquidity into the relevant
CollateralTracker(s) to dominate share supply. - Attacker calls
dispatchFrom, which routes into_liquidate(...)and burns all positions via_burnAllOptionsFrom(...)using hardcodedgetRiskParameters(0). CollateralTracker.settleBurn(...)charges commission; iffeeRecipient==0, it burns shares.- Attacker exits when liquidity permits; the economic transfer happens at burn time.
How the attacker finds margin-called accounts (practically):
- Off-chain: call
PanopticPool.getAccumulatedFeesAndPositionsData(...)+RiskEngine.isAccountSolvent(...)/RiskEngine.getMargin(...)to evaluate solvency at relevant ticks. - On-chain: simply attempt
dispatchFrom(...)for a candidate account; the call reverts unless the account is fully margin-called, so failed attempts are self-pruning.
The attacker’s captured value is approximately:
$$captured \approx donationValue \times \frac{attackerShares}{totalSharesAfterAttackerDeposit}$$
With sufficient capital, the attacker can make the ratio arbitrarily close to 1 and capture almost all of the distribution.
Capital requirements (Passive JIT capture):
For a pool with incumbent TVL T (in assets) and an attacker deposit A, the attacker’s capture fraction at the instant of the burn is approximately:
$$captureFraction \approx \frac{A}{T + A}$$
So to capture p of a burn event, the attacker needs roughly:
$$A \approx \frac{p}{1-p}\,T$$
Examples: p=90% → A≈9×T; p=99% → A≈99×T. The PoC uses large deposits to make the capture fraction very close to 1 and show the asymptote clearly.
Flash loan severity multiplier:
Flash loans are not a universal multiplier for a passive mempool sandwich (the attacker must hold shares across a separate victim transaction). However, when the attacker can actively trigger the commission-burn event (e.g., via liquidation / force exercise paths that hardcode getRiskParameters(0)), they can wrap “enter → trigger burn → exit” in a single transaction, making flash-loan-funded entry feasible.
Practical constraints:
- Realized, in-tx profit is bounded by withdrawable liquidity:
maxWithdraw/maxRedeemare capped bys_depositedAssets(nottotalAssets(), which includess_assetsInAMMand unrealized interest), and withdrawals are blocked whennumberOfLegs(owner) != 0. - In liquidation / force-exercise flows, the protocol delegates virtual shares to the distressed account; any “burn” that only consumes phantom shares is compensated on
revoke()(i.e., it does not persist as a nettotalSupply()decrease). The extractable “donation size” depends on how many real shares are actually burned.
Impact
- Systematic MEV capture of commission distributions: value intended for longer-term LPs can be captured by JIT entrants.
- Fee self-rebating / fee bypass: large or flash-funded actors can materially reduce effective commission paid, undermining the fee model.
- LP incentive degradation: Passive LP returns become MEV-farmable, reducing the attractiveness of providing liquidity.
- MEV arms race: Sophisticated searchers can bundle entry/exit around high-value option interactions.
- MEV around risk events: forced-exercise/liquidation flows can become predictable “donation” farming opportunities when they route through
getRiskParameters(0).
Recommended Mitigation Steps
There is no free lunch here: “burn-based instant distribution to current shareholders” is fundamentally JIT-capturable. Mitigations are about making the distribution not instantaneous or not purely share-price based.
-
Disallow burn-based distribution for commissions (Strongest, Simplest):
- Treat
builderCode == 0as “protocol receives fees” rather than “burn to LPs”. - Enforce
feeRecipient != 0for all dispatch paths, or routebuilderCode == 0to a non-zero treasury recipient, then distribute via a separate time-weighted mechanism.
- Treat
-
Stream/Vest distributions instead of instantaneous uplift:
- Accumulate commissions in a buffer and drip them into
totalAssets()over a window (e.g., X blocks). - This makes same-block JIT capture unprofitable because the “uplift” is smeared over time.
- Accumulate commissions in a buffer and drip them into
-
Cooldown / Time-weighting (Partial mitigation):
- A 1-block withdrawal cooldown reduces risk-free atomic sandwiches but does not remove the economic issue (attackers can hold across blocks).
- If implemented, it must also cover transfers (otherwise deposit→transfer→withdraw bypass exists).
Proof of Concept
Setup instructions:
- Create the PoC file at
test/foundry/poc/CollateralTrackerCommissionBurnJITPoC.t.sol - Apply the diff below (or copy the full file content)
- Run the tests via
forge test --match-path test/foundry/poc/CollateralTrackerCommissionBurnJITPoC.t.sol -vvv
Note: This PoC uses a minimal mock
PanopticPoolsolely to satisfyonlyPanopticPooland to simulate the liquidation-styledelegate()→settleBurn()→revoke()sequence that the realPanopticPooluses duringdispatchFromliquidations/forced exercises. A fulldispatchFromend-to-end liquidation PoC would require spinning up real option positions + solvency/oracle plumbing (typically via a forked environment) and is orthogonal to demonstrating the JIT-capturable share-burn mechanism insideCollateralTracker.
PoC diff:
View detailed Proof of Concept
Expected test output:
All 10 tests pass, demonstrating:
test_PoC_CommissionBurn_JITCapture_WhenFeeRecipientIsZero- JIT attacker captures >99% of commission burn distribution.test_PoC_SettleBurn_NoRealizedPremium_NoCommissionBurn- ConfirmssettleBurngating onrealizedPremium != 0.test_PoC_ActiveCapture_SettleBurn_CommissionBurn_JITCapture- Active attacker-initiated burn capture.test_PoC_FeeSelfRebating_PreDepositReducesEffectiveFee- Fee payer can recapture >99% of their own fee.test_PoC_FeeSelfRebating_CostDecreases_WithShareFraction- Effective fee decreases as the fee payer’s share fraction increases.test_PoC_FlashLoan_ActiveCapture_IsAtomic_WhenLiquidityAllows- Atomic flash loan attack variant.test_PoC_LiquidationStyle_DelegateRevoke_PhantomBurnIsRestored_WhenNoRealShares- Phantom burn is restored on revoke (no persistent supply decrease).test_PoC_LiquidationStyle_DelegateRevoke_RealBurnPersists_WhenVictimHasRealShares- Persistent supply decrease requires burning real shares.test_PoC_UpliftMayBeNonWithdrawable_WhenAssetsInAMMHigh- ShowsmaxWithdraw/maxRedeemare capped bys_depositedAssets(nottotalAssets()).test_PoC_RiskEngine_builderCode0_feeRecipient0- ConfirmsbuilderCode == 0→feeRecipient == address(0).
Panoptic marked as informative.
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 commission is implemented as a share burn that reduces totalSupply without reducing totalAssets, so the resulting share-price increase is captured by whoever holds shares at that moment.
Impact
Value intended for longer-term liquidity providers can be captured by just-in-time entrants, and large or flash-funded actors can materially reduce the effective commission they pay, though realised profit is bounded by withdrawable liquidity and withdrawals are blocked when the owner has open legs.
What the attacker needed
BuilderCode is zero (default); attacker has large capital or a flash loan; for active trigger: a margin-called account
The fix
The commission should not be distributed by an instantaneous share burn; instead, builderCode zero should route fees to a non-zero treasury or the fees should be streamed over time.
How it was found
- Victim submits an option interaction with builderCode set to zero.
- Attacker deposits a large amount to become a dominant shareholder before the victim's transaction.
- Victim's transaction executes and the commission path burns shares from the option owner.
- Attacker withdraws, capturing the share price uplift.
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.
In a shared pool, each person's share of the pool is their number of shares divided by the total number of shares. If the pool burns some shares without taking out any money, the remaining shares are each worth more. An attacker can buy shares just before the burn and sell them just after, pocketing most of that increase.
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.