claimSnowman computes the Merkle leaf using the receiver's current Snow balance (i_snow.balanceOf(receiver)) rather than accepting the amount as a parameter. The Merkle tree is generated at a specific point in time with each user's balance at that moment. If a user's balance changes between tree generation and claiming (by buying more Snow, earning another token, or transferring), the recomputed leaf won't match and the Merkle proof fails.
The Merkle tree generation script (script/GenerateInput.s.sol) captures each user's Snow balance at deployment time and creates leaves as keccak256(abi.encode(address, balance)). The root is stored immutably in the contract. But claimSnowman reads the live balanceOf() rather than using the original amount.
Consider this scenario:
Tree generated with Alice having 1 Snow → leaf = keccak256(abi.encode(alice, 1))
Alice buys 2 more Snow → balance is now 3
Alice claims → leaf computed as keccak256(abi.encode(alice, 3))
Proof for (alice, 1) does not verify against leaf (alice, 3) → revert
The same happens if Alice transfers Snow to someone else, reducing her balance below the tree amount.
The getMessageHash function (line 112-122) has the same issue — it reads i_snow.balanceOf(receiver) to compute the signature digest, so the signature is also tied to the current balance rather than the Merkle-tree balance.
Likelihood:
Any Snow token transaction (earn, buy, transfer) between tree generation and claiming changes the balance. With earnSnow() and buySnow() being the primary user flows, balance changes are expected. The farming period lasts 12 weeks, making balance drift nearly certain.
Impact:
Legitimate airdrop recipients cannot claim their Snowman NFTs. Their Snow tokens are staked but the claim reverts. The only way to claim is to have the exact balance from tree generation time, which is extremely fragile and not communicated to users.
Output:
Accept amount as a function parameter and verify the user holds at least that amount:
# Root + Impact ## Description * Users will approve a specific amount of Snow to the SnowmanAirdrop and also sign a message with their address and that same amount, in order to be able to claim the NFT * Because the current amount of Snow owned by the user is used in the verification, an attacker could forcefully send Snow to the receiver in a front-running attack, to prevent the receiver from claiming the NFT.  ```Solidity function getMessageHash(address receiver) public view returns (bytes32) { ... // @audit HIGH An attacker could send 1 wei of Snow token to the receiver and invalidate the signature, causing the receiver to never be able to claim their Snowman uint256 amount = i_snow.balanceOf(receiver); return _hashTypedDataV4( keccak256(abi.encode(MESSAGE_TYPEHASH, SnowmanClaim({receiver: receiver, amount: amount}))) ); ``` ## Risk **Likelihood**: * The attacker must purchase Snow and forcefully send it to the receiver in a front-running attack, so the likelihood is Medium **Impact**: * The impact is High as it could lock out the receiver from claiming forever ## Proof of Concept The attack consists on Bob sending an extra Snow token to Alice before Satoshi claims the NFT on behalf of Alice. To showcase the risk, the extra Snow is earned for free by Bob. ```Solidity function testDoSClaimSnowman() public { assert(snow.balanceOf(alice) == 1); // Get alice's digest while the amount is still 1 bytes32 alDigest = airdrop.getMessageHash(alice); // alice signs a message (uint8 alV, bytes32 alR, bytes32 alS) = vm.sign(alKey, alDigest); vm.startPrank(bob); vm.warp(block.timestamp + 1 weeks); snow.earnSnow(); assert(snow.balanceOf(bob) == 2); snow.transfer(alice, 1); // Alice claim test assert(snow.balanceOf(alice) == 2); vm.startPrank(alice); snow.approve(address(airdrop), 1); // satoshi calls claims on behalf of alice using her signed message vm.startPrank(satoshi); vm.expectRevert(); airdrop.claimSnowman(alice, AL_PROOF, alV, alR, alS); } ``` ## Recommended Mitigation Include the amount to be claimed in both `getMessageHash` and `claimSnowman` instead of reading it from the Snow contract. Showing only the new code in the section below ```Python function claimSnowman(address receiver, uint256 amount, bytes32[] calldata merkleProof, uint8 v, bytes32 r, bytes32 s) external nonReentrant { ... bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(receiver, amount)))); if (!MerkleProof.verify(merkleProof, i_merkleRoot, leaf)) { revert SA__InvalidProof(); } // @audit LOW Seems like using the ERC20 permit here would allow for both the delegation of the claim and the transfer of the Snow tokens in one transaction i_snow.safeTransferFrom(receiver, address(this), amount); // send ... } ```
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.