#59385 [SC-Low] timestamp ignored current block time used

Submitted on Nov 11th 2025 at 18:22:24 UTC by @jesse03 for Audit Comp | Firelight

  • Report ID: #59385

  • Report Type: Smart Contract

  • Report severity: Low

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

  • Impacts:

    • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

    • Temporary freezing of funds

    • Temporary freezing of NFTs

Description

periodAtTimestamp() calls periodConfigurationAtTimestamp(timestamp) (good), but then ignores the caller‑supplied timestamp and computes with the current block time via _sinceEpoch(periodConfiguration.epoch), which internally does Time.timestamp() - epoch.

This creates two wrong/unsafe behaviors that are directly tied to what periodConfigurationAtTimestamp may return:

  1. Wrong result for past/future lookups. For any timestamp != block.timestamp, the returned period number is computed using now instead of the provided timestamp. So the function returns the current period, not the period at the given time.

  2. Underflow & revert for future timestamps (DoS on view). periodConfigurationAtTimestamp can legitimately return a configuration whose epoch is in the future (e.g., you query a time after a scheduled future configuration). When epoch > block.timestamp, _sinceEpoch(epoch) does block.timestamp - epoch and underflows, causing a revert.


Minimal repro:

  • Assume current time t=105, first config: epoch=100, duration=10.

  • An admin schedules a new config at epoch=110 (the next period boundary) with duration=20.

  • Call periodAtTimestamp(115) now (i.e., while block.timestamp is still 105).

Flow:

  • periodConfigurationAtTimestamp(115) ⇒ returns the future config {epoch:110, duration:20}.

  • _sinceEpoch(110) ⇒ 105 - 110 ⇒ underflow → revert.

Even without the underflow, for any past timestamp (e.g., timestamp=101) the function wrongly calculates using block.timestamp rather than 101, so the answer is incorrect.


Root cause:

Because periodConfigurationAtTimestamp can return a config with epoch > now when you ask about the future, the subsequent subtraction against now is unsafe and logically wrong.


Correct fix:

Use the provided timestamp in the arithmetic; do not derive from current time.

You can then delete _sinceEpoch, or (if you prefer keeping a helper) make it take the reference timestamp explicitly:

and call:

Proof of Concept

Was this helpful?