Under normal behavior, the buySnow()
function allows users to purchase Snow tokens by either sending ETH or paying in WETH. The intention is to require msg.value
to match the fee when paying in ETH, and otherwise fallback to pulling WETH via safeTransferFrom
.
The issue is that the contract does not verify the payment method explicitly. When msg.value
doesn't match the fee, the contract blindly attempts to pull WETH, which can lead to unintended token transfers, especially if users mistakenly send ETH slightly below the expected amount. This breaks principle-of-least-surprise and could cause user losses due to poor UX or gas estimation errors.
Likelihood:
Users frequently pay ETH with slight rounding or miscalculations, especially with frontend errors, gas overheads, or wallet UX problems.
WETH safeTransferFrom
does not prompt the user during the contract call and could drain tokens if allowance was previously set, even unintentionally.
Impact:
Loss of user funds due to unintended WETH transfer, especially in dApp UIs with unclear distinction between ETH and WETH payment options.
Breaks expected contract behavior: user may think ETH payment failed, while WETH was deducted and tokens were minted regardless.
An attacker or regular user can unintentionally trigger the fallback to WETH payment due to a slight mismatch in msg.value
. If the user has a non-zero WETH allowance approved to the Snow
contract, it can be drained without explicit intent.
For example, suppose the fee per token is 1 ether (1e18 wei)
and the user tries to buy 1 token:
To avoid accidental or unintended WETH transfers, the contract should explicitly require users to choose their payment method, either ETH or WETH. This ensures the function logic does not infer intent based on msg.value
and avoids unsafe assumptions.
The improved approach adds a PaymentType
enum and separates logic paths:
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.