Skip to content

Unbounded Array Growth (No Cap on push)

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

What goes wrong

A public function pushes to a storage array with no size limit, and another function later iterates that array. Anyone can grow it until iteration exceeds the block gas limit, permanently bricking the dependent function.

2

The vulnerable pattern

proof of concept — how it is exploited
// register() { participants.push(msg.sender); } // no cap
// distribute() loops participants. Attacker registers 10k addresses
// -> distribute() always OOG-reverts; funds locked.
3

How to fix it

the pattern that is safe
require(items.length < MAX_ITEMS, "full");
items.push(x);
// or avoid iterating storage arrays; use mappings + pull pattern
Cap arrays that are later iterated on-chain.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0240 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