Medium–High Severity

Timestamp Manipulation
block.timestamp Is Not Trustworthy

block.timestamp looks like a clock, but it's a number everyone can know before your transaction runs. A contract that uses it for randomness, lotteries, or races decided by a few seconds can be gamed, by validators on some chains and by ordinary users on all of them.

QUICK ANSWER

Can Ethereum validators manipulate block.timestamp after the Merge?

No, not on Ethereum mainnet. Since September 15, 2022, every block's timestamp must equal the genesis time plus 12 seconds times its slot number, and a block with any other value is invalid. A proposer can only skip its slot, which moves the next timestamp 12 seconds later. But every slot's timestamp is known in advance, so block.timestamp is still unsafe for randomness: an attacker contract can compute the outcome in the same transaction and revert unless it wins.

What Changed at the Merge, and What Didn't

Under proof of work, the miner chose each block's timestamp, and clients only required it to be later than the parent and not too far in the future. That discretion is where the old advice about miners shifting timestamps comes from. Since the Merge, Ethereum mainnet fixes each block's timestamp to its 12-second slot, and a proposer's only option is to skip the slot entirely.

That closed one hole and left a bigger one open: every future timestamp is known in advance. A contract that uses block.timestamp for randomness (e.g. block.timestamp % 2 == 0 decides the winner) can be gamed by anyone who calls it at the right moment, or who calls it from a contract that reverts unless the result favors them. On L2s and other EVM chains, the block producer may still have some say over the value too.

Most Dangerous Use Cases

•
Lottery / game outcomes: Winner determined by timestamp arithmetic
•
Races decided by seconds: On mainnet you only get 12-second slot precision, and some L2 sequencers have leeway; whoever lands in the right block wins
•
Randomness seed generation: block.timestamp used as entropy source for random number
•
Token vesting schedules: Fine if measured in days — risky if measured in seconds
•
Broad expiry checks: Hours or days of tolerance — acceptable use
Real-World Exploits

GovernMental (2016)

The textbook timestamp-dependence case. The jackpot went to the last investor if 12 hours passed without a new one, and the contract measured that with block.timestamp, a value proof-of-work miners could nudge in their own favor.

Fomo3D (2018): a timing attack

The round's timer reset with every purchase, so the last buyer before it expired won. The winner filled blocks with high-fee transactions so no one else's purchase could land before the timer ran out, and took about 10,469 ETH. Any game decided by "who acts last before a deadline" invites this.

Frequently Asked Questions

Can Ethereum validators manipulate block.timestamp after the Merge?+

Not on Ethereum mainnet. Since the Merge (September 15, 2022), blocks are produced in fixed 12-second slots, and a block's timestamp must equal the chain's genesis time plus 12 seconds times the slot number. A block with any other timestamp is invalid. The only lever a proposer has is to skip its slot, which pushes the next block's timestamp 12 seconds later and costs them the block reward.

How much can block.timestamp be manipulated?+

On Ethereum mainnet since the Merge: not at all, beyond a proposer skipping its slot (+12 seconds). Under proof of work, miners could choose the timestamp within the limits their client enforced, which is where the old advice about drift windows comes from. On L2s and other EVM chains the rules differ, and the sequencer or block producer may have some leeway, so check that chain's documentation before relying on second-level precision.

If validators can't change it, why is block.timestamp still unsafe for randomness?+

Because it's predictable. Every future slot's timestamp is known in advance, and an attacker doesn't need to be a validator: they can call your contract from their own contract, compute block.timestamp % N in the same transaction, and revert unless the result favors them. They only pay gas for the attempts they win.

When is it safe to use block.timestamp in Solidity?+

For measuring elapsed time: vesting schedules, lock periods in minutes, hours or days, sale windows, cooldowns and signature deadlines. On mainnet it's accurate to the 12-second slot, and since the Merge it's a better clock than block.number, which drifts whenever a slot is missed. Never use it to pick a winner, seed randomness, or decide a race between users who act within the same few seconds.

Has timestamp dependence caused real exploits?+

GovernMental (2016) is the textbook case: its jackpot went to the last investor if 12 hours passed without a new one, timed with block.timestamp, which proof-of-work miners could nudge. A related timing attack hit Fomo3D in 2018: a round whose timer reset with every purchase was won by a player who filled blocks with high-fee transactions so no one else could buy before it ran out, taking about 10,469 ETH.

What should I use instead of block.timestamp for randomness?+

Chainlink VRF, which delivers random numbers with an on-chain proof, or a commit-reveal scheme where no single party controls the result. block.prevrandao is better than block.timestamp but can still be biased slightly by a proposer who chooses to skip a slot, so don't use it alone for anything valuable. SmartContractAuditor.ai flags block.timestamp, block.number, blockhash and prevrandao used as randomness.

Scan for Timestamp Vulnerabilities

Our scanner flags every block.timestamp dependency in your contract, tells you which ones are exploitable, and suggests the right fix.

Free vulnerability scan • Instant results • No credit card required