Skip to content
Smart contracts Audit finding Intermediate

UpgradeToken(...) can not initialize an upgraded token because the data variable of upgradeToAndCall() is hardcoded to empty string

The upgradeToken function in ArcTokenFactory.sol calls upgradeToAndCall with an empty data argument, so it cannot initialize new state variables when upgrading a token. An attacker cannot exploit this directly, but the admin cannot perform an atomic upgrade and initialization, potentially leaving the token uninitialized.

Kaysoft Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

51850 sc low upgradetoken can not initialize an upgraded token because the data variable of upgradetoandcall is hardcoded to empty string

Submitted on Aug 6th 2025 at 08:16:42 UTC by @kaysoft for Attackathon | Plume Network

Description

Brief/Intro

The second argument of upgradeToAndCall() called in the upgradeToken(...) is used to initialize variables during upgrade.

The upgradeToken(...) cannot initialize an upgraded token because the data variable of upgradeToAndCall() is hardcoded to an empty string.

Solidity
File: ArcTokenFactory.sol
 // Perform the upgrade (this assumes the token implements UUPSUpgradeable)
        UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");//FINDING: Empty string hardcoded blocks calling of init functions during upgrade.

Vulnerability Details

The empty string ("") is used in the call to upgradeToAndCall() made in the upgradeToken(...) function in ArcTokenFactory.sol.

This prevents initializing state during an upgrade. For example, if a new upgrade adds PausableUpgradeable, its initialization function (which sets the pause-related state) cannot be invoked during the same transaction because no data payload is forwarded.

Code excerpt:

Solidity
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
        FactoryStorage storage fs = _getFactoryStorage();

        // Ensure the token was created by this factory
        if (fs.tokenToImplementation[token] == address(0)) {
            revert TokenNotCreatedByFactory();
        }

        // Ensure the new implementation is whitelisted
        bytes32 codeHash = _getCodeHash(newImplementation);
        if (!fs.allowedImplementations[codeHash]) {
            revert ImplementationNotWhitelisted();
        }

        // Perform the upgrade (this assumes the token implements UUPSUpgradeable)
        UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");//@audit empty string limits opportunity to initialize variables when upgrading.

        // Update the implementation mapping
        fs.tokenToImplementation[token] = newImplementation;

        emit TokenUpgraded(token, newImplementation);
    }

Impact Details

If a new implementation requires initialization (e.g., to set storage variables introduced in the upgrade), upgradeToken(...) cannot initialize those variables because the data argument passed to upgradeToAndCall() is hardcoded as an empty string. This prevents performing the initialization atomically with the upgrade.

Recommendation

Allow passing initialization calldata to upgradeToken(...) since the function is access-controlled. Example suggested change:

Diff
--   function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
++   function upgradeToken(address token, address newImplementation, bytes initData) external onlyRole(DEFAULT_ADMIN_ROLE) {
        FactoryStorage storage fs = _getFactoryStorage();

        // Ensure the token was created by this factory
        if (fs.tokenToImplementation[token] == address(0)) {
            revert TokenNotCreatedByFactory();
        }

        // Ensure the new implementation is whitelisted
        bytes32 codeHash = _getCodeHash(newImplementation);
        if (!fs.allowedImplementations[codeHash]) {
            revert ImplementationNotWhitelisted();
        }

        // Perform the upgrade (this assumes the token implements UUPSUpgradeable)
--        UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");
++        UUPSUpgradeable(token).upgradeToAndCall(newImplementation, initData);

        // Update the implementation mapping
        fs.tokenToImplementation[token] = newImplementation;

        emit TokenUpgraded(token, newImplementation);
    }

This preserves access control while enabling atomic upgrade+initialize behavior.

Proof of Concept

{% stepper %} {% step %}

Step

Admin of ArcTokenFactory.sol attempts to upgrade an ArcToken to add Permit support using ERC20PermitUpgradeable. {% endstep %}

{% step %}

Step

The new implementation requires calling __ERC20Permit_init("ArcToken") (or similar) in its initializer to set permit-related state. {% endstep %}

{% step %}

Step

Because upgradeToken(...) calls upgradeToAndCall(newImplementation, "") with an empty data argument, the initialization calldata cannot be passed and the required initialization does not occur within the upgrade transaction. The init must be executed separately, meaning the token won't be properly initialized atomically during upgrade. {% endstep %} {% endstepper %}

The original report as published on Immunefi, by kaysoft. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The upgradeToken function hardcodes an empty string as the data argument to upgradeToAndCall, preventing any initialisation call from being forwarded.

Impact

The token cannot be initialised atomically during an upgrade, so the admin must perform initialisation separately, which may leave the token improperly initialised.

What the attacker needed

Admin role on ArcTokenFactory; new implementation requires initialisation

The fix

The upgradeToken function should accept an initData parameter and pass it to upgradeToAndCall.

How it was found

  1. Admin attempts to upgrade an ArcToken to add Permit support using ERC20PermitUpgradeable.
  2. The new implementation requires calling __ERC20Permit_init to set permit-related state.
  3. Because upgradeToken calls upgradeToAndCall with an empty data argument, the initialisation calldata cannot be passed and the required initialisation does not occur within the upgrade transaction.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a smart contract is upgraded, it sometimes needs to run a setup function to initialise new variables. This report says the upgrade function always passes an empty setup message, so that initialisation cannot happen during the upgrade. The result is that the admin must do the setup separately, which is less safe and can leave the contract in a bad state.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Kaysoft

View all

22 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.