Description:
The buySnow function is intended to allow users to purchase Snow tokens using either native ETH (msg.value) or WETH (i_weth.safeTransferFrom). However, the current logic fails to properly differentiate between these two payment methods and mishandles excess ETH.
solidity
There are two critical flaws in this logic:
Permanent ETH Lock (Fund Loss): If a user sends slightly more ETH than required (i.e., msg.value > s_buyFee * amount), the if condition fails. The excess ETH is not refunded and remains permanently locked in the contract.
Double Payment: If a user sends any amount of ETH that does not exactly match the required cost (e.g., msg.value > 0 but not equal to s_buyFee * amount), the code falls into the else block. It will then attempt to pull the full WETH amount from the user, while the ETH sent is also kept by the contract. The user effectively pays twice (once in ETH, once in WETH) and the ETH is lost forever.
Likelihood:
Medium. Users frequently use the "Max" button or manually input ETH amounts, which can easily lead to sending slightly more than the exact required s_buyFee * amount.
Impact:
High. Any ETH sent that does not exactly match the required amount is permanently locked in the contract with no way to recover it, resulting in a direct loss of funds for the user.
Impact:
. Direct Fund Loss: Users who accidentally send the wrong amount of ETH will lose their ETH permanently, as there is no refund mechanism or withdrawal function for native ETH in this contract.
Double Payment: Users will be forced to pay via WETH even after sending ETH, draining their WETH balance unnecessarily.
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.