58993 sc low incorrect timestamp calculation in periodattimestamp leads to broken historical period lookups
Submitted on Nov 7th 2025 at 15:18:35 UTC by @dobrevaleri for Audit Comp | Firelight
Report ID: #58993
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
The FirelightVault::periodAtTimestamp() function incorrectly uses the current block timestamp instead of the provided timestamp parameter when calculating the period number. This causes the function to always return the current period regardless of which historical timestamp is queried, breaking any functionality that relies on historical period-to-timestamp mappings.
Vulnerability Details
The FirelightVault::periodAtTimestamp() function is designed to return the period number corresponding to any given timestamp. The function correctly identifies which period configuration applies to the given timestamp via periodConfigurationAtTimestamp(), but then fails to use the timestamp parameter in the actual period calculation.
function periodAtTimestamp(uint48 timestamp) public view returns (uint256) {
PeriodConfiguration memory periodConfiguration = periodConfigurationAtTimestamp(timestamp);
return periodConfiguration.startingPeriod + _sinceEpoch(periodConfiguration.epoch) / periodConfiguration.duration;
}The issue stems from the _sinceEpoch() helper function:
The helper function always calculates the time difference from epoch to Time.timestamp() (the current block timestamp), completely ignoring the timestamp parameter passed to periodAtTimestamp(). This means that instead of calculating how many period durations have elapsed from the epoch to the given timestamp, it calculates how many have elapsed to the current time.
For example, with a daily period duration:
Contract deployed at timestamp T₀ (period 0)
Query
periodAtTimestamp(T₀)at timestamp T₃ (3 days later, period 3)Expected result: 0
Actual result: 3
The calculation becomes:
The periodConfigurationAtTimestamp() function correctly finds the period configuration for the given timestamp by iterating through configurations and comparing against the timestamp parameter. However, this correct behavior is undermined when _sinceEpoch() then uses the current time instead.
Impact Details
Historical period queries always return the current period number with the period configuration at the timestamp instead of the correct historical period.
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#L796
Proof of Concept
Proof of Concept
Was this helpful?