In the snow.sol
contract, users are eligible to earn Snow tokens after a predetermined waiting period of one week, as specified in the contract's logic
impact
The function buySnow
contains a vulnerability related to timestamp tracking. Specifically, the contract stores block.timestamp
in a variable that gets overwritten whenever a new user buys Snow tokens. This leads to the following issues :
A previous user's progress toward claiming their tokens is lost, as the timestamp gets reset by the latest transaction.
If a user attempts to claim their tokens after another user has triggered earnSnow
, they will be unable to do so, since the stored timestamp no longer reflects their original eligibility period.
Likelihood:
This issue occurs whenever a new user triggers buySnow
, as the stored timestamp is overwritten.
Users attempting to claim their Snow tokens after another user has bought snow token will lose their progress, making it a recurring problem in active environments.
Impact:
Loss of expected rewards: Users eligible to claim tokens may find their progress wiped, creating frustration and reducing trust in the system.
This test demonstrates how buySnow
unintentionally resets user eligibility when a new user claims Snow tokens.
Ashley earns Snow tokens successfully.
After a week, Jerry interacts with the contract, triggering an update to the global timestamp variable.
Ashley’s claim fails, as her progress is overwritten, preventing her from earning additional tokens.
For this purpose , a getter function is created to get the timestamp and prove that its updated when ever a new user claim there Earned Snow Token.
Issue
Since the contract tracks a single timestamp instead of storing values per user, any new interaction resets prior eligibility, leading to lost rewards.
The issue arises due to a single global timestamp (s_earnTimer
) being used for tracking Snow token earnings. This leads to progress resets whenever a new user interacts with the contract, causing previous users to lose their eligibility.
Changes in Contract Structure
Previous approach: uint256 private s_earnTimer;
Updated approach: mapping(address => uint) private s_earnTimer;
This ensures each user has an independent timestamp, preventing unintended overwrites.
When buySnow is successfully called, the global timer is reset. This inadvertently affects the earning of snow as that particular action also depends on the global timer.
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.