Snowman Merkle Airdrop

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

Root cause: s_earnTimer is a single protocol-wide variable instead of per user. Impact: one address takes the entire free Snow supply, or freezes weekly farming for everybody at zero cost

Root cause: s_earnTimer is a single protocol-wide variable instead of per user. Impact: one address takes the entire free Snow supply, or freezes weekly farming for everybody at zero cost

Description

The README says Snow "can either be earned for free onece a week", which for an airdrop meant to onboard a whitelist can only mean once a week per user. earnSnow is expected to gate each caller individually.

s_earnTimer is one contract-wide slot with no msg.sender anywhere in the logic. Whoever calls first stamps it for everyone, so only one address in the entire protocol can farm per week. buySnow stamps the same slot as a side effect, so a purchase also freezes free farming.

// src/Snow.sol
@> uint256 private s_earnTimer; // one slot for the whole protocol
function earnSnow() external canFarmSnow {
@> if (s_earnTimer != 0 && block.timestamp < (s_earnTimer + 1 weeks)) {
revert S__Timer(); // no per-caller tracking at all
}
_mint(msg.sender, 1);
s_earnTimer = block.timestamp;
}

Their own tooling shows the behaviour: Helper.s.sol has to vm.warp a full week between each of the five users just to give them one Snow each, and TestSnow::testCanEarnSnow only ever exercises a single address, which is why a global timer was indistinguishable from a per-user one.

Risk

Likelihood:

  • Any address triggers this in any block, with no precondition. A bot claiming the slot in the first block of each weekly window wins every race against honest users.

  • Denial costs nothing: buySnow(0) with msg.value of 0 satisfies msg.value == s_buyFee * amount, mints nothing, and still stamps the timer, so a griefer spends only gas.

Impact:

  • One address can take the whole free supply for itself. Since the airdrop snapshot is built from Snow balances, whoever monopolises farming also decides who ends up eligible for the NFT.

  • Everyone else is pushed onto the paid path at 5 ether per unit with the deploy script's FEE = 5, so a free acquisition route becomes a forced purchase, and no admin action can undo it.

Proof of Concept

The attacker is any address, needing nothing but gas. The victims are all other users, including ones who never farmed at all. The protocol side is Snow, whose free distribution mechanic is the thing being captured.

function test_G1_OneAddressTakesTheEntireFreeSupply() public {
// the attacker claims the single global slot every week
for (uint256 week = 0; week < 11; week++) {
vm.prank(attacker);
snow.earnSnow();
vm.warp(block.timestamp + 1 weeks);
}
// he now holds every free token the protocol ever issued
assertEq(snow.balanceOf(attacker), 11, "attacker holds every free token issued");
assertEq(snow.balanceOf(victimA), 0, "honest user got nothing");
// and the only route left for an honest user is the paid one
vm.deal(victimA, 100 ether);
vm.prank(victimA);
snow.buySnow{value: fee}(1);
assertEq(snow.balanceOf(victimA), 1);
}

Output:

[PASS] test_G1_OneAddressTakesTheEntireFreeSupply() (gas: 276689)
Logs:
free tokens taken by one address: 11
cost forced on an honest user, wei: 5000000000000000000

Four supporting tests pass alongside it. Two honest users cannot both farm in the same week, so even with no malice the whole free distribution is capped at one address per week, roughly twelve addresses over the entire FARMING_DURATION. Pure denial is free: buySnow(0) mints nothing, costs nothing, and still freezes everyone, and holding that denial for eleven consecutive weeks left the victim with zero Snow while the griefer spent nothing but gas. No operator lever helps either: collectFee, changeCollector and both Ownable functions were all exercised, and the victim stayed locked out, because nothing in the contract touches s_earnTimer and there is no setter for it.

On severity I am deliberately calling this Medium. Nothing already held is stolen and the paid path keeps working, but a core advertised mechanic is permanently capturable at no cost.

Recommended Mitigation

Track the timer per caller, and stop letting purchases touch it:

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

Delete the s_earnTimer = block.timestamp; line from buySnow, since buying and farming are separate mechanisms, and reject empty purchases so a no-op call cannot be used as a lever:

if (amount == 0) {
revert S__ZeroValue();
}
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 1 hour 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!