The function EggHuntGame.searchForEgg()
uses a predictable randomness to produce a eggFindThreshold
The function EggHuntGame.searchForEgg()
uses block.timestamp ,block.prevrandao , address(msg.sender),eggCounter to produce the random ,those are easily to be predicted.
attacker can call the searchforegg function when the random less than eggFindThreshold,here is 20.
Causing attacker can find the egg 100 percent.
slither
Put this code into the EggHuntGameTest.t.sol
The Log Results
Logs:
previousEggCounter 0
random 74
random 81
random 72
random 56
random 46
random 0
attackereggcounter 1
Use the chainlink oracle instead of the block.timestamp that can be 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.