Skip to content
Business logic Audit finding Advanced

Same-block checkpoint overwrite in FirelightVault.payout lets any depositor escape assessed loss exposure, leaving the protocol unable to honour cover it already sold

A checkpoint trace overwrites rather than appends when a withdrawal is mined in the block whose timestamp equals the period start, so the snapshot used to cap incident payouts is silently rewritten. An ordinary depositor can therefore escape their share of an assessed loss, leaving the cover buyer short by the difference.

Pwning Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

89588 sc high same block checkpoint overwrite in firelightvault payout lets any depositor escape assessed loss exposure leaving the protocol unable to honour cover it already sold

Submitted on Aug 20th 2026 at 01:33:18 UTC by @Pwning for Audit Comp | Firelight

Description

Brief/Intro

FirelightVault.payout caps every incident payout at min(assetsAtCapturePeriod, activePayableAmount), where assetsAtCapturePeriod is totalAssetsAt(capturePeriodStart) — the head of a Checkpoints.Trace256. Because Trace256.push overwrites on an equal key instead of appending, a permissionless withdraw mined in the block whose block.timestamp equals the period start rewrites the exact snapshot that the allocator already consumed when it sized the period's sellable cover, and that the payout will later read as its cap. The protocol therefore sells cover against capital it then treats as absent: in the measured run a fully-assessed claim of 900,000,000,000 asset units is paid only 200,000,000,000, the cover buyer is short 700,000,000,000 (700,000 USDC), and 560,000,000,000 (560,000 USDC) of that shortfall is retained by the withdrawing depositor who was contractually exposed to it. No privileged role acts and no role misbehaves — the attacker is an ordinary LP calling a permissionless function.

Vulnerability Details

The two operands, and why one defeats the other

FirelightVault.payout computes the payable amount at FirelightVault.sol:927:

Solidity
// FirelightVault.sol:909-927
// Cap by the active assets committed at the start of the covered period.
// This is an exposure cap, not a segregated asset bucket.
uint256 assetsAtCapturePeriod = totalAssetsAt(capturePeriodStart);
uint256 currentActiveAssets = totalAssets();

// Withdrawals requested during the capture period are assigned to capturePeriod + 1
// and remain payable while payout is allowed.
uint256 capturePeriodWithdrawals = withdrawAssets[capturePeriod + 1];

// If payout happens in the following period, withdrawals requested before payout
// during that following period are assigned to capturePeriod + 2 and should also
// remain payable; otherwise exposed assets could escape by withdrawing first.
uint256 nextPeriodWithdrawals;
if (_currentPeriod == capturePeriod + 1) {
    nextPeriodWithdrawals = withdrawAssets[capturePeriod + 2];
}

uint256 activePayableAmount = currentActiveAssets + capturePeriodWithdrawals + nextPeriodWithdrawals;
paidAmount = Math.min(amount, Math.min(assetsAtCapturePeriod, activePayableAmount));

activePayableAmount is a deliberate anti-escape invariant. It adds pending withdrawals back into the payable base, and the vault's own comment at FirelightVault.sol:918-920 states the purpose verbatim:

"…withdrawals requested before payout during that following period are assigned to capturePeriod + 2 and should also remain payable; otherwise exposed assets could escape by withdrawing first."

That invariant is correctly implemented and it works. The sibling operand voids it.

Why assetsAtCapturePeriod is mutable

totalAssetsAt reads a checkpoint trace. Checkpoints.sol:207-208 overwrites rather than appends when the pushed key equals the latest key:

Solidity
// Checkpoints.sol:203-212
(bool exists, uint48 lastKey,) = self._trace.latestCheckpoint();

uint256 len = self._values.length;
uint256 lastValue = latest(self);
if (exists && key == lastKey) {
    self._values[len - 1] = value;      // <-- OVERWRITE, not append
} else {
    self._trace.push(key, uint208(len));
    self._values.push(value);
}

The key is block.timestamp. Every vault balance mutation routes through _logTrace at FirelightVault.sol:1044-1056:

Solidity
function _logTrace(
    address owner,
    uint256 balance,
    uint256 _totalSupply,
    uint256 _totalAssets,
    bool isLogAssets
) private {
    uint48 ts = Time.timestamp();
    _traceBalanceOf[owner].push(ts, balance);
    _traceTotalSupply.push(ts, _totalSupply);

    if (isLogAssets) _traceTotalAssets.push(ts, _totalAssets);
}

So a withdraw landing in a block whose block.timestamp == periodStart replaces totalAssetsAt(periodStart) rather than adding a new point after it.

The same key is also what sizes the cover

CoverOrderAllocator.sol:711, inside _computeAvailableCapacity, reads the identical key:

Solidity
uint256 totalAssetsCanonical = Decimals.convert(
    $.vault.totalAssetsAt($.vault.currentPeriodStart()),
    $.vaultAssetDecimals,
    CANONICAL_DECIMALS,
    Math.Rounding.Floor
);

Its own doc comment at CoverOrderAllocator.sol:690 shows the intended reading — a value fixed for the period:

"Values staked assets at currentPeriodStart(), so it is only meaningful for the current period (enforced by callers)."

Two contracts read one storage key at two different times and both assume it is immutable for the period. It is not.

The contradiction inside the vault itself

The vault classifies a single transaction two ways at once. _requestWithdraw buckets the withdrawal into withdrawAssets[currentPeriod() + 1], treating it as belonging to the new period — which is exactly what keeps it inside activePayableAmount and therefore payable. Simultaneously, totalAssetsAt(periodStart) folds that same withdrawal into the snapshot taken before that period began, which is what caps the payment.

The withdrawal is counted as still exposed by one operand and as already gone by the other, and Math.min lets the second one win.

Measured, both operands, immediately before payout

The PoC reads both operands directly from the live contracts one call before payout executes:

control treatment
totalAssets() 200000000000 200000000000
withdrawAssets[capturePeriod+1] 800000000000 800000000000
activePayableAmount (operand A) 1000000000000 1000000000000
assetsAtCapturePeriod (operand B) 1000000000000 200000000000
resulting paidAmount 900000000000 200000000000
control:    paidAmount = min(900000000000, min(1000000000000, 1000000000000)) = 900000000000
treatment:  paidAmount = min(900000000000, min( 200000000000, 1000000000000)) = 200000000000
                                                ^^^^^^^^^^^^^
                                                the only value that differs

activePayableAmount is identical in both arms, and so are the vault's liquid totalAssets() and the withdrawal bucket. The claim is therefore not truncated because the assets are absent — they are present and payable, and the anti-escape mechanism correctly says so. It is truncated solely because the sibling operand was rewritten. This is what makes the finding a constraint bypass rather than a capacity shortfall, and it is why the vault's stated intent for that operand — "the active assets committed at the start of the covered period" (:909-910) — is false at the moment it is read. The assets committed at the start of that period were 1,000,000,000,000.

Control validity

The two arms differ in exactly one variable. Measured and emitted by both:

treatment control
withdrawAssets[targetPeriod+1] 800000000000 800000000000
currentPeriod() at withdrawal 2 2
target period 2 2
offset of withdrawal from periodStart 0 s 1 s

Identical bucket, identical period, identical amount. The single difference between a full payout and a 700,000 USDC shortfall is a one-second difference in the withdrawal's block timestamp.

Reachability — three preconditions, each measured

1. A block must exist whose timestamp is exactly periodStart. Stated plainly because the PoC forces it with evm_setNextBlockTimestamp: a write one second either side of periodStart creates a new checkpoint and changes nothing. Measured against Flare mainnet, two independent 300-block samples taken minutes apart:

                          sample 1      sample 2
blocks sampled                 300           300
wall-clock span (s)            339           333
mean gap (s)                 1.134         1.114
gap histogram          {1:280,2:12,  {1:282,2:11,
                              5:7}     4:1,5:5}
distinct timestamps            300           300
seconds carrying a block     88.2%         89.8%

Roughly 88–90% of any given second on Flare carries a block bearing exactly that timestamp, so the boundary block is the ordinary case, not a lucky one. Every sampled block had a distinct timestamp, so when it exists it is unique.

2. The allocator's commit must land in that same block. The commit reads currentPeriodStart() — a computed timestamp, not a block property — and the project's own MockCoverOrderAllocatorVault.sol:38-40 documents the operating mode:

"Mirror FirelightVault semantics for the off-chain matcher: the current period started the moment it rolled. The off-chain engine pins its matching reads to the first block at/after this timestamp."

If the commit instead landed in a later block, any write at key periodStart would necessarily precede it, so the commit would read the already-reduced value and size cover correctly.

That dependency is itself the defect, not a mitigation of it. Nothing in CoverOrderAllocator or FirelightVault constrains when the commit is submitted. The contracts read a mutable checkpoint as though it were immutable for the period, and whether that assumption holds is decided entirely by off-chain submission timing the contracts neither observe nor enforce. A safety property — that cover is never sold against capital which has already left — must not rest on the punctuality of an off-chain engine. This report therefore does not require the reviewer to accept any claim about how the production matcher behaves today: if it commits in the boundary block the loss is reachable now, and if it does not, the contracts still carry a latent unsafe assumption that any future change in engine latency, block cadence, or a retry path converts into the loss below, with no contract change and no warning.

3. The withdrawal must be ordered after the commit within that block. This is a genuine transaction-ordering requirement and is not glossed. The PoC asserts it rather than assuming it — it checks the withdrawal shares the commit's block number and carries a strictly higher transaction index, with the commit paying 100 gwei priority and the attacker 1 gwei. Being ordered after a known transaction is the easy direction: this is a back-run, not a front-run. The period start is deterministic (epoch + n * duration), so the attacker does not need to observe the commit — they pre-submit a low-priority withdrawal targeted at that block, and a miss costs nothing beyond an ordinary withdrawal.

Impact Details

Selected in-scope impact: Protocol insolvency

The protocol sells 900,000,000,000 asset units of cover, an incident assesses the full amount, and the contract honours 200,000,000,000. It cannot meet an obligation it has already sold, while the capital that backed it leaves to the LPs. Equivalently, direct theft of any user funds, whether at-rest or in-motion: the claimant's payment is funds in motion, 700,000,000,000 of it never arrives, and 560,000,000,000 is retained by the attacker.

The loss, measured

Scenario: a 1,000,000-token vault (6-decimal asset), cover sold at 90% of it, attacker holding 80% of deposits.

control treatment delta
capacity committed 900000000000000000000000 900000000000000000000000 0
totalAssetsAt(periodStart) after the block 1000000000000 200000000000 rewritten
claim assessed 900000000000 900000000000 0
claim paid 900000000000 200000000000 −700000000000
attacker's assets recovered 80000000000 640000000000 +560000000000

The attacker's position, stated precisely

The attacker does not end up with more than they deposited. They deposit 800,000,000,000 and recover 640,000,000,000, so in absolute terms they are down 160,000,000,000. What they gain is escape from a loss they were contractually exposed to. Had the claim paid in full — the control's outcome, and the design's intent — their pro-rata share of the assessed loss would have left them with 80,000,000,000:

loss they would have borne, claim paid in full   720,000,000,000
loss actually borne                              160,000,000,000
                                                ────────────────
loss ESCAPED by the attacker                     560,000,000,000   (560,000 USDC)
loss escaped by the other LPs                    140,000,000,000
                                                ────────────────
shortfall borne by the cover buyer               700,000,000,000   ✓ closes exactly

The 560,000,000,000 figure is corroborated two independent ways: as the cross-arm difference in the attacker's recovered assets (640B − 80B), and as the within-arm escaped-loss identity above. Both are emitted by the PoC, and the control emits 0 for all three.

The loss scales with the attacker's LP share and with the size of the assessed incident.

Why the operator recovery path does not cap this

The exposure cap is per call rather than aggregate — the program's published known issue [3] — so operators can recover the buyer by opening further incidents against the same order. That path was executed and it does work. It is nonetheless not a mitigation that caps severity, for three measured reasons.

1. It is not the code's behaviour; it is discretionary human work the protocol never signals. payout truncates silently via min(). It does not revert, the incident is set CLOSED after the partial payout, and no path reopens it. Nothing in the contracts tells an operator that the snapshot was rewritten or that the buyer is short.

2. It requires the CURATOR to fabricate incidents that did not occur, purely as a payment rail — 4 extra incident cycles at the measured 80% share, up to 17 at 95%, each cycle five transactions needing both CURATOR and ASSESSMENT_APPROVER. Manufacturing loss events that never happened is not a documented privilege of that role, so this is not an operator using the system as designed.

3. The window is hard-bounded and shuts at exactly the moment the attacker can take the money. _isPeriodInPayoutWindow is current == period || current == period + 1, so payout is impossible from capturePeriod + 2 onward. claimWithdraw requires period < currentPeriod() and the withdrawal sits in capturePeriod + 1, so the attacker's first opportunity to claim is currentPeriod() == capturePeriod + 2. Recovery ends and extraction begins in the same period. With the on-chain period duration of 86400 seconds, operators have at most two days, unprompted.

Operator recovery cost against the size of the boundary withdrawal, measured:

attacker's share snapshot after first payout recovered extra incident cycles
50% 500000000000 500000000000 400000000000 1
80% 200000000000 200000000000 700000000000 4
90% 100000000000 100000000000 800000000000 8
95% 50000000000 50000000000 850000000000 17

If that work is not done in time, the cover buyer's shortfall is permanent and the escaped loss stays escaped. No operator has to do anything wrong for this — they simply have to not perform an undocumented remediation that nothing told them was needed.

Fallback framing: if the reviewer credits the recovery path, the honest fallback impact is temporary freezing of funds for at least 24 hours, since the payout window is two periods and the on-chain period duration is 86400 seconds.

Live-chain context

Measured today against Flare mainnet via test/fork/v2_upgrade_mainnet.js (4 passing):

live totalAssets                          56601413625750   (56,601,413.63 FXRP)
live pendingWithdrawAssets                  215799508170
live periodDuration                                86400   (1 day)
totalAssetsAt(currentPeriodStart)         56601413625751

The live FirelightVault proxy's _traceTotalAssets history is dense and populated, so totalAssetsAt returns real values in production and the period duration bounding the recovery window is the deployed one rather than a test constant. IncidentManager and CoverOrderAllocator are not yet deployed on Flare — the expected state of code under a pre-deployment audit. This finding is against the audited branch v1_audit_ready at commit 42f9ea5; the live figures are corroboration that the checkpoint history the exploit manipulates is real, not a contingency for the finding.

Suggested fix

Read the exposure snapshot at periodStart - 1, or push a period-start checkpoint on the first write of each period. Either makes the value immune to a later write on the same timestamp key and restores the invariant activePayableAmount already encodes.

A narrower alternative: drop assetsAtCapturePeriod from the min() when the withdrawal it accounts for is still inside activePayableAmount, since in that case the two operands double-count the same assets in opposite directions.

Note on scope

This is not a duplicate of known issue [3]. That issue concerns aggregate claims exceeding cover sold. This is the opposite direction — cover sold exceeding the claims the contract will pay — and known issue [3] is what makes the operator recovery path possible at all, not what causes the bug.

References

Target: https://github.com/immunefi-team/audit-comp-firelight Branch v1_audit_ready, commit 42f9ea5e43d88b35197b901acc2a8c24b314fa62.

Proof of Concept

Proof of Concept

Environment

Bash
git clone https://github.com/immunefi-team/audit-comp-firelight
cd audit-comp-firelight
git checkout 42f9ea5e43d88b35197b901acc2a8c24b314fa62   # branch v1_audit_ready
npm install

Save the file in Full PoC source below as test/integration/k_ts1_backrun.js. No in-scope contract is modified — verified with git diff --stat HEAD -- contracts/core contracts/oracle, which is empty. The only mocked contracts are the vault's asset token (MockERC20) and the price feed (MockAggregatorV3); the vault, allocator, IncidentManager and CoverNFT are all real. Neither mock lies on the path this finding concerns.

Step-by-step

Both arms execute the identical sequence. The only difference is the boolean sameBlock, which decides which block the whale's withdraw is mined in.

  1. Seed the vault. Two depositors fund a 1,000,000-token vault: the attacker ("whale") deposits 800,000,000,000 (80%) and a passive LP deposits 200,000,000,000 (20%).

  2. Advance to period P-1 and write a cover order. The CURATOR calls createCoverOrder for 900,000 canonical USD of cover against market Morpho/market-A. The order's period is asserted to equal pPrev + 1 — it targets period P.

  3. Read the period boundary. periodStart = vault.currentPeriodEnd(), which is the first timestamp of period P.

  4. Build the boundary block. Disable automine and pin the next block's timestamp to exactly periodStart:

    JavaScript
    await ethers.provider.send('evm_setAutomine', [false])
    await ethers.provider.send('evm_setNextBlockTimestamp', [Number(periodStart)])
    
  5. Submit the allocator's commit first. commitAllocation(targetPeriod, root, coverAmount, coverAmount) at 100 gwei priority fee. Internally this reads totalAssetsAt(currentPeriodStart()) = 1,000,000,000,000 and commits that as the period's available capacity.

  6. Back-run it with the withdrawal — treatment only. withdraw(WHALE, whale, whale) at 1 gwei priority fee, so the mempool orders it after the commit. _requestWithdraw calls _logTrace, which pushes a checkpoint keyed block.timestamp == periodStart. Because Trace256.push overwrites on an equal key, totalAssetsAt(periodStart) is rewritten from 1,000,000,000,000 down to 200,000,000,000. In the control this same withdrawal is instead mined in the next block (periodStart + 1), where it appends a new checkpoint and leaves the period-start value intact.

  7. Mine the block and assert the ordering — not assume it.

    JavaScript
    expect(commit block timestamp).to.equal(periodStart)
    expect(vault.currentPeriod()).to.equal(targetPeriod)
    // treatment:
    expect(wdRcpt.blockNumber).to.equal(commitRcpt.blockNumber)   // same block
    expect(wdRcpt.index > commitRcpt.index).to.equal(true)        // ordered AFTER
    // control:
    expect(wdRcpt.blockNumber > commitRcpt.blockNumber).to.equal(true)
    
  8. Capture control-validity evidence. Read withdrawAssets[targetPeriod+1], currentPeriod(), and the withdrawal block's timestamp offset from periodStart. These come out identical in both arms except the offset (0 s vs 1 s).

  9. Settle the cover order. settleCoverOrder(orderId, allocations, []) succeeds against the capacity committed in step 5, at the full 900,000 canonical USD in both arms. The protocol has now sold cover against capital that, in the treatment, the vault's own snapshot says has left.

  10. Open and assess an incident in period P at the full settled cover amount: createIncident(periodStart, …) → confirmIncident → addAssessmentLosses(amount = settled.allocatedCoverAmount) → submitCurrentAssessment.

  11. Read both min() operands immediately before payout.

    JavaScript
    const activeAssetsPre            = await vault.totalAssets()                       // 200000000000 BOTH arms
    const capturePeriodWithdrawalsPre= await vault.withdrawAssets(targetPeriod + 1n)   // 800000000000 BOTH arms
    const activePayablePre           = activeAssetsPre + capturePeriodWithdrawalsPre   // 1000000000000 BOTH arms
    const assetsAtCapturePre         = await vault.totalAssetsAt(periodStart)          // 1000000000000 vs 200000000000
    
  12. Approve the assessment, triggering the payout. approveCurrentAssessment(incidentId) drives FirelightVault.payout. Measure the delta in the payout receiver's balance.

    • Control: paid 900,000,000,000 — the full assessed claim.
    • Treatment: paid 200,000,000,000 — short by 700,000,000,000.
  13. Run the operator recovery arm (optional, K_TS1_WORKAROUND=1). Loop opening further incidents against the same order while isPeriodInPayoutWindow(targetPeriod) holds, to test honestly whether operators can recover the buyer. They can — in 4 cycles at the 80% share — which is why the report addresses that path explicitly rather than hiding it.

  14. Advance two periods and let the attacker exit. claimWithdraw(targetPeriod + 1).

    • Control: attacker recovers 80,000,000,000 — they bore their full pro-rata share of the loss.
    • Treatment (no operator recovery): attacker recovers 640,000,000,000 — they escaped 560,000,000,000 of it.

Commands and observed output

Bash
K_TS1_ARM=control    npx hardhat test test/integration/k_ts1_backrun.js
h13_capacity_committed: 900000000000000000000000
h13_snapshot_after: 1000000000000
h13_claim_assessed: 900000000000
h13_claim_paid: 900000000000
h13_shortfall: 0
h13_shortfall_usdc: 0
h13_vault_total_usdc: 1000000
h13_whale_recovered: 80000000000
h13_withdraw_bucket: 800000000000
h13_active_assets_pre: 200000000000
h13_active_payable_pre: 1000000000000
h13_assets_at_capture_pre: 1000000000000
h13_withdraw_period: 2
h13_target_period: 2
h13_wd_offset_from_period_start: 1
h13_attacker_share_pct: 80
h13_other_lps_share_pct: 20
h13_attacker_loss_if_paid_in_full: 720000000000
h13_attacker_loss_actual: 720000000000
h13_attacker_escaped_loss: 0
h13_attacker_escaped_loss_usdc: 0
h13_other_lps_escaped_loss: 0
  2 passing
Bash
K_TS1_ARM=treatment  npx hardhat test test/integration/k_ts1_backrun.js
h13_capacity_committed: 900000000000000000000000
h13_snapshot_after: 200000000000
h13_claim_assessed: 900000000000
h13_claim_paid: 200000000000
h13_shortfall: 700000000000
h13_shortfall_usdc: 700000
h13_vault_total_usdc: 1000000
h13_whale_recovered: 640000000000
h13_withdraw_bucket: 800000000000
h13_active_assets_pre: 200000000000
h13_active_payable_pre: 1000000000000
h13_assets_at_capture_pre: 200000000000
h13_withdraw_period: 2
h13_target_period: 2
h13_wd_offset_from_period_start: 0
h13_attacker_share_pct: 80
h13_other_lps_share_pct: 20
h13_attacker_loss_if_paid_in_full: 720000000000
h13_attacker_loss_actual: 160000000000
h13_attacker_escaped_loss: 560000000000
h13_attacker_escaped_loss_usdc: 560000
h13_other_lps_escaped_loss: 140000000000
  2 passing

Operator recovery arm (both environment variables are required — the loop's default round cap of 12 truncates the 95% row and prints a shortfall that is an artifact of the harness, not a property of the protocol):

Bash
K_TS1_WORKAROUND=1 K_TS1_MAX_ROUNDS=30 npx hardhat test test/integration/k_ts1_backrun.js
CONTROL   — whale withdraws one block later
  capacity committed (read at pe

The original report as published on Immunefi, by Pwning. 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

Likely the checkpoint library overwrites the latest entry when a new write shares the same timestamp key, so a permissionless withdrawal in the period-start block mutates a snapshot that both the payout cap and the cover sizing treat as immutable.

Impact

The protocol could sell cover it cannot honour, with the claimant short by 700,000 USDC in the measured run, though the operator recovery path can partially compensate if acted on within two periods.

What the attacker needed

Attacker holds a large LP share; withdrawal mined in the period-start block; withdrawal ordered after the allocator commit; curator opens an incident and payout runs

The fix

The exposure snapshot should be read at periodStart minus one, or a period-start checkpoint should be pushed on the first write of each period, so a later same-timestamp write cannot alter it.

How it was found

  1. Seed the vault with an attacker depositing 80% and a passive LP depositing 20%
  2. Advance to the prior period and have the curator create a cover order targeting the next period
  3. Read the period boundary timestamp from the vault
  4. Mine the attacker's withdrawal in the block whose timestamp equals the period start
  5. Trigger an incident assessment and call payout, observing the reduced cap

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.

The vault records how much money it holds at the start of each period, and later uses that recorded figure to limit how much it pays out after a loss. The recording system replaces the entry when two writes happen in the same second, so a withdrawal timed to that exact second changes history. The depositor then looks as though they had already left, and the payout is cut short.

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 Pwning

View all

2 more disclosed reports, best first.

More from Firelight

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.