The buySnow
function allows users to purchase Snow
tokens by either sending ETH directly or paying with WETH. The function attempts to determine the payment method based on whether the msg.value
exactly matches the required ETH fee (s_buyFee * amount
). If not, it falls back to attempting a WETH safeTransferFrom
.
As the result, the functionbuySnow
function can take more fees than intended due to imprecise ETH value matching and silent fallback to WETH.
The specific issue is that this logic is ambiguous and unsafe. Users who mistakenly overpay or underpay by even 1 wei will silently trigger a WETH transfer, which may fail if WETH has not been approved. This causes unexpected reverts, poor UX, and the most severe this introduces financial risk for users and undermines trust in the token mechanics.
Additionally, there's no way for the user to explicitly choose the payment method, leading to unpredictable behavior.
Likelihood:
This occurs whenever a user provides an incorrect ETH value (overpaying or underpaying by any amount), which is common due to frontend inconsistencies or slippage buffers.
This also occurs when a user unknowingly relies on WETH payment without approving the correct allowance beforehand.
Impact:
Users experience failed transactions and wasted gas due to unintuitive fallback behavior.
financial risk for users and undermines trust in the token mechanics.
Add the following test in TestSnow
Here the contract will take WETH as fees + the value of msg.value (here 1 wei). As a result, it will collects more fees as intended.
Separate the two different methods of payment in two functions.
Ensures clear and intentional user behavior, removes ambiguity, and prevents unintentional failures or misuse.
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.