s_hasClaimedSnowman Enables Double‑Claiming of AirdropSeverity: Medium
Impact: A single address can claim Snowman NFTs more than once if the Merkle tree contains multiple valid leaves for that address, bypassing the intended one‑claim‑per‑address restriction.
Affected Contract: SnowmanAirdrop.sol
The claimSnowman function sets s_hasClaimedSnowman[receiver] = true after a successful claim but never checks this flag before processing a new claim. As a result, if the airdrop’s Merkle tree includes more than one valid leaf for the same address (for example, different amounts), an attacker can invoke claimSnowman multiple times, each time using a different valid proof and signature, and receive additional Snowman NFTs. The intended one‑time‑per‑address limit is never enforced.
In SnowmanAirdrop.sol, the relevant code:
Notice that s_hasClaimedSnowman[receiver] is written but never consulted with a require(!s_hasClaimedSnowman[receiver]). The only purpose of the mapping appears to be a record, not a prevention mechanism. Consequently, if the Merkle tree contains two (or more) entries for the same address – for example, one for amount = 100 and another for amount = 200 – the same receiver can call claimSnowman twice, each time with a valid proof and signature, and successfully mint additional NFTs. The amount is determined by the user’s current Snow balance at the time of the call, so an attacker could also manipulate their balance to match different leaves across multiple calls.
The following Foundry test simulates a Merkle tree containing two leaves for the same address with different amounts. The attacker first claims using one leaf, then adjusts their balance, and claims again using the second leaf.
Multiple claims by the same address: If the Merkle tree accidentally or maliciously contains several entries for one beneficiary, that beneficiary can claim multiple times, receiving far more NFTs than intended.
Undermines airdrop fairness: The intended one‑claim‑per‑user invariant is violated, potentially leading to supply inflation and unfair distribution.
May be combined with balance manipulation: An attacker could move tokens between accounts or flash‑loan Snow to claim multiple times with different balances, amplifying the effect.
Add a check at the beginning of claimSnowman that prevents re‑claiming:
This simple addition enforces the one‑claim‑per‑address rule and closes the double‑claim vector. Additionally, the Merkle tree should be constructed carefully to avoid duplicate leaves for the same address.
# 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; } ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.