Root Cause: setTreatCost has incorrect validation logic
Impact: Treats could be set to cost 0, contrary to the requirement check.
https://github.com/Cyfrin/2024-10-trick-or-treat/blob/main/src/TrickOrTreat.sol#L43-L46
The setTreatCost
function has a logical error in its validation:
The function checks if the current cost is > 0, but doesn't validate the new cost, allowing setting a zero cost.
cost can be set to zero, allows users to get free nft
Manual Review
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.