Skip to content

require/revert Without a Reason String

SAFE-0306 Best Practice Checked automatically by the scanner
1

What goes wrong

require()/revert() is used without a descriptive reason. Failures surface as opaque reverts, complicating debugging, off-chain monitoring, and user-facing error handling.

2

The vulnerable pattern

proof of concept — how it is exploited
// require(ok);   // reverts with no reason
// integrators and users see only 'execution reverted' — hard to diagnose
// which invariant failed during an incident.
3

How to fix it

the pattern that is safe
require(cond, "descriptive reason");
// or a custom error: error NotOwner(); if (msg.sender != owner) revert NotOwner();
Use reason strings or custom errors on every revert.
4

Where this has happened

Largest recorded losses in the same failure class — related, not the same bug:

Check your own contract for this

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