For the complete documentation index, see llms.txt. This page is also available as Markdown.

59179 sc low periodattimestamp bug returns current period for all timestamps

Submitted on Nov 9th 2025 at 16:14:05 UTC by @coinsspor for Audit Comp | Firelight

  • Report ID: #59179

  • Report Type: Smart Contract

  • Report severity: Low

  • Target: https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol

  • Impacts:

    • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Brief/Intro

I found a bug in periodAtTimestamp() - it ignores the timestamp parameter and always returns the current period. This breaks external contracts and services trying to query historical or future periods.

Vulnerability Details

Location: FirelightVault.sol, lines 246-250 and 795-797

What I Found: periodAtTimestamp() should calculate which period a given timestamp falls into. But I noticed there's a bug in the _sinceEpoch() helper - it always uses Time.timestamp() (current block time) instead of the timestamp parameter.

Here's the buggy code:

The timestamp parameter never gets used. I tested this and every query returns the current period regardless of what timestamp I pass in.

What I Tested: I deployed the contract and moved time forward 10 periods (current period = 10):

  • When I queried timestamp for period 2 → Got 10 back (wrong)

  • When I queried timestamp for period 15 → Got 10 back (wrong)

  • When I queried timestamps for periods 1-5 → All returned 10 (all wrong)

The only time it works is when I query current block.timestamp (and that's just by accident).

Impact Details

External Contracts: Any contract checking elapsed time will get wrong period data. I can see this causing problems with withdrawal eligibility checks - periodAtTimestamp(requestTime) always returns current period so the checks become useless.

Off-chain Systems: From what I can tell:

  • Indexers will show flat historical data

  • Analytics dashboards won't display period metrics correctly

  • Monitoring alerts won't work properly

Integration Partners: Projects building on Firelight need accurate period data. This bug makes the public API unreliable.

Why I'm Categorizing as Griefing: There's no direct fund loss, but I think this causes systematic data corruption that damages protocol usability. No profit motive for attacker, but clear damage to users and integrations.

References

My Suggested Fix: Line 249 should be:

Proof of Concept

Proof of Concept / Steps to Reproduce

Test Environment:

  • OS: Ubuntu 22.04

  • Node.js: v20.x

  • Hardhat: 2.22.x

  • Solidity: 0.8.28

Setup Steps:

  1. I cloned the Firelight repository:

  1. I created a simple MockERC20 contract for testing:

  1. I configured the environment:

  1. I wrote this test to reproduce the bug:

Running the Test:

Results:

What This Proves:

I tested the periodAtTimestamp() function with different timestamps:

  • Queried for period 2 (2 days after deployment) → Got period 10 (current)

  • Queried for periods 1-5 → All returned period 10 (current)

The function completely ignores the timestamp parameter. This happens because _sinceEpoch() uses Time.timestamp() instead of the parameter.

Verification: Anyone can reproduce this by following the setup steps above. The bug is deterministic.

Was this helpful?