Skip to content
Access control Audit finding Intermediate

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.

FaisalAli19 Follow

Originally disclosed on Immunefi

Informational View original
  • 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

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:

  1. Unauthorized Access: Attackers could initialize the implementation contract, setting themselves as the contract owner or manipulating state variables.
  2. 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

https://github.com/AcronymFoundation/anvil-contracts/blob/b03f034929b4c0972c8d81f2d0d33dd730056aa2/contracts/LetterOfCredit.sol#L157

```solidity constructor() initializer {} ```

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

More from Anvil: Letters of Credit

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.