The buySnow function uses equality check msg.value == (s_buyFee * amount) instead of >=, allowing users to mint Snow tokens with insufficient payment. The else branch attempts WETH transfer without proper validation, enabling token minting at a fraction of the intended cost.
Contract: src/Snow.sol
Function: buySnow (lines 68-78)
The function splits payment into two paths without proper enforcement:
ETH path: Only mints if msg.value exactly matches (fails on over/under payment)
WETH path: Attempts transfer without verifying approval/balance first
Issues:
Equality check instead of >=
No revert on underpayment
WETH path mints without verifying transfer succeeded
Severity: High
Likelihood: High
Impact: High
Users can acquire Snow tokens at significantly reduced cost
Token sale revenue severely compromised
Fee collection mechanism unreliable
Scenario 1 - Zero Payment:
Scenario 2 - Partial Payment:
Consequences:
Economic model broken
Unfair distribution favoring attackers
Project credibility damaged
Run: forge test -vv --match-contract BuySnowExploitTest
Key Fixes:
✅ Uses >= instead of ==
✅ Reverts on underpayment
✅ Refunds excess ETH
✅ Validates payment before minting
Alternative: Split into buyWithETH() and buyWithWETH() for clarity.
SWC-114: Payment Validation
CWE-843: Type Compatibility
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.