Skip to content
low Logic / State No SWC entry CWE-193

Off-By-One in Cap / Bound Check

SAFE-0253 Logic / State Checked automatically by the scanner
1

What goes wrong

A cap or limit uses the wrong comparison (<= where < is intended, or vice-versa), letting one more item through than allowed or rejecting the final valid one. Small, but can break supply caps or allowlist sizes.

2

The vulnerable pattern

proof of concept — how it is exploited
// require(totalMinted < MAX_SUPPLY); _mint(qty);
// checks BEFORE adding qty, so a batch can push totalMinted past
// MAX_SUPPLY by (qty-1).
3

How to fix it

the pattern that is safe
require(totalMinted + qty <= MAX_SUPPLY, "exceeds cap"); // inclusive cap, checked correctly
Check the post-operation value against the cap.
Check your own contract for this

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