#59820 [SC-Low] periodattimestamp returns current period instead of historical period

Submitted on Nov 16th 2025 at 05:09:20 UTC by @Pro_King for Audit Comp | Firelight

  • Report ID: #59820

  • Report Type: Smart Contract

  • Report severity: Low

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

  • Impacts:

    • Contract fails to deliver promised returns, but doesn't lose value

Description

Brief/Intro

The periodAtTimestamp(uint48 timestamp) function is designed to return the period number for any given timestamp but always returns the current period instead. The bug occurs because the helper function _sinceEpoch() uses Time.timestamp() (current time) rather than the input timestamp parameter. This breaks external integrations, frontend historical displays, and analytics systems that rely on historical period queries. Core vault operations are unaffected since they use currentPeriod() which works correctly.

Vulnerability Details

The periodAtTimestamp() function contains a logic error:

function periodAtTimestamp(uint48 timestamp) public view returns (uint256) {
    PeriodConfiguration memory periodConfiguration = periodConfigurationAtTimestamp(timestamp);
    return periodConfiguration.startingPeriod + _sinceEpoch(periodConfiguration.epoch) / periodConfiguration.duration;
}

function _sinceEpoch(uint48 epoch) private view returns (uint48) {
    return Time.timestamp() - epoch;  //  Always uses current time
}

_sinceEpoch() calculates elapsed time using Time.timestamp() (current block time) instead of the input timestamp parameter. The function ignores its input and always returns the current period.

Example:

  • Period 0: Nov 16-23, Period 1: Nov 23-30, Period 2: Nov 30-Dec 7

  • Current time: Nov 30 (Period 2)

  • Query: periodAtTimestamp(Nov_19) (Nov 19 is in Period 0)

  • Expected: Period 0

  • Actual: Period 2

Impact Details

  • Historical period-based performance reports are incorrect

  • Users see all their historical activity mapped to incorrect periods

  • All past activity appears to happen in the current period

References

Proof of Concept

Proof of Concept

Firstly make a file by name of period_at_timestamp_bug_poc.js at test folder then for running the test use this command npx hardhat test test/period_at_timestamp_bug_poc.js

Test output:

Was this helpful?