Description:
The searchForEgg() function uses a pseudo-random number generation that can be manipulated by miners/attackers:
This uses block.timestamp and block.prevrandao which are both values that can be influenced by miners. Combined with msg.sender and eggCounter which are predictable, this makes the randomness weak and exploitable.
Impact:
Attackers can predict or manipulate the outcome of egg finding attempts, allowing them to game the system and find eggs more frequently than intended. This breaks the fairness of the game and could allow attackers to accumulate all available eggs.
Proof of Concept:
A miner notices an egg search transaction in the mempool
They manipulate block.timestamp and block.prevrandao to ensure the random number is below threshold
The miner includes the transaction in a block with their manipulated values
The miner's address always finds eggs, accumulating all NFTs unfairly
Recommended Mitigation:
Use a more robust randomness solution such as:
Chainlink VRF for verifiable randomness
Commit-reveal scheme
Oracle-based randomness
At minimum, use more unpredictable inputs like blockhash of previous blocks
Impact: High
Likelihood: High
Severity: HIGH/Crit
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.