Skip to content
low Input Validation No SWC entry CWE-129

Array Index Used Without Bounds Assumption

SAFE-0255 Input Validation Checked automatically by the scanner
1

What goes wrong

A caller-supplied index is used to read/write an array or a mapping-of-structs whose existence isn't validated. Out-of-range or non-existent ids return zeroed structs that downstream logic treats as real, valid entries.

2

The vulnerable pattern

proof of concept — how it is exploited
// getOrder(id) returns orders[id]; a non-existent id returns a zeroed
// Order{maker:0, amount:0, filled:false}; fill() then treats it as open.
3

How to fix it

the pattern that is safe
require(id < items.length, "bad id");
Item storage it = items[id];
require(it.exists, "no item");
Validate ids/indices and struct existence.
Check your own contract for this

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