Eggstravaganza

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

Insecure randomess generator logic which doesn't even work on some EMV chains

Description

Randomness in the EggHuntGame is generated on-chain which is totally predictable since blockchains are deterministic:

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

Additionally, not all EVM-compatible chains implement the PREVRANDO opcode, and even those who does it have different implementations, for example:

  • Scroll: always returns 0

  • ZKsync Era: always returns a constant value of 2500000000000000

Impact

In the examples above it will be useless to generate a random number but, on other chains that does not support the opcode, the game contract may not be even deployable at all.

Tools Used

  • Manual review

Recommendation

Use off-chain solutions like ChainLink VRF or Gelato VRF which generate truly random numbers and are supported on most EVM-compatible chains.

Updates

Lead Judging Commences

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