Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Dangerous Usage of Block Timestamps

Summary

The ScoreBoard and ThePredicter contracts contain several instances where block timestamps are used for critical comparisons. Reliance on block.timestamp can be dangerous because it can be manipulated, potentially leading to unexpected and exploitable behavior in the contracts.

Vulnerability Details

ScoreBoard.setPrediction

  • Location: ScoreBoard.setPrediction (src/ScoreBoard.sol#60-70)

  • Dangerous Comparison:

if (block.timestamp <= START_TIME + matchNumber * 68400 - 68400) {
revert PredictionsAreClosed();
}

ThePredicter.register

  • Location: ThePredicter.register (src/ThePredicter.sol#43-57)

  • Dangerous Comparison:

if (block.timestamp > START_TIME - 14400) {
revert ThePredicter__RegistrationIsOver();
}

ThePredicter.makePrediction

  • Location: ThePredicter.makePrediction (src/ThePredicter.sol#83-94)

  • Dangerous Comparison:

if (block.timestamp > START_TIME + matchNumber * 68400 - 68400) {
revert ThePredicter__PredictionsAreClosed();
}

Impact

Since block.timestamp can be manipulated within a certain range, using it for critical comparisons can lead to unpredictable and exploitable behavior. Attackers could potentially manipulate the timestamp to benefit from certain conditions being met or avoided.

Tools Used

Manual code

Recommendations

  • Avoid Using Block Timestamps for Critical Comparisons: Instead of relying on block.timestamp, consider using mechanisms that are not susceptible to miner manipulation. For example, use block numbers for time comparisons and calculate elapsed time using the block number and average block time.

  • Implement Time Windows: For time-sensitive operations, define acceptable time windows and ensure the logic can tolerate minor deviations in block timestamps.

  • Use Oracle Services: For high-stakes scenarios, consider using off-chain oracle services like Chainlink to provide reliable time data.

Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.