The EggHuntGame
contract uses an insecure method for generating randomness based on predictable blockchain parameters; it uses keccak256
with a combination of block.timestamp
, block.prevrandao
, msg.sender
, and eggCounter
. These numbers are predictable so a threat actor could simulate the randomness off-chain with a malicious contract and only submit transactions when a successful mint is guaranteed.
The random number is calculated using this code:
This is an issue because block.timestamp
and block.prevrandao
are known or predictable by the time the transaction is minted. msg.sender
is controlled by the attacker; and eggCounter
is either known or easily bruteforceable on-chain.
Since the modulo operation doesn't provide cryptographic randomness, a threat actor could simulate this PRNG logic off-chain and determine in advance whether a call to searchForEgg()
would result in a successful mint or not (e.g., if the result is less than the game's eggFindThreshold..
25`).
A threat actor could:
Avoid wasting gas on failed mint attempts
Game the mint system to mint multiple eggs
Gain a significant advantage over legitimate players
Undermine the integrity and fairness of the game
This creates centralization of rewards and opens the protocol up to abuse by botting/scripting.
Foundry (forge, anvil, cast)
VS Code
An Anvil testnet (chain ID: 31337)
Step 1: Create a Simulator Contract
Step 2: Deploy Using Foundry Script
Run with anvil
- in a new terminal:
Deploy locally to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Step 3: Simulate On-Chain Behavior with cast
Example input:
Returns:
0x...000f → decimal 15 ✅ Guaranteed Mint (under 25)
Step 4: Automate with Bash Script
Output (Truncated):
This demonstrates how the outcome can be predicted and exploited without ever touching the real game contracts.
To mitigate this, use a secure randomness source like:
Chainlink VRF
RANDAO + user commit-reveal schemes (with proper timing separation)
Off-chain oracles with verifiable signatures
Avoid relying on block values like timestamp
, prevrandao
, or block.number
for randomness - these are either manipulable or predictable.
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.