hats-finance / SafeStaking-by-HOPR-0x607386df18b663cf5ee9b879fbc1f32466ad5a85

HOPR is an open incentivized mixnet which enables privacy-preserving point-to-point data exchange. HOPR is similar to Tor but actually private, decentralized and economically sustainable.
https://hoprnet.org
GNU General Public License v3.0
0 stars 1 forks source link

OwnableUpgradeable uses single-step ownership transfer #44

Open hats-bug-reporter[bot] opened 11 months ago

hats-bug-reporter[bot] commented 11 months ago

Github username: -- Submission hash (on-chain): 0x92a7480241b5bcbb2fa4d07be5c1f3b42cc96a1bbf51fddd3101dc6de88c828e Severity: medium

Description: Description\

The ownership pattern implementation is linked to the OwnableUpgradeable contract where a single-step transfer is implemented.

This can lead to problem for all methods marked in onlyOwner throughout the codebase, in which some of have core protocol functionality i.e. NodeManagementModule contract.

Attack Scenario\

Single-step transfer of ownership means, if a wrong address is passed during transferring of ownership it will result in loss of owner based role forever.

Attachments

https://github.com/hoprnet/hoprnet/blob/master/packages/ethereum/contracts/src/node-stake/permissioned-module/SimplifiedModule.sol#L7

  1. Proof of Concept (PoC) File

SimplifiedModule contract utilizes OwnableUpgradeable contract which is prone to error due to lack effective control.

import { OwnableUpgradeable } from "openzeppelin-contracts-upgradeable/access/OwnableUpgradeable.sol";
  1. Recommendation

It is a best practice to use two-step ownership transfer pattern where ownership transfer gets to a "pending" state and the new owner should claim his new rights, otherwise the old owner will still has control of the contract.

Consider using OpenZeppelin's Ownable2Step contract.