The buySnow function is payable and uses an if/else to decide between ETH and WETH payment. The condition checks msg.value == (s_buyFee * amount) — if this is exactly true, ETH is used. Otherwise, the else branch pulls WETH via safeTransferFrom. The problem is that any ETH sent in the else branch is silently absorbed by the contract with no refund mechanism.
Likelihood:
This occurs when a user sends any non-zero ETH amount that doesn't exactly equal s_buyFee * amount — e.g., sending slightly too much ETH, or mistakenly sending ETH while also having WETH approved.
The s_buyFee is 5 * 10^18 (5 ETH). Users attempting to send ETH with rounding or UI errors will trigger the else branch.
Impact:
Users permanently lose their ETH — there is no withdrawal or refund function for trapped ETH beyond collectFee.
Users may also pay WETH on top of the lost ETH, resulting in double payment for a single purchase.
This test demonstrates that when a user sends slightly more ETH than required (e.g., fee + 1 wei), the if condition fails and execution falls to the else branch. The WETH is pulled via safeTransferFrom, while the ETH sent with the transaction is silently trapped in the contract. The user ends up paying both ETH and WETH for a single Snow token purchase.
Replace the exact-match if with a check on whether msg.value > 0, and add explicit validation that the correct amount was sent. This separates the ETH and WETH payment paths cleanly and prevents any ETH from being silently trapped when a user intends to pay with WETH.
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.