The buySnow()
function uses a strict equality check for ETH payments, causing unintuitive behavior when users send incorrect amounts. The function uses WETH instead of ETH in all cases where the exact ETH amount is not sent, even when ETH is provided.
The Snow contract allows users to purchase tokens using either ETH or WETH. However, the payment logic in the buySnow()
function uses a strict equality check (==
) rather than a greater-than-or-equal check (>=
) when verifying ETH payments:
This implementation creates two significant issues:
If a user sends slightly more ETH than required, the contract will ignore the ETH payment and attempt to use WETH instead.
If a user sends slightly less ETH than required, the contract will also attempt to use WETH rather than simply reverting with a clear message about insufficient ETH.
This behavior is unintuitive and confusing for users, as they might send ETH but the contract would deduct WETH from their balance. Additionally, excess ETH sent to the contract becomes trapped, as there is no mechanism to refund it.
Likelihood: High
Users commonly make small mistakes when entering payment amounts
Any user who sends more than the exact ETH amount will trigger this issue
Occurs during normal contract usage
Impact:
Impact: Medium
Users can lose funds by sending excess ETH that becomes trapped
Confusing payment behavior leads to unexpected WETH transfers
Poor user experience and potential fund loss
1. Use >= for ETH comparisons and refund excess ETH:
This fix:
Properly handles cases where users send excess ETH by refunding them
Clearly distinguishes between ETH and WETH payment intentions
Provides more informative errors when insufficient ETH is sent
Prevents user confusion and potential fund loss
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.