Description
Inside the SpookySwap::setTreatCost
function the parameter _cost
is never checked to be greater than zero, and since the require statement, require(treatList[_treatName].cost > 0, "Treat must cost something.");
, checks that the Treat must have had a value greater than zero alredy, it prevents the Treat cost to be updated again.
Impact
The function allows that the cost of any Treat can be updated to zero, hence minting these kinds of NFTs will be for free. And since the require(treatList[_treatName].cost > 0, "Treat must cost something.");
validates that in order to update the cost of a Treat, its previous value must have been greater than zero before, prevents that a new cost could be set; making the Treat free to mint forever.
Proof of Concepts
Create a test file named TrickOrTreat.t.sol
and include the following code.
Tools Used
Foundry, VsCode
Recommended mitigation
Add also a validation in the function to check if the new cost is greater than zero.
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.
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.