In the SantasList contract only those users are allowed to collect present who are checked twice by santa but even though if the user is not checked twice by santa then also users can collect their present due mishandling of the Status enum .
In enum Status, NICE is present at 0th position, also the mapping s_theListCheckedOnce
and s_theListCheckedTwice
store the default value 0 by default which means everyone will be NICE by default in both the mapping and they can call the collectPresent function even though they are not even checked by santa and get the NFT.
This vulnerability exists in the SantasList::Status enum in the SantasList.sol file starting on line 69. The Status has NICE at 0th position and as both the mapping starting from line 79 and ending at 80 will have 0 as their default values which corresponds to NICE of the Status enum, therefore every user will be NICE by default and they can call the collectPresent
function on SantasList contract and collect the NFT without even getting checked by Santa.
The Santa only wants to allow those users to call collectPresent function which are checked by him as NICE or EXTRA_NICE but if a user who is not checked by him should not be able to call it and it should revert.
But due the mishandling of Status enum, everyone will be NICE by default, so all the unchecked users will be NICE and they will be able to mint the NFT by calling the collectPresent function
Refactor the import in file test/unit/SantasListTest.t.sol
: (Vm is used to get array to get the Log array to store recorded event logs)
to
Add the test in the file test/unit/SantasListTest.t.sol
Run the test:
Manual Review, Foundry Test
In the Status
enum of SantasList contract, move NOT_CHECKED_TWICE
to 0th position, so that every user will now be not checked by default as it will be at 0th position and both mapping s_theListCheckedOnce
and s_theListCheckedTwice
will now be NOT_CHECKED_TWICE by default.
In Solidity the first element of an enum is the default value. In Santa's List, the means each person is mapped by default to 'NICE'.
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.