Anyone can collect a NFT through the SantasList::collectPresent()
function without having been checked twice previously because all addresses have the status NICE
and are checked twice by default.
The mappings SantasList::s_theListCheckedOnce
and SantasList::s_theListCheckedTwice
use address
as key and SantasList::Status
as values. If you retrieve a non changed or non initialized value from any of these two mappings using any address as key, you will get the default value of the SantasList::Status
enum.
Enums are a custom type of enumerated unsigned integers. Its value starts at 0
and goes up to the amount of enum values - 1
.
Let's use SantasList::Status
as an example:
The first value, NICE
, is equal to 0
, EXTRA_NICE
is equal to 1
, NAUGHTY
is equal to 2
, and NOT_CHECKED_TWICE
is equal to 3
.
When you don't initialize a unsigned integer with a value, its default value will be 0
. The same happens to enums. So the default value of the SantasList::Status
enum is NICE
.
Knowing this, when you retrieve the default status of an address from SantasList::s_theListCheckedOnce
or SantasList::s_theListCheckedTwice
you will receive the value NICE
.
Apply the following diff:
And run the testAllAddressesAreNiceAndDoubleCheckedByDefault
test:
Anyone can collect a NFT through the SantasList::collectPresent()
function without having been checked twice previously.
Manual Review
GNU Emacs (solidity-mode + magit)
Foundry test
Add a UNKNOWN
enum value above NICE
inside SantasList::Status
enum:
So the default value of SantasList::Status
will be UNKNOWN
instead of NICE
.
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.