Eggstravaganza

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

Insecure Randomness for Game Logic

Summary

The contract uses insecure, predictable pseudo-random number generation to determine if a player finds an egg, making it susceptible to manipulation.

Vulnerability Details

uint256 random = uint256(
keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
) % 100;
if (random < eggFindThreshold) {
...
}
  • The random number is based on block.timestamp, block.prevrandao, and msg.sender, which are predictable by users and miners.

  • This allows manipulation of input parameters to consistently win the egg.

Impact

Players (especially bots or miners) can predict or brute-force winning attempts, severely compromising fairness and integrity of the game.

Tools Used

Manual review

Recommendations

  • For simple games, use Chainlink VRF (Verifiable Random Function) for secure randomness.

  • If using pseudo-random logic for demonstration, clearly document its insecurity and restrict for testing only.

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.