Description
The function SpookySwap::addTreat
doesn't validate if a treat has been already created with the _name
parameter, also it doesn't check if the _rate
parameter is greater than zero.
Impact
An already created treat can be overwritten by a totally new treat with the same name, but different cost and metadata. This would make the first treat no longer valid for future possible mintings. Also, allowing a treat to have a cost of zero would make the protocol to lose money as the minting would be for free.
Proof of Concepts
Create a test file named TrickOrTreat.t.sol
and include the following code.
Tools Used
Foundry, VsCode
Recommended mitigation
Add _name
and _rate
parameter checkers in the SpookySwap::addTreat
function to verify no Treat has been created with that name already and that the cost is not set to 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 function `addTreat` is called by the owner. The owner is trusted. There will be no duplicates.
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.