The buySnow() function allows users to purchase Snow tokens by specifying an amount parameter. However, the function does not validate that amount is greater than zero.
If amount == 0:
s_buyFee * amount evaluates to 0
msg.value == 0 satisfies the condition
_mint(msg.sender, 0) is executed
The function proceeds successfully without reverting. While no funds are directly lost, the lack of input validation weakens protocol correctness and may introduce edge cases or inconsistencies in accounting and monitoring.
Likelihood:
This issue does not enable fund theft or protocol compromise but may lead to incorrect state updates, misleading events, and unexpected edge-case behavior.
Impact:
Allowing zero-amount purchases may lead to unintended or misleading behavior
Users can trigger the SnowBought event without paying any fee
Off-chain systems (frontends, indexers, analytics) may interpret zero-value purchases as valid activity
Protocol invariants or assumptions that a purchase always involves value transfer may be violated
The function updates s_earnTimer even when no tokens are minted, potentially affecting reward timing logic.
Add explicit validation to ensure that the purchase amount is greater than zero:
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.