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

`SantasList::collectPresent()` has invalid logic

Summary

SantasList::collectPresent() has invalid logic that leads to possibility of minting multiple NFTs/ERC20s. User once receive present can sent NFT to another wallet and call the function once again.

Vulnerability Details

The function lacks proper method for flagging users that claimed presenets.

Impact

High, user can abuse the function leading to minting arbitrary amount of NFTs/ERC20s.

Tools Used

Manaual Review + foundry

Recommendations

add mapping on SantasList

+ mapping(address => bool) public userClaimedPresent;
function collectPresent() external {
+ if(userClaimedPresent[msg.sender]) {
+ revert SantasList__AlreadyCollected();
+ }
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
) {
+ userClaimedPresent[msg.sender] = true;
_mintAndIncrement();
return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE &&
s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
+ userClaimedPresent[msg.sender] = true;
_mintAndIncrement();
i_santaToken.mint(msg.sender);
return;
}
revert SantasList__NotNice();
}
Updates

Lead Judging Commences

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

Weak Already Collected Check

Relying on balanceOf > 0 in collectPresent() allows the msg.sender to send their present to another address and then collect again.

Support

FAQs

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