An initializer plays the role of a constructor for upgradeable contracts, so it must run exactly once. If it can be called again on live state, an attacker re-runs it to overwrite privileged pointers.
This guide covers what happens when an initializer stays open, and why the damage depends entirely on which storage slot it writes.
Why initializers exist at all
In a normal contract, the constructor runs once at deployment and then disappears. It can never be called again.
Upgradeable contracts (UUPS, transparent proxies, diamonds) lose that guarantee. The logic lives at a different address from the proxy that holds the funds and state, so a constructor can’t write the proxy’s storage. Developers use an ordinary external function instead, usually initialize(), which runs in the proxy’s context through delegatecall.
The catch: an ordinary function doesn’t disappear. It stays callable forever unless something stops it. Forget the one-shot guard, such as OpenZeppelin’s initializer modifier, and anyone can re-run initialization on live, funded state.
If that function writes the slot that decides who owns the protocol, or which address receives delegatecalls, the attacker gets to run their own code inside the vault.
The bug in one sentence
An initializer with no one-shot guard lets an attacker re-run it on a live proxy, overwrite an address that’s later used as a delegatecall target or admin, and run arbitrary code with the vault’s own identity.
A real case: Renegade Darkpool (Arbitrum, May 2026, about $210K)
Renegade’s darkpool ran behind a UUPS proxy holding about $210K across 26 tokens, including USDC, WBTC, WETH, PENDLE and ARB. The proxy delegated to an Arbitrum Stylus implementation, written in Rust and compiled to WASM.
That implementation exposed an initialize entry point with no one-shot guard. The sketch below is reconstructed from the storage operations seen on-chain. It’s not the original source:
// selector 0x92413afe: initialize(...) — no initializer guard
function initialize(address injectedExecutor, address token /*, ... */) external {
assembly { sstore(0, injectedExecutor) } // overwrites slot 0 on the live proxy
}
// selector 0x803f430a: updateWallet(...) — a normal user entry point
function updateWallet(bytes calldata proof, bytes calldata data) external {
address executor;
assembly { executor := sload(0) } // loads whatever is in slot 0
(bool ok, ) = executor.delegatecall(data); // runs that code as the vault
require(ok, "Execution failed");
}
The attack took two steps:
- Call
initialize(attackerContract, ...)on the proxy. Nothing stops it, so slot 0 now holds the attacker’s contract. - Call
updateWallet(...). It loads slot 0 anddelegatecalls it with caller-supplied data. The attacker’s code runs withaddress(this)equal to the darkpool proxy.
The injected code was a simple loop:
function drainTokens(address recipient, address[] calldata tokens) external {
for (uint256 i = 0; i < tokens.length; ++i) {
uint256 bal = IERC20(tokens[i]).balanceOf(address(this)); // the proxy's balance
if (bal > 0) IERC20(tokens[i]).transfer(recipient, bal);
}
}
One transaction emptied all 26 tokens.
The lesson about non-Solidity engines: Stylus contracts still have to protect their storage like any EVM contract. A missing check in Rust is an open storage write on the proxy.
Why the slot matters
How bad an open initializer is depends on what it writes:
- A parameter such as a fee or an oracle address leads to economic damage or bad trades.
- An owner or admin slot means the attacker controls upgrades and privileged functions.
- An address that’s later
delegatecalled gives the attacker arbitrary code in the vault’s context, with its storage and its balances. That’s total loss.
The attack, step by step
- Recon. Inspect the proxy and implementation for an
initialize-style function with no guard, noinitializedflag and no version counter. - Prepare. Deploy a drain contract to serve as the injected target.
- Overwrite. Call
initializeon the proxy, writing the drain contract into the executor slot. - Trigger. Call the user entry point that
delegatecalls that slot. - Sweep. The drain loop sends every token to the attacker.
Why it worked: four facts
- An executable privileged pointer. A slot holds an address the contract later runs in its own context, or hands admin rights to.
- An unguarded initializer. Anyone can write that slot.
- A public trigger path. A normal entry point reaches the pointer without real authorization. At Renegade, an empty proof was accepted.
- Value in the execution frame. The proxy holds pooled assets or approvals, so code running there can move them.
Remove any one and the exploit fails. With an initializer modifier the slot can’t be rewritten. With a plain call instead of delegatecall, foreign code couldn’t touch the proxy’s balances.
How to hunt for it
- Find every initializer.
bash grep -rnE "function (initialize|init|setUp|reinitialize)\w*\(" src/Check the modifiers on each one. - Check the one-shot guard. Does the contract inherit OpenZeppelin
Initializableand useinitializerorreinitializer(n)? Does the implementation’s constructor call_disableInitializers()? - Test it on a fork. Call
initialize(...)against the live proxy state. Does it revert withInvalidInitialization(), or does it write storage?bash cast call <PROXY> "initialize(address)" <ANY_ADDRESS> --rpc-url $RPCA successful simulated call is a strong signal, but confirm the storage write in a fork test. - List every
delegatecall. Trace each target back. Is it constant or immutable, or is it loaded from a slot that some external function writes? - Check validation order. Do signature or proof checks run before dispatching to the executor, or does the design rely on the executor to validate?
Lookalikes that are safe, and why
- OpenZeppelin
Initializable(v4 and v5). An internal version counter is set on the first run, and later calls revert withInvalidInitialization(). - Immutable or constant executor addresses. If the
delegatecalltarget is baked into the bytecode, re-running initialization can’t change it. - Plug-ins called with
callorstaticcall. Foreign code runs in its own context and can’t touch the vault’s storage or tokens unless it’s been approved.
Fixes that work
- Use the
initializermodifier. Also call_disableInitializers()in the implementation’s constructor, so nobody can initialize the implementation itself. - Gate re-initialization. If upgrades need it, use
reinitializer(version)plus an admin role. Never leave it public. - Namespace critical pointers. Store executor and admin addresses in hashed, namespaced slots (EIP-1967 style), not in slot 0, where they can collide or be overwritten by accident.
- Validate before dispatch. Never accept empty proofs, and never defer authorization until after a
delegatecall.
The same bug in other clothes
- Renegade Darkpool (Arbitrum, about $210K). A slot-0 overwrite through an open Stylus initializer, then a
delegatecall. Covered above. - Aurellion Labs (Arbitrum). Ownership of a diamond proxy had been set by a separate setter, while the initialization version stayed at zero. A public re-initialization took ownership, and the attacker installed their own facets through
diamondCutand drained standing approvals. - WaleCoin (BNB Chain). A dividend token proxy left
initialize()unguarded. The attacker re-ran it, pointed the router and pair addresses at contracts they controlled, minted the supply to themselves and drained the buyback liquidity. - Uninitialized implementations (Parity-style). The proxy is initialized correctly, but the implementation contract never was. An attacker initializes the implementation directly, becomes its owner, and can self-destruct it or upgrade it, breaking every proxy that depends on it. The 2017 Parity multisig library freeze is the classic example.
Test yourself
initialize()is protected byonlyOwner. Safe? That’s a circular design. Before initialization the owner is usuallyaddress(0), so nobody can call it and the contract can’t be set up. If the owner gets set some other way first, you’re relying on that path being safe. Use a one-shot flag, not a role check.- Why should implementation constructors call
_disableInitializers()? The implementation has its own storage. If it’s left uninitialized, anyone can initialize it directly and become its owner. - How is this different from part 2 (permissionless executors)? Part 2 runs attacker calldata in the same call, without changing storage. Here the attacker permanently corrupts a stored pointer, then uses a legitimate entry point to fire it.
- The open initializer only sets a fee percentage. Severity? No code execution, because no executable pointer is written. But setting fees to 100% can still cause denial of service or economic damage. Medium to High, depending on impact.
Recap
- An initializer without a one-shot guard can be re-run on live, funded state.
- Re-callable initializer plus a stored
delegatecalltarget means arbitrary code in the vault’s own context. - Renegade lost 26 tokens because a Stylus initializer had no guard and a user function
delegatecalled the overwritten slot. - The fix: use
initializerguards, disable initializers on implementations, and neverdelegatecallan address that users can write.