59100 sc low periodattimestamp returns current period instead of queried historical period
Description
Brief/Intro
Vulnerability Details
/**
* @notice Returns the period number for the timestamp given.
* @dev Return value may be unreliable if period number given is far away in the future
* @dev given that new period configurations can be added after nextPeriodEnd().
* @return The period number corresponding to the given timestamp.
*/
function periodAtTimestamp(uint48 timestamp) public view returns (uint256) {
PeriodConfiguration memory periodConfiguration = periodConfigurationAtTimestamp(timestamp);
// BUG: Uses _sinceEpoch() which calls Time.timestamp(), not the parameter '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, never query timestamp
}Impact Details
Primary Impact: Contract Fails to Deliver Promised Returns
Concrete Consequences
References
Proof of Concept
Proof of Concept
Previous59115 sc low periodattimestamp function is incorrectly implemented and always returns period at current timestamp Next#59091 [SC-Low] low firelightvault sol implementation contract does not disable initializers
Was this helpful?