The Snow
ERC20 contract allows users to earn 1 token every week via the earnSnow()
function, which is intended to reward each individual user once per week.
However, the current implementation uses a single global timestamp variable (s_earnTimer
to enforce the cooldown, rather than maintaining a per-user timer. As a result, only the first user to call earnSnow()
can successfully mint, and all subsequent users are blocked for one week, even if they have never called the function before.
Likelihood:
The function earnSnow()
can be accessed by any user once per week. This vulnerability will always occur after the first user has called the function during the current week.
The system is designed for many users to earn tokens individually, making the likelihood high in multi-user environments such as airdrops or public farming events.
Impact:
Users who have not previously earned tokens will be unfairly blocked from earning due to another user’s activity.
This directly violates the protocol’s intended behavior, resulting in loss of user rewards and trust.
Attacker calls earnSnow()
first, sets the global s_earnTimer
.
Waits exactly 1 week, calls again before others can.
Repeats this weekly, resetting the timer each time.
A malicious user (the attacker) repeatedly calls earnSnow()
as soon as the 1-week timer expires, effectively resetting the global timer every time and denying access to everyone else.
Replace the global s_earnTimer
With a per-user mapping to track individual cooldowns
Use a mapping(address => uint256)
to store the last earned timestamps for each user
Ensure each user can call earnSnow()
only after 1 week from their last claim
Introduce an epoch-based claiming system to allow fair reward distribution
Prevent multiple users from being blocked due to a shared timer
Emit events with timestamps for off-chain eligibility tracking
Add thorough test cases simulating multiple users attempting to earn rewards
Validate timestamp logic using msg.sender
context only
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.