59369 sc low the function periodattimestamp uses the current timestamp instead of provided timestamp causing incorrect period calculation

Submitted on Nov 11th 2025 at 16:20:02 UTC by @Y4nhu1 for Audit Comp | Firelight

  • Report ID: #59369

  • 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 function periodAtTimestamp uses the current timestamp for period number calculation, which leads to incorrect results when querying a timestamp other than the current one.

Vulnerability Details

The function periodAtTimestamp should return the period number for the timestamp given. The statement _sinceEpoch(periodConfiguration.epoch) / periodConfiguration.duration calculates the elapsed period based on the time elapsed since the start time of the current period configuration, i.e. periodConfiguration.epoch.

function periodAtTimestamp(uint48 timestamp) public view returns (uint256) {
    // [...]
    return periodConfiguration.startingPeriod + _sinceEpoch(periodConfiguration.epoch) / periodConfiguration.duration;
}

According to the function definition, the time elapsed from the periodConfiguration.epoch to the parameter timestamp should be used. However, the function _sinceEpoch calculates the time elapsed from the periodConfiguration.epoch to the current timestamp.

Impact Details

This leads to users or other contracts obtaining incorrect results when querying a timestamp other than the current one.

References

  • https://github.com/firelight-protocol/firelight-core/blob/db36312f1fb24efc88c3fde15a760defbc3e6370/contracts/FirelightVault.sol#L249

  • https://github.com/firelight-protocol/firelight-core/blob/db36312f1fb24efc88c3fde15a760defbc3e6370/contracts/FirelightVault.sol#L795-L797

Proof of Concept

Proof of Concept

Run the test using the command npx hardhat test --grep "periodAtTimestamp returns diffe rent values as time progresses".

Without adding a new period configuration, the period number for a future timestamp should not change. However, the test results show that over time, periodAtTimestamp() returns different results for the same timestamp, indicating a calculation error.

Was this helpful?