Snowman Merkle Airdrop

First Flight #42
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: high
Likelihood: high
Invalid

## Snow.sol ## [ Double earnSnow in earnSnow() ]

Root + Impact

Description

The earnSnow function does not prevent multiple earnings within 1 week because it uses a single global timer **s_earnTimer **for all users instead of tracking individual user timestamps. As a result, any user can call earnSnow multiple times to mint tokens repeatedly without waiting.

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 issue occurs whenever multiple users interact with the contract, as the cooldown timer is shared globally.

Users can bypass intended weekly cooldowns to mint multiple tokens.

Impact:

Allows double or multiple token earnings per week, potentially inflating token supply unfairly.

Can lead to economic imbalance or abuse of token minting.

Proof of Concept

Any user can repeatedly call earnSnow() immediately after another user did, because the cooldown is not tracked per user.

// Example:
// User A calls earnSnow() -> timer is set to now
// Immediately after, User B calls earnSnow() -> timer reset, no revert, mints token again

Recommended Mitigation

Change s_earnTimer to a mapping to track each user's last earn time individually, and update the function:

- uint256 s_earnTimer;
+ mapping(address => uint256) private s_earnTimer;
- @> if (s_earnTimer != 0 && block.timestamp < (s_earnTimer + 1 weeks)) {
- revert S__Timer();
- }
- @> s_earnTimer = block.timestamp;
+ uint256 lastClaim = s_earnTimer[msg.sender];
+ if (lastClaim != 0 && block.timestamp < (lastClaim + 1 weeks)) {
+ revert S__Timer();
+ }
- s_earnTimer = block.timestamp;
+ s_earnTimer[msg.sender] = block.timestamp;
Updates

Lead Judging Commences

yeahchibyke Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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