Snowman Merkle Airdrop

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

Missing claim check on s_hasClaimedSnowman allows repeated NFT claims via proof replay

Root + Impact

Description

Root Cause: s_hasClaimedSnowman[receiver] is written at L94 but is never read anywhere in claimSnowman. The only effective deduplication is the balanceOf(receiver) == 0 check at L76, which relies on the live Snow balance being zero.


​
// SnowmanAirdrop.sol L47
mapping(address => bool) private s_hasClaimedSnowman;
// @> Declared to "verify if an address has claimed", but never read in claimSnowman
​
// L76 — the only effective deduplication
if (i_snow.balanceOf(receiver) == 0) {
revert SA__ZeroAmount();
}
// @> Dedup relies on the live Snow balance, not on s_hasClaimedSnowman
​
// L94
s_hasClaimedSnowman[receiver] = true;
// @> Written here, but no `if (s_hasClaimedSnowman[receiver]) revert;` exists anywhere in the function
​
// L138 — the only read path
function getClaimStatus(address claimant) external view returns (bool) {
return s_hasClaimedSnowman[claimant];
}
// @> Only exposed via a getter; the claim path never consults it

Risk

Likelihood:

Impact:A whitelisted address can claim NFTs repeatedly by restoring its Snow balance to the exact value stored in its Merkle leaf. Each replay transfers the same amount of Snow into the contract and mints the same amount of NFTs. getClaimStatus(receiver) returns true throughout, but this value places no constraint on the claim path.

Proof of Concept

## Proof of Concept
​
### Environment
- Foundry 1.8.5
- Solidity 0.8.24
- Contracts under test: `src/Snow.sol`, `src/Snowman.sol`, `src/SnowmanAirdrop.sol` (unmodified)
​
### Test file
`test/DoubleClaim.t.sol`
​
### Setup
The Merkle root contains exactly one leaf: `(victim, 1)`.
`Snow` is deployed with `_buyFee = 1`, i.e. `s_buyFee = 1e18 wei = 1 ETH per Snow`.
​
### Attack
1. `victim` calls `earnSnow()` to obtain 1 `Snow`.
2. `victim` signs the EIP-712 digest **once** via `airdrop.getMessageHash(victim)`.
3. `claimSnowman(victim, proof, v, r, s)` succeeds. `getClaimStatus(victim)` returns `true`.
4. `L92` transfers the whole balance away, so `balanceOf(victim) == 0`.
5. `victim` restores the balance to exactly 1 — either by `earnSnow()` after one week,
or instantly by `buySnow{value: 1 ether}(1)`.
6. **The identical `(v, r, s)` and the identical `proof` are submitted again.**
All checks at `L76`, `L80` and `L88` pass again because they depend on the live
balance, not on `s_hasClaimedSnowman`.
7. Steps 5–6 repeat without limit.
​
### Core assertion
```solidity
(v, r, s) = vm.sign(VICTIM_PK, airdrop.getMessageHash(victim)); // signed once
airdrop.claimSnowman(victim, new bytes32[](0), v, r, s); // NFT #1
assertTrue(airdrop.getClaimStatus(victim)); // "already claimed"
​
vm.warp(block.timestamp + 1 weeks);
snow.earnSnow(); // balance back to 1
airdrop.claimSnowman(victim, new bytes32[](0), v, r, s); // NFT #2, same signature
vm.warp(block.timestamp + 1 weeks);
snow.earnSnow();
airdrop.claimSnowman(victim, new bytes32[](0), v, r, s); // NFT #3
assertEq(nft.balanceOf(victim), 3); // flag was true the whole time

Recommended Mitigation

- remove this code
+ add this code
// SnowmanAirdrop.sol
​
// 1) Declare the new error at the top of the contract
+ error SA__AlreadyClaimed();
​
function claimSnowman(address receiver, bytes32[] calldata merkleProof, uint8 v, bytes32 r, bytes32 s)
external
nonReentrant
{
if (receiver == address(0)) {
revert SA__ZeroAddress();
}
​
+ // Reject a second claim: read the marker that is already written at L94
+ if (s_hasClaimedSnowman[receiver]) {
+ revert SA__AlreadyClaimed();
+ }
​
if (i_snow.balanceOf(receiver) == 0) {
revert SA__ZeroAmount();
}
​
// ... rest of the function unchanged ...
}
Updates

Lead Judging Commences

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

[L-01] Missing Claim Status Check Allows Multiple Claims in SnowmanAirdrop.sol::claimSnowman

# Root + Impact   **Root:** The [`claimSnowman`](https://github.com/CodeHawks-Contests/2025-06-snowman-merkle-airdrop/blob/b63f391444e69240f176a14a577c78cb85e4cf71/src/SnowmanAirdrop.sol#L44) function updates `s_hasClaimedSnowman[receiver] = true` but never checks if the user has already claimed before processing the claim, allowing users to claim multiple times if they acquire more Snow tokens. **Impact:** Users can bypass the intended one-time airdrop limit by claiming, acquiring more Snow tokens, and claiming again, breaking the airdrop distribution model and allowing unlimited NFT minting for eligible users. ## Description * **Normal Behavior:** Airdrop mechanisms should enforce one claim per eligible user to ensure fair distribution and prevent abuse of the reward system. * **Specific Issue:** The function sets the claim status to true after processing but never validates if `s_hasClaimedSnowman[receiver]` is already true at the beginning, allowing users to claim multiple times as long as they have Snow tokens and valid proofs. ## Risk **Likelihood**: Medium * Users need to acquire additional Snow tokens between claims, which requires time and effort * Users must maintain their merkle proof validity across multiple claims * Attack requires understanding of the missing validation check **Impact**: High * **Airdrop Abuse**: Users can claim far more NFTs than intended by the distribution mechanism * **Unfair Distribution**: Some users receive multiple rewards while others may receive none * **Economic Manipulation**: Breaks the intended scarcity and distribution model of the NFT collection ## Proof of Concept Add the following test to TestSnowMan.t.sol  ```Solidity function testMultipleClaimsAllowed() public { // Alice claims her first NFT vm.prank(alice); snow.approve(address(airdrop), 1); bytes32 aliceDigest = airdrop.getMessageHash(alice); (uint8 v, bytes32 r, bytes32 s) = vm.sign(alKey, aliceDigest); vm.prank(alice); airdrop.claimSnowman(alice, AL_PROOF, v, r, s); assert(nft.balanceOf(alice) == 1); assert(airdrop.getClaimStatus(alice) == true); // Alice acquires more Snow tokens (wait for timer and earn again) vm.warp(block.timestamp + 1 weeks); vm.prank(alice); snow.earnSnow(); // Alice can claim AGAIN with new Snow tokens! vm.prank(alice); snow.approve(address(airdrop), 1); bytes32 aliceDigest2 = airdrop.getMessageHash(alice); (uint8 v2, bytes32 r2, bytes32 s2) = vm.sign(alKey, aliceDigest2); vm.prank(alice); airdrop.claimSnowman(alice, AL_PROOF, v2, r2, s2); // Second claim succeeds! assert(nft.balanceOf(alice) == 2); // Alice now has 2 NFTs } ``` ## Recommended Mitigation **Add a claim status check at the beginning of the function** to prevent users from claiming multiple times. ```diff // Add new error + error SA__AlreadyClaimed(); function claimSnowman(address receiver, bytes32[] calldata merkleProof, uint8 v, bytes32 r, bytes32 s) external nonReentrant { + if (s_hasClaimedSnowman[receiver]) { + revert SA__AlreadyClaimed(); + } + if (receiver == address(0)) { revert SA__ZeroAddress(); } // Rest of function logic... s_hasClaimedSnowman[receiver] = true; } ```

Support

FAQs

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

Give us feedback!