Eggstravaganza

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

Owner shouldn't be able to set the eggFindThreshold to 0

Description

The eggFindThreshold variable controls the percentage to find an egg by calling searchForEgg(), which is the crucial point of the whole game.

The admin can change it via the setEggFindThreshold() function in a range between 0 and 100:

function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= 100, "Threshold must be <= 100");
eggFindThreshold = newThreshold;
}

By setting this value to 0 the admin can make finding eggs impossible since they're only minted if the generated random number is less than the eggFindThreshold... which will be always false in this scenario.

if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
eggNFT.mintEgg(msg.sender, eggCounter);
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}

Tools Used

  • Manual review

Recommendation

Define a reasonable and greater than 0 minimum value for eggFindThreshold.

Updates

Lead Judging Commences

m3dython Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Trusted Owner

Owner is trusted and is not expected to interact in ways that would compromise security

Support

FAQs

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