Usage of an incorrect version of Ownbale library can potentially malfunction all onlyOwner functions
The contract used a non-upgradeable Ownable library in an upgradeable proxy, so no owner was set and all onlyOwner functions became inaccessible. An attacker could not directly exploit this, but the contract's owner-only functions would be permanently unusable.
Submitted by WatchPug
// this is used to have the contract upgradeable
function initialize(uint128 minStakedRequired) public initializer {
Based on the context and comments in the code, the DelegatedStaking.sol contract is designed to be deployed as an upgradeable proxy contract.
However, the current implementation is using an non-upgradeable version of the Ownbale library: @openzeppelin/contracts/access/Ownable.sol instead of the upgradeable version: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol.
A regular, non-upgradeable Ownbale 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.
As a result, all the onlyOwner functions will be inaccessible.
Recommendation
Use @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol and @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol instead.
And change the initialize() function to:
function initialize(uint128 minStakedRequired) public initializer {
__Ownable_init();
...
}
kitti-katy (Covalent) confirmed
GalloDaSballo (judge) commented:
Agree with the finding, when using Upgradeable Proxies it’s important to use the adequate libraries that will be compatible with initializable contracts
GalloDaSballo (judge) commented:
The sponsor has mitigated the issue
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 contract used a non-upgradeable Ownable library instead of the upgradeable version, so the owner was not initialised in the proxy.
Impact
All onlyOwner functions became inaccessible, which could prevent the owner from managing the contract.
What the attacker needed
Contract deployed as upgradeable proxy
The fix
The issue was fixed by using the upgradeable Ownable library and calling its initializer in the initialize 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.
Smart contracts can be made upgradeable by using a proxy pattern, where the logic contract is separate from the storage. The Ownable library sets an owner in the constructor, but constructors don't run for proxy contracts. So the owner was never set, and functions restricted to the owner could not be called by anyone.
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.