Root Cause: No validation for empty strings or duplicate treat names
Impact: Potential contract state confusion and unusable treats
https://github.com/Cyfrin/2024-10-trick-or-treat/blob/main/src/TrickOrTreat.sol#L37-L41
The addTreat
function doesn't validate that treat names are non-empty strings and doesn't prevent duplicate treat names. This could lead to confusion in the contract state and potential issues with treat identification.
If a treat is already exists, it just overrides that with new values.
Confusion in treat identification
Potential overrding of existing values that can affect users
Manual Review
Here is the recomendation that can be implemented to avoid these issues -
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.