sherlock-audit / 2023-02-blueberry-judging

12 stars 5 forks source link

PNM - Med: Anyone can call initialize() of the implementation contract #345

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

PNM

medium

Med: Anyone can call initialize() of the implementation contract

Summary

Anyone can call initialize() of various implementation contracts

Vulnerability Detail

The initialize function of the following implementation contracts can be triggered by any account: https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/vault/HardVault.sol#L36 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/vault/SoftVault.sol#L41 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/BlueBerryBank.sol#L94 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/ProtocolConfig.sol#L28

Impact

An attacker can get the ownership of those implementation contracts.

Code Snippet

https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/vault/HardVault.sol#L36 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/vault/SoftVault.sol#L41 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/BlueBerryBank.sol#L94 https://github.com/PwnedNoMore-DAO/2023-02-blueberry/blob/main/contracts/ProtocolConfig.sol#L28

Tool used

Recommendation

Avoid leaving a contract uninitialized (see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/Initializable.sol#L51)