Rules › Solidity

Initializer anyone can call

highSolidityRule sol-unprotected-initializer

An initialize function without the initializer modifier or an access check can be called again, or first, by an attacker.

Why it matters

Upgradeable contracts use an initialize function instead of a constructor. Without the initializer modifier (or an equivalent guard), anyone can call it first after deployment, or call it again later, and make themselves owner. The implementation contract behind a proxy also needs _disableInitializers() in its constructor, or an attacker can initialize it directly.

Vulnerable

function initialize(address _owner) external {
    owner = _owner;
}

Fixed

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() { _disableInitializers(); }

function initialize(address _owner) external initializer {
    __Ownable_init(_owner);
}

What other tools call it

ToolDetector or reference
Slitherunprotected-upgrade, uninitialized-state
Aderynunprotected-initializer
SWC registrySWC-118

Check your code

Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.

Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.