The function generates a pseudo-random number using keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
, which is predictable and can be manipulated.
The randomness is derived from predictable values like block.timestamp
and block.prevrandao
.
Attackers can manipulate these values to increase their chances of finding an egg, and miners can influence the randomness by selecting favorable timestamps.
The pseudo-random number generation is not secure, which could lead to unfair advantages in the game and potential exploitation by miners or malicious users.
Solidity
VS code
Use Chainlink VRF (Verifiable Random Function) for truly random numbers instead of relying on block-based randomness. This provides cryptographically secure randomness.
Alternative Solution: Consider using block.difficulty
in earlier versions or other external oracles to improve randomness security.
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.