Skip to content

Unbounded Batch Mint / Airdrop Loop

SAFE-0214 Denial of Service Checked automatically by the scanner
1

What goes wrong

A mint/airdrop iterates a caller-supplied array with no length cap. A large array runs out of gas (blocking the operation) or, combined with per-item accounting, inflates supply unexpectedly.

2

The vulnerable pattern

proof of concept — how it is exploited
// airdrop(bigArray) with 5000 entries -> exceeds block gas limit,
// the tx always reverts; or a cheaper griefer forces others' batches
// to compete for gas.
3

How to fix it

the pattern that is safe
require(recipients.length <= MAX_BATCH, "batch too large");
for (uint i; i < recipients.length; ++i) { _mint(recipients[i], amount); }
Cap batch sizes for any loop over external input.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0214 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs