The setEggFindThreshold
function contains an input validation gap that allows the threshold to be set to 0%, which would make it impossible for players to find eggs, potentially leading to an unplayable game state.
The setEggFindThreshold
function in the EggHuntGame contract validates that the new threshold value is not greater than 100, but fails to validate that it is greater than 0:
This allows the contract owner to set the threshold to 0%, which would make the random number generation in the searchForEgg
function always fail the condition:
When eggFindThreshold
is 0, the condition will never be true because any random number from 0-99 will not be less than 0, making it impossible for players to find eggs.
Owner calls setEggFindThreshold(0)
Players call searchForEgg()
repeatedly
No eggs are ever found because random < 0
will always be false
Setting the threshold to 0 would result in:
Players wasting gas on transactions that can never succeed
Game becoming functionally broken
Loss of player trust and engagement
Manual Review
Add a lower bound check to the setEggFindThreshold
function:
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.