Eggstravaganza

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

Insecure Pseudo-Random Number Generation in EggHuntGame

Summary

The EggHuntGame contract uses a predictable method to generate pseudo-random numbers for determining whether a player finds an egg. This vulnerability allows miners or attackers to manipulate the outcome by controlling block variables (block.timestamp, block.prevrandao), leading to unfair advantages in the game.

Vulnerability Details

Location:
EggHuntGame::searchForEgg()

Issue:
The randomness is derived from:

uint256 random = uint256(
keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
) % 100;
  • Predictability: block.timestamp and block.prevrandao are public and can be influenced by miners/validators.

  • Front-running Risk: Attackers can compute the expected random number before submitting a transaction and only proceed if favorable.

  • No Entropy: The seed lacks external unpredictability (e.g., oracle inputs).

Impact

Attackers can guarantee egg discoveries, breaking game fairness -- making them monopolize rewards, devaluing NFTs for legitimate participants.

Tools Used

  • Manual code review.

Recommendations

Use Chainlink VRF
Integrate Chainlink’s Verifiable Random Function (VRF) for cryptographically secure randomness.

Updates

Lead Judging Commences

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

Give us feedback!