Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing check for newThreshold in setEggFindThreshold() __ EggHuntGame.sol

Summary

The setEggFindThreshold function only checks that newThreshold is less than or equal to 100, but does not check whether it is greater than or equal to 20.

Vulnerability Details

If the owner accidentally sets eggFindThreshold = 0, it would make it impossible to find eggs.

/// @notice Allows the owner to adjust the egg-finding chance.
function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= 100, "Threshold must be <= 100");
eggFindThreshold = newThreshold;
}

Impact

Threshold could be set to zero making the game unplayable

Could lead to confusion among users.

Tools Used

Manual review

Recommendations

Add a check to ensure the threshold is not too low:

require(newThreshold >= 20, "Threshold cannot be less than 20");
Updates

Lead Judging Commences

m3dython Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!