The searchForEgg
function in the smart contract relies on an insecure method of generating randomness using on-chain variables such as block.timestamp
, block.prevrandao
, msg.sender
, and eggCounter
. This approach allows attackers to guess the outcome and mint an EggstravaganzaNFT
.
The vulnerability arises from the following line in the searchForEgg
function:
uint256 random = uint256(keccak256(abi.encodePacked(block.timestamp,block.prevrandao, msg.sender,eggCounter))) % 100;
This method is not truly random because an attacker can estimate block.timestamp
, block.prevrandao
, and eggCounter
values since they are publicly accessible or can be influenced.
An attacker can manipulate randomness to increase their chances of finding EggstravaganzaNFT
unfairly, affecting game integrity.
Manual code review
Consider generating random numbers off-chain, either using services like Chainlink VRF or using your own internal server.
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.