Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Owners can set function and collection admins #1383

Closed
c4-submissions opened this issue Nov 13, 2023 · 5 comments
Closed

Owners can set function and collection admins #1383

c4-submissions opened this issue Nov 13, 2023 · 5 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-303 edited-by-warden sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

c4-submissions commented Nov 13, 2023

Lines of code

https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/NextGenAdmins.sol#L44
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/NextGenAdmins.sol#L50
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/NextGenAdmins.sol#L58
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/NextGenAdmins.sol#L31

Vulnerability details

https://seize-io.gitbook.io/nextgen/nextgen-smart-contracts/minter
https://code4rena.com/contests/2023-10-nextgen#top

Impact

From the provided readme and documentation, the functions to register a function and a collection admin are only to be called by a global admin who are registered by the owners.

The registerFunctionAdmin, registerBatchFunctionAdmin and registerCollectionAdmin functions are protected using the AdminRequired modifier.
However, the modifier is allows both the global admin and the owner. This gives the owner the ability to register function and collection admins which breaks the protocol's main invariant.

Proof of Concept

From the provided readme

Main invariants
Properties that should NEVER be broken under any circumstance:

Admin roles can only be registered on the Admin Contract.
Global Admins can only be registered by the Admin Contract owner. 
Function and Collection admins can only be registered by global admins.  

and the provided documentation,

2. Register a Function Admin
The registerFunctionAdmin(..) function is used to register function admins who can call specific functions on the Core and Minter contracts.
...
Notes:
This function can be called by a global admin.
3. Register a Collection Admin
The registerCollectionAdmin(..) function is used to register collection admins who can call certain functions for a specific collection on the Core and Minter contracts.
...
Notes:
This function can be called by a global admin.

The registerFunction/Batch/CollectionAdmin functions uses the AdminRequired modifier.

function registerFunctionAdmin(address _address, bytes4 _selector, bool _status) public AdminRequired {
        functionAdmin[_address][_selector] = _status;
    }

    // function to register batch functions admin
function registerBatchFunctionAdmin(address _address, bytes4[] memory _selector, bool _status) public AdminRequired {
        for (uint256 i=0; i<_selector.length; i++) {
            functionAdmin[_address][_selector[i]] = _status;
        }
    }
    // function to register a collection admin

function registerCollectionAdmin(uint256 _collectionID, address _address, bool _status) public AdminRequired {
        require(_collectionID > 0, "Collection Id must be larger than 0");
        collectionAdmin[_address][_collectionID] = _status;
    }

The AdminRequired modifier is defined - it allows the msg.sender to be a global admin or the owner.

      modifier AdminRequired {
      require((adminPermissions[msg.sender] == true) || (_msgSender()== owner()), "Not allowed");
      _;
    }

This allows the owner to be able to set these admins, but breaks the protocol's invariants.

Tools Used

Manual code review

Recommended Mitigation Steps

Updating the modifier, e.g

    modifier AdminRequired {
      require((adminPermissions[msg.sender] == true);
      _;
    }

Assessed type

Access Control

@c4-submissions c4-submissions added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 13, 2023
c4-submissions added a commit that referenced this issue Nov 13, 2023
@code4rena-admin code4rena-admin changed the title Breaking of protocol invariant Owners can set function and collection admins Nov 13, 2023
@a2rocket
Copy link

owner or global admins should register functions or collection admins, this is how it should work.

@c4-sponsor
Copy link

a2rocket (sponsor) disputed

@c4-sponsor c4-sponsor added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Nov 24, 2023
@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Nov 27, 2023
@c4-pre-sort
Copy link

141345 marked the issue as sufficient quality report

@c4-judge c4-judge closed this as completed Dec 7, 2023
@c4-judge
Copy link

c4-judge commented Dec 7, 2023

alex-ppg marked the issue as duplicate of #303

@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as unsatisfactory:
Overinflated severity

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-303 edited-by-warden sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

6 participants