Skip to content

Unprotected Initializer / Initialization

SAFE-0008 Access Control Checked automatically by the scanner
1

What goes wrong

An initializer function (used instead of a constructor in upgradeable/proxy contracts) is callable by anyone and lacks the initializer guard. An attacker front-runs deployment or re-initializes to set themselves as owner.

2

How to fix it

the pattern that is safe
function initialize(address _owner) external initializer {
    __Ownable_init();
    transferOwnership(_owner);
}
constructor() { _disableInitializers(); }
Wormhole/Parity-class init bugs. Use OZ Initializable.
Check your own contract for this

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