Skip to content
Misconfiguration Audit finding Intermediate

Dispatcher.sol uses initializer modifier instead of onlyInitializing

The Dispatcher contract uses the initializer modifier instead of onlyInitializing, which prevents the parent Router contract from completing its own initialization. This could cause deployment failures for critical protocol contracts.

Kyosi Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#43195 [SC-Insight] `Dispatcher.sol` uses `initializer` modifier instead of `onlyInitializing`

Submitted on Apr 3rd 2025 at 15:31:11 UTC by @Kyosi for Audit Comp | Spectra Finance

Description

Brief/Intro

Dispatcher contract is a child contract of the Router contract and it uses initializer modifier instead of onlyInitializing. In the inheritance model, the contract Router has its own initialize function, which includes the initializer modifier and calls the __Dispatcher_init function of Dispatcher contract. The problem here is that both the parent contract (Router) and the child contract (Dispatcher) are using the initializer modifier, which limits initialization to only one call.

Vulnerability Details

According to the Openzeppelin documentation https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-initializer-- , the onlyInitializing modifier should be used to allow initialization in both the parent and child contracts (https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-onlyInitializing--). The onlyInitializing modifier ensures that when the initialize function is called, any contracts in the inheritance chain can still complete their own initialization. From the Openzeppelin docs: A modifier that defines a protected initializer function that can be invoked at most once. In its scope, onlyInitializing functions can be used to initialize parent contracts.

Impact Details

The vulnerability causes an operational issue, preventing inheriting contracts from completing initialization. This could lead to a failure in the deployment of critical protocol contracts, affecting the overall system functionality.

References

https://github.com/immunefi-team/Spectra-Audit-Competition/blob/1cebdc67a9276fd87105d13f302fd77d000d0c0b/src/router/Dispatcher.sol#L73-L79

Same issue found in another protocol: https://solodit.cyfrin.io/issues/m-5-masteramo-should-not-use-the-initializer-modifier-sherlock-axion-git

Mitigation

Replace initializer with onlyInitializing on Dispatcher.sol

Solidity
    function __Dispatcher_init(address _routerUtil, address _kyberRouter) internal onlyInitializing {
        if (_routerUtil == address(0)) {
            revert AddressError();
        }
        routerUtil = _routerUtil;
        kyberRouter = _kyberRouter;
    }

Proof of Concept

Proof of Concept

None

The original report as published on Immunefi, by Kyosi. 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

Likely the developer used the initializer modifier on the child contract's internal init function instead of onlyInitializing, which blocks the parent contract's initialization.

Impact

This could lead to a failure in the deployment of critical protocol contracts, affecting the overall system functionality.

What the attacker needed

None

The fix

Replace initializer with onlyInitializing on Dispatcher.sol.

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.

In Solidity, contracts can inherit from other contracts. When a child contract is set up, it may need to call setup functions in its parent. The initializer modifier stops any setup from running more than once, so if both parent and child use it, the parent's setup is blocked. The onlyInitializing modifier is designed to allow each contract in the chain to run its own setup once.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More from Spectra Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.