Snowman Merkle Airdrop

First Flight #42
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: high
Valid

No access control in mintSnowman

Root + Impact

Description

  • NFT minting should normally be restricted to a certain set of privileged addresses

  • This contract allows anyone to mint an NFT for free

function mintSnowman(address receiver, uint256 amount) external { //no access control
for (uint256 i = 0; i < amount; i++) {
_safeMint(receiver, s_TokenCounter);
emit SnowmanMinted(receiver, s_TokenCounter);
s_TokenCounter++;
}
}

Risk

Likelihood:

  • Anyone can call mintSnowman and mint as many NFTs as they want

Impact:

  • The whole staking process is bypassed and users can claim the NFT at no cost

Proof of Concept

  1. Alice calls mintSnowman and gets free NFTs

Recommended Mitigation

Implement access control so that only the airdrop contract may call mintSnowman on behalf of users.

+ modifier onlyAirdrop() {
if (msg.sender != s_airdropContract) {
revert S__NotAllowed();
}
_;
}
+ function mintSnowman(address receiver, uint256 amount) external onlyAirdrop{
for (uint256 i = 0; i < amount; i++) {
_safeMint(receiver, s_TokenCounter);
emit SnowmanMinted(receiver, s_TokenCounter);
s_TokenCounter++;
}
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Unrestricted NFT mint function

The mint function of the Snowman contract is unprotected. Hence, anyone can call it and mint NFTs without necessarily partaking in the airdrop.

Support

FAQs

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