Missing _disableInitializer() implementation
The upgradeable implementation contract does not call _disableInitializers() in its constructor, so it can be initialized by anyone. An attacker could take ownership of the implementation, which might indirectly affect proxy contracts that rely on it.
Originally disclosed on Immunefi
- Disclosed after under an hour
#36970 [SC-Insight] Missing `_disableInitializer()` implementation
Submitted on Nov 21st 2024 at 07:59:06 UTC by @FaisalAli19 for Audit Comp | Anvil: Letters of Credit
- Report ID: #36970
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/AcronymFoundation/anvil-contracts/blob/main/contracts/LetterOfCredit.sol
- Impacts:
- Missing `_disableInitializer()` implementation
Description
Brief/Intro
The `LetterOfCredit.sol` contract uses the Initializable module and is missing a call to _disableInitializers() in its constructor. This function is critical to ensure that the implementation contract is locked and cannot be initialized.
Vulnerability Details
The implementation contract is missing a call to `_disableInitializers()` in its constructor. This function is critical to ensure that the implementation contract is locked and cannot be initialized. If an attacker successfully initializes the implementation contract, they could potentially gain unauthorized control over it, which might impact proxy contracts pointing to the implementation.
Impact Details
An uninitialized implementation contract poses a significant security risk:
- Unauthorized Access: Attackers could initialize the implementation contract, setting themselves as the contract owner or manipulating state variables.
- Proxy Impact: Malicious control over the implementation could indirectly affect proxy contracts relying on it.
References
Please check the Initializing the Implementation Contract section. https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable
Proof of Concept
```solidity constructor() initializer {} ```
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 implementation contract's constructor does not call _disableInitializers(), leaving the initializer callable on the implementation itself.
Impact
An attacker could initialize the implementation contract and set themselves as owner or change state, which might indirectly affect proxy contracts relying on it.
What the attacker needed
Implementation contract deployed; initializer not yet called
The fix
Add a call to _disableInitializers() in the implementation contract's constructor so it cannot be initialized.
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.
Upgradeable contracts often use a proxy pattern: a proxy contract holds the storage and forwards calls to an implementation contract that contains the logic. The implementation contract should be locked so nobody can call its initializer directly. Here it was not locked, so someone could become its owner, which might cause problems for proxies using it.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.