Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Any user who has not yet been checked can collect NFTS, because it has NICE status

Summary

By default, a user who has not yet been checked has the status Nice.
The first value in the SantaList::Status enum must be selected with care.

Vulnerability Details

enum Status {
@> NICE,
EXTRA_NICE,
NAUGHTY,
NOT_CHECKED_TWICE
}
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
if (balanceOf(msg.sender) > 0) {
revert SantasList__AlreadyCollected();
}
@> if (s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE) {
_mintAndIncrement();
return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE
&& s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
_mintAndIncrement();
i_santaToken.mint(msg.sender);
return;
}
revert SantasList__NotNice();
}
@> function getNaughtyOrNiceOnce(address person) external view returns (Status) {
return s_theListCheckedOnce[person];
}

"The default value of an enum is it's first member"
(https://docs.soliditylang.org/en/latest/control-structures.html#scoping-and-declarations).
so the default value of SantasList::Status is NICE.
therefore by default the functions SantasList::getNaughtyOrNiceOnce and SantasList::getNaughtyOrNiceTwice
will return NICE for any user who has not yet been checked out.
which means that calling the function SantasList::collectPresent with this type of user will
mint the NFT instead of reverting.

Impact

Any user who has not yet been checked can mint SantaList's NFT 
every time they can call the `SantaList::collectPresent` function

Tools Used

-Foundry

Recommendations

Add a new value to the enum SantaList::Status and place it as the first element in the list as follows:

enum Status {
NOT_CHECKED_ONE,
NICE,
EXTRA_NICE,
NAUGHTY,
NOT_CHECKED_TWICE
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

default status is 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'.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.