searchForEgg function is vulnerable as the user can create N number of new addresses and call the function in the same block and each one will have a 20% chance of getting the prize, there is no limit for this.
searchForEgg function allows the user mint as much NFTs as he wants all at once. The attacker can set a script to use N different addresses to call that function in N different transactions in the same block or can he simply make a contract that is a factory of new contracts that will be used to call the `searchForEgg` function.
Since the msg.sender is the only thing the user can alter he can simply spam multiple of his addresses and it each one has a 20% chance of minting a new NFT.
https://github.com/CodeHawks-Contests/2025-04-eggstravaganza/blob/main/src/EggHuntGame.sol#L63-L81
foundry test: [PASS] testMint() (gas: 256705)
Logs:
3
3 NFTs minted all in one call, but can be set to as many addresses the attacker wants.
pseudo-numbers are not safe and should never be used in production as they are predictable.
Foundry
use RNG from Chainlink instead to secure true random numbers.
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.