Eggstravaganza

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

Insecure randomness used in EgssHuntGame.sol

Summary

The EggHuntGame.sol contract uses keccak256 with predictable inputs to generate random values. This approach is insecure on public blockchains, especially in game logic where fair randomness is critical.

Vulnerability Details

uint256 random = uint256(
keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
) % 100;

This method of generating randomness is deterministic and can be influenced or predicted by miners or users. Since block.timestamp and msg.sender are known or partially controllable values, attackers can game the system to gain an unfair advantage during prize distribution or gameplay.

Impact

  • Attackers may predict or manipulate the outcome of random events.

  • Players can gain unfair advantages, compromising the fairness and integrity of the game.

  • This undermines trust in the game’s outcomes and opens up potential economic exploits.

Tools Used

  • Manual code inspection

  • Solidity anti-pattern identification

Recommendations

  • Replace the current randomness logic with Chainlink VRF or a similar verifiable randomness solution.

  • Avoid using block.timestamp, blockhash, or msg.sender alone in any randomness logic.

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.