Eggstravaganza

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

Predictable Randomness in Egg Finding

Summary

The `searchForEgg` function in `EggHuntGame.sol` uses a pseudo-random number generation method that includes `block.timestamp`, making the outcome potentially predictable and exploitable.

Vulnerability Details

The searchForEgg function generates a random number using keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter)) % 100.

While `block.prevrandao` offers some randomness, the inclusion of `block.timestamp` introduces a degree of predictability, especially within short timeframes.

Impact

players might be able to strategically time their `searchForEgg` transactions based on the current `block.timestamp` to increase their chances of finding an egg. This can lead to an unfair advantage over other participants in the game.

Recommendations

For secure and unbiased random number generation on-chain, it's advisable to use external oracles, verifiable off-chain computations, or cryptographic methods that are less susceptible to manipulation.

Updates

Lead Judging Commences

m3dython Lead Judge 4 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.