Skip to content
Business logic Audit finding Beginner

Timestamp-agnostic periodAtTimestamp misreports historical periods, breaking time-locked logic

The periodAtTimestamp function ignores its timestamp argument and always returns the current period, so any historical or future lookup gives wrong data. Off-chain systems relying on it for withdrawal scheduling or upgrade planning could compute incorrect unlock times.

vivekd Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

59635 sc low timestamp agnostic periodattimestamp misreports historical periods breaking time locked logic

Submitted on Nov 14th 2025 at 10:18:46 UTC by @vivekd for Audit Comp | Firelight

Description

Brief/Intro

periodAtTimestamp(uint48) is supposed to tell integrators which period corresponds to any arbitrary timestamp. The function instead always returns the current period because it ignores its timestamp argument, so anything relying on historical or future lookups receives incorrect data. This can misconfigure time-locked withdrawals, scheduled upgrades, or analytics built atop the vault.

Vulnerability Details

  • periodAtTimestamp fetches the correct PeriodConfiguration for the supplied timestamp (contracts/FirelightVault.sol:246-248), but then calls _sinceEpoch(periodConfiguration.epoch).
  • _sinceEpoch unconditionally returns Time.timestamp() - epoch, i.e., "now minus epoch," with no way to pass the caller's timestamp (contracts/FirelightVault.sol:795-797).
  • Therefore periodAtTimestamp(x) collapses to startingPeriod + (now - epoch) / duration, which is simply currentPeriod() regardless of x.
  • Functions such as currentPeriod() and analytics that depend on this view are fine, but anyone trying to reason about historical or future periods using the public getter gets incorrect data.

Impact Details

Off-chain systems (withdrawal schedulers, upgrade planners, risk dashboards) cannot safely reason about periods that are not "right now," which can lead to incorrect unlock times or reporting.

Proof of Concept

Proof of Concept

JavaScript
// test/period_timestamp_poc.js
const { loadFixture, time } = require('@nomicfoundation/hardhat-network-helpers')
const { expect } = require('chai')
const { deployVault } = require('./setup/fixtures')

describe('periodAtTimestamp PoC', function () {
  let firelight_vault, config

  before(async () => {
    ({ firelight_vault, config } = await loadFixture(deployVault))
  })

  it('returns the current period even when queried for the original epoch', async () => {
    const firstConfig = await firelight_vault.periodConfigurations(0)
    const genesisEpoch = firstConfig.epoch

    await time.increase(Number(config.period_configuration_duration) * 3)

    const current = await firelight_vault.currentPeriod()
    const historical = await firelight_vault.periodAtTimestamp(genesisEpoch)

    expect(Number(current)).to.be.gt(0)
    expect(historical).to.equal(current)
  })
})

What the code does

Deploys the vault, records the epoch of the first period (time zero), advances three periods, then compares currentPeriod() with periodAtTimestamp(genesisEpoch)—a query that should have returned 0. The test asserts they're equal, showing the getter ignores its argument.

How to run

  1. Install deps if needed: npm install
  2. Ensure .env is populated (any dummy 32-byte keys).
  3. Run only this test: npx hardhat test test/period_timestamp_poc.js

Logs

newuser@LAPTOP-MLPJMQD2:~/firelight-core$ npx hardhat test test/period_timestamp_poc.js


  periodAtTimestamp PoC
    ✔ returns the current period even when queried for the original epoch


  1 passing (411ms)

The PoC reproduces the bug: querying the genesis timestamp yields the current period instead of 0.

The original report as published on Immunefi, by vivekd. 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 helper _sinceEpoch always uses the current block timestamp instead of accepting the caller's timestamp, so periodAtTimestamp collapses to currentPeriod.

Impact

Off-chain systems such as withdrawal schedulers and upgrade planners could compute incorrect unlock times or reporting because they cannot safely reason about non-current periods.

What the attacker needed

None

The fix

The function should pass the supplied timestamp into the period calculation instead of always using the current time.

How it was found

  1. Deploy the vault and record the epoch of the first period.
  2. Advance time by three period durations.
  3. Call currentPeriod and periodAtTimestamp with the genesis epoch.
  4. Observe that both return the same value instead of the historical period.

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 function meant to answer 'which time period was active at this specific moment?' But it always answers with the current period, no matter what moment you ask about. That means other programs using it to plan future or past actions get the wrong answer.

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 vivekd

View all

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