Skip to content

Custom Boolean Reentrancy Lock (Fragile)

SAFE-0307 Reentrancy Checked automatically by the scanner
1

What goes wrong

The contract rolls its own boolean reentrancy lock instead of a battle-tested guard. Hand-rolled locks frequently mis-order set/clear, forget to reset on a revert path, or leave gaps, re-opening the reentrancy they were meant to close.

2

The vulnerable pattern

proof of concept — how it is exploited
// bool locked; function f() external { require(!locked); locked=true; ...
//   external.call(...); locked=false; }
// if the external call reverts on a path that skips locked=false, the
// contract is bricked; if any function forgets the check, reentrancy is open.
3

How to fix it

the pattern that is safe
// use OpenZeppelin ReentrancyGuard (nonReentrant) instead of a manual bool
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
Prefer audited guards over hand-rolled locks.
Check your own contract for this

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