Medium
Snow.buySnow() supports payment with either native ETH or WETH. The function decides which payment path to use by checking whether msg.value exactly equals the expected ETH price:
If a user sends a non-zero ETH amount that is not exactly equal to s_buyFee * amount, the function enters the WETH branch. It pulls the full WETH fee, but it does not reject or refund the ETH sent with the transaction.
Affected code:
src/Snow.sol:79
src/Snow.sol:80
src/Snow.sol:83
A user with WETH allowance can accidentally pay both ETH and WETH for the same Snow purchase. The incorrect ETH remains in the contract and can later be collected by the collector.
Impact:
users can overpay,
funds are silently accepted in the wrong payment branch,
collector can collect both the incorrect ETH and the WETH fee.
The PoC gives a buyer both ETH and enough WETH allowance to buy 1 Snow. The buyer calls buySnow(1) with an ETH amount that is non-zero but not exactly equal to the expected fee. Because the ETH amount is not exact, the function enters the WETH branch and pulls the full WETH fee. The incorrect ETH sent with the call remains in the Snow contract.
Add this test to test/AuditFuzz.t.sol:
Run:
Result:
The final assertions show that the Snow contract receives both the wrong ETH amount and the full WETH fee while the buyer receives only 1 Snow.
Separate ETH and WETH payment paths explicitly. If ETH is sent, require the exact ETH amount. If no ETH is sent, charge WETH.
Example fix:
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.