Skip to content
Smart contracts Audit finding Intermediate

Usage of an incorrect version of Ownable library can potentially malfunction all onlyOwner functions

The contracts used the standard non-upgradeable Ownable library inside proxy-based upgradeable contracts, so the constructor that sets the owner never runs and no owner is assigned. As a result, every function restricted to the owner would be unusable after deployment.

robee Follow

Originally disclosed on Code4rena

Submitted by robee

The current implementaion is using a non-upgradeable version of the Ownable library. Instead of the upgradeable version: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol.

A regular, non-upgradeable Ownable library will make the deployer the default owner in the constructor. Due to a requirement of the proxy-based upgradeability system, no constructors can be used in upgradeable contracts. Therefore, there will be no owner when the contract is deployed as a proxy contract

Recommended Mitigation Steps

Use @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol and @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol instead.

And add _Ownableinit(); at the beginning of the initializer.

Oracle.sol AMM.sol


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

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 contracts inherited the non-upgradeable Ownable, whose constructor-based owner assignment does not execute in a proxy deployment, instead of the upgradeable variant initialised explicitly.

What the attacker needed

Contracts deployed behind a proxy

The fix

Switch to the upgradeable Ownable and Initializable libraries and call the Ownable initialiser at the start of the initializer function.

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 are deployed behind a proxy, a contract that forwards calls to the real logic contract. Because of this, constructors do not run, so any setup done in a constructor is lost. The Ownable library normally sets the owner in its constructor, so here nobody ends up as owner and owner-only actions cannot be performed.

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 robee

View all

6 more disclosed reports, best first.

More from Hubble contest

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.