Uninitialized proxy: why an open initializer is a takeover

An uninitialized proxy is an upgradeable contract, or the implementation behind it, whose initializer hasn't been called yet, so the first account to call it becomes the owner. A proxy can't use a constructor to set up its own storage, so an ordinary initialize function does the job, and any gap between deployment and that call is the vulnerability. Initialize the proxy in the transaction that deploys it, and lock the implementation's initializer in its constructor.

Last updated . 6 minute read. By the QuillAudits Team.

Why do proxies need initializers?

A constructor runs once, at deployment, and writes the storage of the contract being deployed. Behind a proxy, the implementation's constructor writes the implementation's storage, not the proxy's, because the proxy only borrows the implementation's code through delegatecall. So upgradeable contracts move their setup into an ordinary function, usually initialize, that is called through the proxy.

That leaves two contracts to set up, each with its own storage: the proxy, which holds the real state and the funds, and the implementation, which holds the code. Each has an initialize that anyone can call until someone does.

How does an uninitialized proxy get taken over?

  • The proxy is set up in two transactions. It is deployed in one and initialized in the next. Anyone watching can call initialize in between and become the owner, and if the deploy script doesn't check, the protocol launches with an attacker as admin. This is a front running race.
  • The implementation is never initialized. Nobody uses it directly, so nobody sets it up. An attacker initializes it, becomes its owner and uses whatever owner-only functions it has. Before Cancun that could include self-destruct, which left every proxy pointing at empty code.
  • An upgrade adds an initializer nobody calls. Version 2 needs new variables set by initializeV2, and the upgrade transaction doesn't call it, so it waits for the first caller.
  • The initializer has no guard at all, so it can be called again later and the owner replaced.

What does vulnerable code look like?

This factory deploys a minimal proxy for each new vault and returns it. Initialization is left to a second transaction, and the implementation contract is never locked.

Vulnerable: a proxy initialized in a later transaction (illustrative, not audited code) OpenVaultFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract MinimalProxy {
    address private immutable implementation;

    constructor(address implementation_) {
        implementation = implementation_;
    }

    fallback() external payable {
        address impl = implementation;
        assembly {
            calldatacopy(0, 0, calldatasize())
            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
            returndatacopy(0, 0, returndatasize())
            switch ok
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
        }
    }

    receive() external payable {}
}

contract Vault {
    address public owner;
    bool public initialized;

    // No constructor lock: the implementation itself can be initialized by anyone.
    function initialize(address owner_) external {
        require(!initialized, "already initialized");
        initialized = true;
        owner = owner_;
    }

    function withdraw(address payable to, uint256 amount) external {
        require(msg.sender == owner, "not owner");
        (bool ok, ) = to.call{value: amount}("");
        require(ok, "send failed");
    }
}

contract OpenVaultFactory {
    address public immutable implementation;

    constructor(address implementation_) {
        implementation = implementation_;
    }

    // Returns the proxy uninitialized. Whoever calls initialize on it first owns it.
    function deployVault() external returns (address vault) {
        vault = address(new MinimalProxy(implementation));
    }
}

A bot that watches the factory calls initialize on each new proxy as soon as it appears, ahead of the deployer's own call. The deployer's call then reverts with already initialized, but a careless script carries on, and users deposit into a vault the attacker owns.

How do you fix it?

Initialize in the same transaction that deploys the proxy, so there is no moment when it is open, and lock the implementation in its constructor, so its own initializer can never run.

Fixed: initialize atomically and lock the implementation (illustrative, not audited code) LockedVaultFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract MinimalProxy {
    address private immutable implementation;

    constructor(address implementation_) {
        implementation = implementation_;
    }

    fallback() external payable {
        address impl = implementation;
        assembly {
            calldatacopy(0, 0, calldatasize())
            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
            returndatacopy(0, 0, returndatasize())
            switch ok
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
        }
    }

    receive() external payable {}
}

contract Vault {
    address public owner;
    bool public initialized;

    // Runs once, for the implementation only. Proxies start with empty storage,
    // so their own initializer still works.
    constructor() {
        initialized = true;
    }

    function initialize(address owner_) external {
        require(!initialized, "already initialized");
        require(owner_ != address(0), "zero owner");
        initialized = true;
        owner = owner_;
    }

    function withdraw(address payable to, uint256 amount) external {
        require(msg.sender == owner, "not owner");
        (bool ok, ) = to.call{value: amount}("");
        require(ok, "send failed");
    }
}

contract LockedVaultFactory {
    address public immutable implementation;

    constructor(address implementation_) {
        implementation = implementation_;
    }

    function deployVault(address owner_) external returns (address vault) {
        vault = address(new MinimalProxy(implementation));
        // Same transaction: there is never a block in which the proxy is open.
        Vault(vault).initialize(owner_);
    }
}
  • Deploy and initialize in one transaction. A factory, a deploy script that batches both calls, or a proxy whose constructor makes the initialization call all close the gap.
  • Lock every implementation in its constructor. Upgradeable contract libraries ship a function that marks the implementation as initialized; call it, or set the flag yourself as above.
  • Run new initializers in the upgrade transaction. Upgrade and call initializeV2 atomically, and give each version its own guard so it runs exactly once.
  • Check what you deployed as well as the code. After deploying, read the owner and the initialized flag of both the proxy and the implementation, and fail the script if either is open.

How has an uninitialized contract been exploited?

Protocol Parity multi-sig wallet library
Date 6 November 2017
Chain Ethereum
Loss 513,774.16 ETH frozen in 587 wallets
What happened Parity multi-sig wallets deployed after 20 July 2017 were lightweight stubs that depended on one shared library contract holding most of the wallet logic. The library had been deployed in July with its owner never initialized, although a GitHub contributor had recommended calling initWallet at deployment. On 6 November 2017 a user initialized the library, became its owner and then killed it, which blocked the funds in 587 wallets holding 513,774.16 ETH.
Sources Parity Technologies

Nothing was stolen. The funds stayed in the wallets, which could no longer run the code they depended on: the uninitialized-implementation failure in its plainest form. The access control page covers the same incident from the side of who may call what.

The exact ending couldn't repeat today. The Solidity docs say selfdestruct was deprecated in 0.8.18 and that from Cancun onwards it only sends the account's Ether to the recipient. An attacker who initializes an implementation can still use every other owner-only function it has, and one who initializes a live proxy owns the protocol.

What should a reviewer check?

  • List every initialize, reinitialize and initializeV2-style function, in every contract that sits behind a proxy or is cloned.
  • Is each one guarded so it runs once, and does it reject a zero owner or other bad arguments?
  • Does every implementation lock its initializers in its constructor?
  • Do the deploy scripts and factories deploy and initialize in the same transaction?
  • Does each upgrade call its new initializer in the upgrade transaction?
  • Can any owner-only function on the implementation itself do harm if a stranger owns it: delegatecall, upgrade, sweep, self-destruct?
  • After deployment, does a script read the owner and initialized state of each proxy and each implementation on chain?

How does QuillShield check for uninitialized proxies?

An open initializer is easy to miss in a review of one contract, because the bug is in how the contracts get deployed and wired together. QuillShield's full audit takes the whole Solidity codebase of a Foundry project, builds a security graph of the code and lists the invariants it must keep. A separate reviewer agent tries to disprove each finding, and the ones that hold up come with the exact lines, the impact, a recommended fix and, on full audits, a proof of concept. Privileged roles are one of the things you can describe in the context before an audit, so write down which account should own each proxy and each implementation.

Upgrades are where new initializers appear, so the pull request checks matter here: QuillShield checks every pull request on GitHub or GitLab.com against the audit's security graph, and on GitHub, with branch protection or rulesets, a required QuillShield check blocks the merge while the pull request has a High or Critical finding.

Before a major upgrade, run a full audit on the new version and request a manual audit from QuillAudits for the upgrade plan. A QuillShield audit is not a substitute for that review; its job is to keep checking every change once the upgrade ships. Sign-up is free.

FAQ

Do I need to initialize the implementation contract?

You need to make sure nobody else can. Lock it in its constructor so its initializer always reverts; then its storage stays empty and unowned, which is what you want for a contract that only holds code.

Is an uninitialized proxy still dangerous after Cancun?

Yes. Cancun changed what selfdestruct does, so an implementation can no longer be deleted the way Parity's library was, but whoever initializes a live proxy still becomes its owner.

Can an upgrade leave a contract uninitialized?

Yes, when version 2 adds variables that a new initializer sets and the upgrade doesn't call it in the same transaction. Until someone calls it, the first caller decides those values.

Is there an SWC entry for uninitialized proxies?

Not directly. The nearest are SWC-118, Incorrect Constructor Name, where a function meant to run once at creation became callable by anyone, and SWC-106, Unprotected SELFDESTRUCT Instruction, which cites the Parity post-mortem. On the OWASP Smart Contract Top 10 (2025) the closest entry is SC01, Access Control Vulnerabilities.

Sources

QuillShield is building the security layer between AI and money, so you can keep shipping between audits.

Sign-up is free, and new accounts get $50 in credit, good for up to half of an order.

  1. 1Sign up and import a repo
  2. 2See the exact price before anything is charged
  3. 3Approve it, and the audit starts