Covalent contest - WatchPug's results

One unified API. One billion possibilities.

General Information

Platform: Code4rena

Start Date: 19/10/2021

Pot Size: $30,000 ETH

Total HM: 5

Participants: 13

Period: 3 days

Judge: GalloDaSballo

Total Solo HM: 4

Id: 43

League: ETH

Covalent

Findings Distribution

Researcher Performance

Rank: 2/13

Findings: 3

Award: $11,088.93

🌟 Selected for report: 5

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: WatchPug

Labels

bug
3 (High Risk)
resolved
sponsor confirmed

Awards

2.9984 ETH - $10,723.39

External Links

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-10-covalent/blob/ded3aeb2476da553e8bb1fe43358b73334434737/contracts/DelegatedStaking.sol#L62-L63

// 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 implementaion 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();
    ...
}

#0 - GalloDaSballo

2021-10-30T00:19:06Z

Agree with the finding, when using Upgradeable Proxies it's important to use the adequate libraries that will be compatible with initializable contracts

#1 - GalloDaSballo

2021-10-30T00:22:29Z

The sponsor has mitigated the issue

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter