MasterAMO should not use the `initializer` modifier
The MasterAMO contract's initialize function used the initializer modifier, which prevents child contracts from initializing it. This could cause deployment failures for inheriting contracts.
FonDevs Follow with KupiaSec, UsmanAtique and 2 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-10-axion-judging/issues/244
Found by
FonDevs, KupiaSec, UsmanAtique, calc1f4r, hunter_w3b
Summary
MasterAMO is a utils contract that intended to be inherited by SolidlyV2AMO, SolidlyV3AMO contracts, therefore. it's initializer function should not use the initializer modifier, instead, it should use onlyInitializing modifier.
Root Cause
In the MasterAMO.sol:104 contract, the initialize function uses the initializer modifier. This is incorrect for a contract like MasterAMO, which is meant to be inherited by other contracts, such as SolidlyV2AMO and SolidlyV3AMO.
In this inheritance model, the SolidlyV2AMO contract also has its own initialize function, which includes the initializer modifier and calls the initialize function of MasterAMO. The problem here is that both the parent contract MasterAMO and the child contracts SolidlyV2AMO, SolidlyV3AMO are using the initializer modifier, which limits initialization to only one call.
According to the OpenZeppelin documentation, the onlyInitializing modifier should be used to allow initialization in both the parent and child contracts. The onlyInitializing modifier ensures that when the initialize function is called, any contracts in its inheritance chain can still complete their own initialization.
https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-initializer--
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.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
In this scenario, no direct attack or monetary loss is likely. However, the vulnerability causes a significant operational issue, preventing inheriting contracts from completing initialization. This could lead to a failure in the deployment of critical protocol components, affecting the overall system functionality.
PoC
A simple POC in Remix.
Mitigation
Replace the initializer modifier in the MasterAMO contract with the onlyInitializing modifier. This allows the initialize function to be used by both the MasterAMO and any inheriting contracts during their initialization phase, without conflicting with their individual setup processes.
function initialize(
address admin, // // Address assigned the admin role (given exclusively to a multi-sig wallet)
address boost_, // The Boost stablecoin address
address usd_, // generic name for $1 collateral ( typically USDC or USDT )
address pool_, // The pool where AMO logic applies for Boost-USD pair
// On each chain where Boost is deployed, there will be a stable Boost-USD pool ensuring BOOST's peg.
// Multiple Boost-USD pools can exist across different DEXes on the same chain, each with its own AMO, maintaining independent peg guarantees.
address boostMinter_ // the minter contract
- ) public initializer {
+ ) public onlyInitializing {
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/AXION-MONEY/liquidity-amo/pull/11
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
Impact
No direct attack or monetary loss is likely, but inheriting contracts may fail to initialize, causing deployment failures.
What the attacker needed
None
The fix
The protocol team fixed this issue by replacing the initializer modifier with onlyInitializing in MasterAMO.
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.
Smart contracts can inherit from other contracts, like a child inheriting traits from a parent. When setting up such contracts, the parent's setup function must be callable by the child. Using a lock that allows only one call blocks the child from completing setup, so the whole deployment can fail.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.