Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: low
Invalid

Function MembershipERC1155::initialize() is missing onlyInitializing modifier thus limiting future inheritance.

Summary

Function MembershipERC1155::initialize() uses the initializer modifier which can only be called once, even when using inheritance ( as per OZ docs -see below link). This limits contracts that want extend/inherit from it inlcuding future upgrades by owner or others. Its recommended that parent contracts should use the onlyInitializing modifier.

From the OZ docs: per OZ docs: https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable

Another difference between a constructor and a regular function is that Solidity takes care of automatically invoking the constructors of all ancestors of a contract. When writing an initializer, you need to take special care to manually call the initializers of all parent contracts. Note that the initializer modifier can only be called once even when using inheritance, so parent contracts should use the onlyInitializing modifier:

If the contract MembershipERC1155 was meant to be not extendible, then it should have used abstract keyword/modifier as such.

Vulnerability Details

Snippets below show the function [MembershipERC1155::initialize() ] which is missing the onlyInitializing modifier.

function initialize(
string memory name_,
string memory symbol_,
string memory uri_,
address creator_,
address currency_
) external initializer {
_name = name_;
_symbol = symbol_;
creator = creator_;
currency = currency_;
_setURI(uri_);
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(DAO_CREATOR, creator_);
_grantRole(OWP_FACTORY_ROLE, msg.sender);
}

Impact

This limits future inheritance inlcuding future upgrades by owner or others. If there is ever a need to extend/inherit this contract for any reason, then those inheriting can't make use of OpenZeppelin Upgrades and initializer or _disableInitializers() capabilities (docs link in summary). Also, If the contract MembershipERC1155 was meant to be not inheritable, then it should have used **abstract keyword/modifier **as such.

Tools Used

Manual review.

Recommendations

Add the correct modifier. Snippets below show the function [MembershipERC1155::initialize() ] with the correct onlyInitializing modifier.

function initialize(
string memory name_,
string memory symbol_,
string memory uri_,
address creator_,
address currency_
) external onlyInitializing {
_name = name_;
_symbol = symbol_;
creator = creator_;
currency = currency_;
_setURI(uri_);
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(DAO_CREATOR, creator_);
_grantRole(OWP_FACTORY_ROLE, msg.sender);
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.