The buySnow()
function performs unchecked multiplication of s_buyFee * amount
to calculate the total payment required in either ETH or WETH. Under extreme input values, this multiplication can cause an integer overflow, which leads to either:
Unexpected revert due to overflow under Solidity 0.8+'s default checks
Incorrect fee logic if overflow handling is later disabled using unchecked
for gas optimizations
This bug is particularly dangerous in payment logic because it may allow users to mint a large number of tokens for a small ETH/WETH amount, or cause denial-of-service (DoS) due to automatic reverts on overflow.
The function is expected to multiply s_buyFee
by amount
, then either accept ETH (msg.value
) or transfer WETH accordingly, and mint tokens.
If amount
is large enough, the multiplication s_buyFee * amount
will overflow. Solidity 0.8+ reverts on overflow, causing the entire transaction to fail. If this multiplication is ever wrapped in unchecked
, it could silently overflow and allow minting tokens for very low value.
Will trigger on very large amount
values due to Solidity 0.8+ overflow checking
Likely to go unnoticed until DoS or if someone disables the safety using unchecked
Denial-of-service: All large amount
calls revert unexpectedly
Potential underpayment if unchecked logic is used
Affects critical financial flow (minting against payment)
###Output
Use safe multiplication and include a precondition check:
Alternatively, use OpenZeppelin's SafeMath
(for earlier versions) or apply an internal _safeMul()
utility to avoid unsafe operations.
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.