the Snowman
contract is all about minting awesome NFT snowmen for an airdrop. It’s built on the trusty ERC721 standard, but there’s a sneaky issue in the mintSnowman
function. It’s got a loop that lets anyone try to mint a ton of tokens in one go, and that could grind things to a halt faster than a sled on dry grass. Why? Because it could eat up more gas than an Ethereum block can handle (~30M gas).
The mintSnowman
function has a for
loop that mints tokens one by one, based on a user-provided amount
. Sounds fine, right? But there’s no cap on how big amount
can be. Someone could crank it up to, say, 10,000 tokens, and each mint chews through ~33,577 gas (per our PoC). Do the math, and that’s a whopping 335M gas—way over Ethereum’s 30M gas block limit. The transaction would crash like a snowball hitting a brick wall, leaving legit users stuck and unable to mint.
What Happened When I Ran It:
What’s This Telling Us?
Minting 100 tokens burned 3,357,766 gas, so each mint costs ~33,577 gas.
In a 30M gas block, you could only mint about 893 tokens (30,000,000 / 33,577
).
Trying to mint 10,000 tokens would need ~335,770,000 gas, which is way over the limit. On Ethereum mainnet, that’d crash and burn, proving the DoS risk is real.
Set a cap on the amount
parameter in mintSnowman
to keep gas usage in check. Here’s a quick code snippet to make it happen:
The mint function of the Snowman contract is unprotected. Hence, anyone can call it and mint NFTs without necessarily partaking in the airdrop.
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.