The EggHuntGame::searchForEgg
function uses an insecure source of randomness that relies on predictable on-chain values. This makes the game's outcomes potentially manipulable by attackers, compromising the fairness of the egg hunt game.
The current implementation generates randomness using the following components:
block.timestamp
- Can be slightly influenced by miners
block.prevrandao
- More secure but still predictable in certain scenarios
msg.sender
- Known value
eggCounter
- On-chain value that can be monitored
An attacker could monitor the blockchain and submit a transaction when block.timestamp
and eggCounter
align favorably:
In Ethereum's Proof-of-Stake context:
Validators are selected in advance, making block proposers known approximately 2 epochs (64 blocks) ahead
While block.prevrandao provides better randomness than the previous block.difficulty, it's still derived from the RANDAO process which has its own limitations
Validators can still manipulate block.timestamp within a small window
Sophisticated validators could potentially withhold or reorder transactions to gain advantage
Even in a PoS environment, the weak randomness implementation allows validators or advanced users to:
Calculate probable outcomes by knowing validator sequences and observing on-chain state
Time transactions to coincide with favorable randomness conditions
For validators themselves, potentially influence transaction ordering or inclusion
Gain an unfair advantage in the egg hunt game
This undermines the fairness of the game and could lead to uneven NFT distribution.
Despite the move to Proof-of-Stake, truly secure randomness still requires external solutions. Chainlink VRF remains the recommended approach:
Insecure methods to generate pseudo-random numbers
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.