Periodattimestamp returns incorrect period numbers for non current timestamps
The periodAtTimestamp function uses the current block time instead of the supplied timestamp when computing elapsed time, so it always returns the current period number rather than the period for the queried time. Any caller relying on it for historical analysis receives incorrect period data.
- Disclosed after under an hour
#59031 [SC-Low] periodattimestamp returns incorrect period numbers for non current timestamps
Submitted on Nov 7th 2025 at 21:37:11 UTC by @Falendar for Audit Comp | Firelight
- Report ID: #59031
- 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 function doesn't return the correct period for the provided timestamp.
Vulnerability Details
The vulnerability exists in the interaction between two functions:
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;
}
The bug occurs because:
periodAtTimestamp(timestamp)accepts atimestampparameter indicating which point in time to query- It correctly uses this parameter to fetch the appropriate
periodConfigurationviaperiodConfigurationAtTimestamp(timestamp) - However, when calculating the period number, it calls
_sinceEpoch(periodConfiguration.epoch)which ignores the input parameter and usesTime.timestamp()(current block time) instead - This means the elapsed time calculation uses the wrong reference point: current time instead of the queried timestamp
Impact Details
Any external protocol, contract, user or future implementations that calls periodAtTimestamp for historical analysis will receive incorrect data.
References
Proof of Concept
Proof of Concept
Example
periodConfigurations[0] = {epoch: 1000, duration: 100, startingPeriod: 0}
Period timeline:
Period 0: 1000-1100
Period 1: 1100-1200
Period 2: 1200-1300 (this is the period that needs to be retrieved)
...
Period 10: 2000-2100
Current blockchain timestamp: Time.timestamp() = 2000
Retrieving period at timestamp 1250: vault.periodAtTimestamp(1250);
elapsed = Time.timestamp() - 1000 = 2000 - 1000 = 1000
periodsElapsed = 1000 / 100 = 10
periodNumber = 0 + 10 = 10 (current value, WRONG)
Result: Returns Period 10 instead of Period 2 (always returns current period)
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
The helper that computes elapsed time reads the current block timestamp instead of the timestamp passed into periodAtTimestamp.
Impact
Callers using the function for historical analysis receive incorrect period numbers, though no funds are lost.
What the attacker needed
None
How it was found
- Configure a period schedule with a known epoch, duration and starting period.
- Note the current blockchain timestamp is later than the timestamp to query.
- Call periodAtTimestamp with a historical timestamp inside an earlier period.
- Observe the returned period number matches the current period, not the queried one.
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 tell you which time period a given moment falls into. It looks up the right settings for that moment, but then measures how much time has passed from the start of the schedule until now, not until the moment you asked about. So it always reports the current period, even when you ask about a past time.
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.