Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Predictable Randomness in searchForEgg()

Summary

The function generates a pseudo-random number using keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter)), which is predictable and can be manipulated.

Vulnerability Details

  • The randomness is derived from predictable values like block.timestamp and block.prevrandao.

  • Attackers can manipulate these values to increase their chances of finding an egg, and miners can influence the randomness by selecting favorable timestamps.

Impact

  • The pseudo-random number generation is not secure, which could lead to unfair advantages in the game and potential exploitation by miners or malicious users.

Tools Used

  • Solidity

  • VS code

Recommendations

  1. Use Chainlink VRF (Verifiable Random Function) for truly random numbers instead of relying on block-based randomness. This provides cryptographically secure randomness.

  2. Alternative Solution: Consider using block.difficulty in earlier versions or other external oracles to improve randomness security.

Updates

Lead Judging Commences

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Insecure Randomness

Insecure methods to generate pseudo-random numbers

Support

FAQs

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