Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Incorrect check of treat cost in setTreatCost function leads to function becoming uninvokable after treat cost is set to zero.

Incorrect check of treat cost in setTreatCost function leads to uninvokable function after treat cost is set to zero.

Description:
In setTreatCost function, if cost is set to zero once, then the function cannot be called again as the require statement check will always revert.

Impact:
If cost is set to zero once, it will lead to denial of service of the setTreatCost function.

Proof of concept:
Add the following test case and run the forge test command.

function test_dosAfterZeroTreatCost() external {
vm.startPrank(owner);
tot.setTreatCost(treats[0].name, 0);
vm.expectRevert("Treat must cost something.");
tot.setTreatCost(treats[0].name, 123);
vm.stopPrank();
}

Recommended Mitigation:
Replace the cost check with below statement.

- require(treatList[_treatName].cost > 0, "Treat must cost something.");
+ require(_cost > 0, "Treat must cost something.");
Updates

Appeal created

bube Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[invalid] Zero treat cost

The cost of the treat is set only by the owner (in the constructor, in addTreat and in setTreatCost). That means the cost of the treat will always be greater than zero.

Support

FAQs

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