Snowman Merkle Airdrop

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

Users cant claim there Free snow after 1 week

Root + Impact

Title: Logical flaw in earnSnow prevents users from claiming free Snow tokens after 1 week

  • Description: According to the protocol documentation for the SnowMan Merkle AirDrop, users are supposed to be able to earn Snow tokens for free once a week. However, there is a logical error in the timestamp validation within the earnSnow function.

  • Instead of allowing the claim after the 1-week period has elapsed, the conditional check incorrectly reverts the transaction. Because of this flaw, once the initial time threshold is crossed, the contract permanently blocks users from minting their free tokens, completely breaking the intended distribution model.

function earnSnow() external canFarmSnow {
if (s_earnTimer != 0 && block.timestamp < (s_earnTimer + 1 weeks)) {
revert S__Timer();
}
_mint(msg.sender, 1);
s_earnTimer = block.timestamp;
}

Risk

Likelihood:

  • This is a core, user-facing function. The bug triggers deterministically based on the blockchain timestamp, meaning 100% of users attempting to claim their free tokens after the first week will encounter this revert.

  • The core economic design of the Snow token is broken. Users are permanently locked out of the "free-to-earn" path and are forcefully required to purchase Snow tokens with WETH or native ETH to participate in the Airdrop, entirely disenfranchising non-paying users.


Proof of Concept

function test_RevertIfAllotherAddressTriesToCLaimThereFreeTokenAfter1week()
public
{
//Arrange
uint256 initial_balance_ofAlice = snow.balanceOf(alice);
uint256 initial_balance_ofbob = snow.balanceOf(bob);
uint256 initial_balance_ofclara = snow.balanceOf(clara);
uint256 initial_balance_ofdan = snow.balanceOf(dan);
uint256 initial_balance_ofeli = snow.balanceOf(eli);
vm.warp(block.timestamp + 1 weeks);
//Act
vm.prank(alice);
snow.earnSnow();
vm.expectRevert(Snow.S__Timer.selector);
vm.prank(bob);
snow.earnSnow();
vm.expectRevert(Snow.S__Timer.selector);
vm.prank(clara);
snow.earnSnow();
vm.expectRevert(Snow.S__Timer.selector);
vm.prank(dan);
snow.earnSnow();
vm.expectRevert(Snow.S__Timer.selector);
vm.prank(eli);
snow.earnSnow();
uint256 final_balanceOf_alice = snow.balanceOf(alice);
uint256 final_balanceOf_bob = snow.balanceOf(bob);
uint256 final_balanceOf_clara = snow.balanceOf(clara);
uint256 final_balanceOf_dan = snow.balanceOf(dan);
uint256 final_balanceOf_eli = snow.balanceOf(eli);
//Assert
assertEq(
final_balanceOf_alice,
initial_balance_ofAlice + 1,
"should be 2"
);
assertEq(final_balanceOf_bob, initial_balance_ofbob, "should be 1");
assertEq(final_balanceOf_clara, initial_balance_ofclara, "should be 1");
assertEq(final_balanceOf_dan, initial_balance_ofdan, "should be 1");
assertEq(final_balanceOf_eli, initial_balance_ofeli, "should be 1");
}
[PASS] test_RevertIfAllotherAddressTriesToCLaimThereFreeTokenAfter1week() (gas: 102232)
Traces:
[102232] TestVulnSnow::test_RevertIfAllotherAddressTriesToCLaimThereFreeTokenAfter1week()
├─ [3284] Snow::balanceOf(alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6]) [staticcall]
│ └─ ← [Return] 1
├─ [3284] Snow::balanceOf(bob: [0x1D96F2f6BeF1202E4Ce1Ff6Dad0c2CB002861d3e]) [staticcall]
│ └─ ← [Return] 1
├─ [3284] Snow::balanceOf(clara: [0xE55d6ba4bE0A6E0D87c4cA26B7C80779573Dc674]) [staticcall]
│ └─ ← [Return] 1
├─ [3284] Snow::balanceOf(dan: [0xb72116984E306d834a0ae638688Ef9AF1f7FE2cd]) [staticcall]
│ └─ ← [Return] 1
├─ [3284] Snow::balanceOf(eli: [0xEa61F454C2B4A5A16AB556DBE8DBB176C1D02177]) [staticcall]
│ └─ ← [Return] 1
├─ [0] VM::warp(3024001 [3.024e6])
│ └─ ← [Return]
├─ [0] VM::prank(alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6])
│ └─ ← [Return]
├─ [19833] Snow::earnSnow()
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6], value: 1)
│ └─ ← [Return]
├─ [0] VM::expectRevert(custom error 0xc31eb0e0: d8f332dc00000000000000000000000000000000000000000000000000000000)
│ └─ ← [Return]
├─ [0] VM::prank(bob: [0x1D96F2f6BeF1202E4Ce1Ff6Dad0c2CB002861d3e])
│ └─ ← [Return]
├─ [1315] Snow::earnSnow()
│ └─ ← [Revert] S__Timer()
├─ [0] VM::expectRevert(custom error 0xc31eb0e0: d8f332dc00000000000000000000000000000000000000000000000000000000)
│ └─ ← [Return]
├─ [0] VM::prank(clara: [0xE55d6ba4bE0A6E0D87c4cA26B7C80779573Dc674])
│ └─ ← [Return]
├─ [1315] Snow::earnSnow()
│ └─ ← [Revert] S__Timer()
├─ [0] VM::expectRevert(custom error 0xc31eb0e0: d8f332dc00000000000000000000000000000000000000000000000000000000)
│ └─ ← [Return]
├─ [0] VM::prank(dan: [0xb72116984E306d834a0ae638688Ef9AF1f7FE2cd])
│ └─ ← [Return]
├─ [1315] Snow::earnSnow()
│ └─ ← [Revert] S__Timer()
├─ [0] VM::expectRevert(custom error 0xc31eb0e0: d8f332dc00000000000000000000000000000000000000000000000000000000)
│ └─ ← [Return]
├─ [0] VM::prank(eli: [0xEa61F454C2B4A5A16AB556DBE8DBB176C1D02177])
│ └─ ← [Return]
├─ [1315] Snow::earnSnow()
│ └─ ← [Revert] S__Timer()
├─ [1284] Snow::balanceOf(alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6]) [staticcall]
│ └─ ← [Return] 2
├─ [1284] Snow::balanceOf(bob: [0x1D96F2f6BeF1202E4Ce1Ff6Dad0c2CB002861d3e]) [staticcall]
│ └─ ← [Return] 1
├─ [1284] Snow::balanceOf(clara: [0xE55d6ba4bE0A6E0D87c4cA26B7C80779573Dc674]) [staticcall]
│ └─ ← [Return] 1
├─ [1284] Snow::balanceOf(dan: [0xb72116984E306d834a0ae638688Ef9AF1f7FE2cd]) [staticcall]
│ └─ ← [Return] 1
├─ [1284] Snow::balanceOf(eli: [0xEa61F454C2B4A5A16AB556DBE8DBB176C1D02177]) [staticcall]
│ └─ ← [Return] 1
└─ ← [Return]

Recommended Mitigation

  • Refactor s_earnTimer from a single uint256 to a mapping that tracks the last claim timestamp for each individual user (mapping(address => uint256)). Update the earnSnow logic to check and update the timer for msg.sender.

// 1. Change the state variable to a mapping
mapping(address => uint256) public s_earnTimer;
function earnSnow() external canFarmSnow {
// 2. Check the timer specifically for msg.sender
if (s_earnTimer[msg.sender] != 0 && block.timestamp < (s_earnTimer[msg.sender] + 1 weeks)) {
revert S__Timer();
}
_mint(msg.sender, 1);
// 3. Update the timer specifically for msg.sender
s_earnTimer[msg.sender] = block.timestamp;
}
Updates

Lead Judging Commences

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

[L-02] Global Timer Reset in Snow::buySnow Denies Free Claims for All Users

## Description: The `Snow::buySnow` function contains a critical flaw where it resets a global timer `(s_earnTimer)` to the current block timestamp on every invocation. This timer controls eligibility for free token claims via `Snow::earnSnow()`, which requires 1 week to pass since the last timer reset. As a result: Any token purchase `(via buySnow)` blocks all free claims for all users for 7 days Malicious actors can permanently suppress free claims with micro-transactions Contradicts protocol documentation promising **"free weekly claims per user"** ## Impact: * **Complete Denial-of-Service:** Free claim mechanism becomes unusable * **Broken Protocol Incentives:** Undermines core user acquisition strategy * **Economic Damage:** Eliminates promised free distribution channel * **Reputation Harm:** Users perceive protocol as dishonest ```solidity function buySnow(uint256 amount) external payable canFarmSnow { if (msg.value == (s_buyFee * amount)) { _mint(msg.sender, amount); } else { i_weth.safeTransferFrom(msg.sender, address(this), (s_buyFee * amount)); _mint(msg.sender, amount); } @> s_earnTimer = block.timestamp; emit SnowBought(msg.sender, amount); } ``` ## Risk **Likelihood**: • Triggered by normal protocol usage (any purchase) • Requires only one transaction every 7 days to maintain blockage • Incentivized attack (low-cost disruption) **Impact**: • Permanent suppression of core protocol feature • Loss of user trust and adoption • Violates documented tokenomics ## Proof of Concept **Attack Scenario:** Permanent Free Claim Suppression * Attacker calls **buySnow(1)** with minimum payment * **s\_earnTimer** sets to current timestamp (T0) * All **earnSnow()** calls revert for **next 7 days** * On day 6, attacker repeats **buySnow(1)** * New timer reset (T1 = T0+6 days) * Free claims blocked until **T1+7 days (total 13 days)** * Repeat step **4 every 6 days → permanent blockage** **Test Case:** ```solidity // Day 0: Deploy contract snow = new Snow(...); // s_earnTimer = 0 // UserA claims successfully snow.earnSnow(); // Success (first claim always allowed) // Day 1: UserB buys 1 token snow.buySnow(1); // Resets global timer to day 1 // Day 2: UserA attempts claim snow.earnSnow(); // Reverts! Requires day 1+7 = day 8 // Day 7: UserC buys 1 token (day 7 < day 1+7) snow.buySnow(1); // Resets timer to day 7 // Day 8: UserA retries snow.earnSnow(); // Still reverts! Now requires day 7+7 = day 14 ``` ## Recommended Mitigation **Step 1:** Remove Global Timer Reset from `buySnow` ```diff function buySnow(uint256 amount) external payable canFarmSnow { // ... existing payment logic ... - s_earnTimer = block.timestamp; emit SnowBought(msg.sender, amount); } ``` **Step 2:** Implement Per-User Timer in `earnSnow` ```solidity // Add new state variable mapping(address => uint256) private s_lastClaimTime; function earnSnow() external canFarmSnow { // Check per-user timer instead of global if (s_lastClaimTime[msg.sender] != 0 && block.timestamp < s_lastClaimTime[msg.sender] + 1 weeks ) { revert S__Timer(); } _mint(msg.sender, 1); s_lastClaimTime[msg.sender] = block.timestamp; // Update user-specific timer emit SnowEarned(msg.sender, 1); // Add missing event } ``` **Step 3:** Initialize First Claim (Constructor) ```solidity constructor(...) { // Initialize with current timestamp to prevent immediate claims s_lastClaimTime[address(0)] = block.timestamp; } ```

Support

FAQs

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

Give us feedback!