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

Use of NextGenAdmins in all contracts that define an adminsContract is flawed and any Admin can become the owner of adminsContract #303

Closed
c4-submissions opened this issue Nov 5, 2023 · 7 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 primary issue Highest quality submission among a set of duplicates 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

Lines of code

https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/NextGenCore.sol#L322-L325
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L454-L457
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/RandomizerNXT.sol#L45-L47
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/RandomizerVRF.sol#L94-L97
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/RandomizerRNG.sol#L61-L64

Vulnerability details

Let’s take the example of RandomizerNXT for the sake of simplicity.

Impact

In RandomizerNXT.sol and Admin of adminsContract can design himself as a function admin for the updateAdminContract function and update the admin contract to one he is the owner of.

This defeats the whole purpose of the onlyOwner modifier in the registerAdmin function in NextGenAdmins.sol

This is marked as MEDIUM as the probability of a malicious Admin is moderate.

Proof of Concept

When the RandomizerNXT.sol contract is initially deployed, the adminsContract is set in the constructor.

constructor(address _randoms, address _admin, address _gencore) {
        randoms = IXRandoms(_randoms);
        adminsContract = INextGenAdmins(_admin);
        gencore = _gencore;
        gencoreContract = INextGenCore(_gencore);
}

In this NextGenAdmins, the owner() and only the owner() is able to designate global Admins via the registerAdmin function as defined below

function registerAdmin(address _admin, bool _status) public onlyOwner {
        adminPermissions[_admin] = _status;
}

Let’s put ourselves in the situation where a global Admin has been chosen by the owner().

This Admin should be able to define FunctionAdmins with the registerFunctionAdmin function as defined below

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

but should NOT be able to register other global Admins as the registerAdmin function uses the onlyOwner modifier.

However, Admin can declare themselves as a Function Admin for the updateAdminsContract function, meaning he is able to update the adminsContract to a contract from which he is the owner() and where he can nominate global Admins.

Tools Used

Manual review / Visual Studio

Recommended Mitigation Steps

The updateAdminsContract function should use an OwnerRequired modifier instead of the FunctionAdminRequired(this.updateAdminsContract.selector) modifier it is currently using.
This OwnerRequired modifier could look like the below

modifier OwnerRequired() {
      require(adminsContract.owner() == msg.sender , "Not allowed");
      _;
}

This would ensure that admins are not able to replace the owner and result in stronger access control.

Assessed type

Governance

@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 5, 2023
c4-submissions added a commit that referenced this issue Nov 5, 2023
@c4-pre-sort
Copy link

141345 marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Nov 17, 2023
@c4-pre-sort
Copy link

141345 marked the issue as primary issue

@c4-pre-sort c4-pre-sort added the primary issue Highest quality submission among a set of duplicates label Nov 18, 2023
@c4-sponsor c4-sponsor added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Nov 23, 2023
@c4-sponsor
Copy link

a2rocket (sponsor) disputed

@a2rocket
Copy link

this is the intended design, owner of the NextGenAdmins contract can set Admins which are fully trusted.

@alex-ppg
Copy link

alex-ppg commented Dec 5, 2023

The Warden specifies a way whereby a function administrator can escalate themselves to be a global administrator. This falls under suitable findings per the relevant Centralization Risks Supreme Court verdict, however, I am inclined to mark this as a non-issue.

The reasoning behind this judgment is that a function administrator is expected to have complete access to the relevant function, and the updateAdminsContract function can only achieve one outcome; the upgrade of the administrative contract that handles overall ACL for the contract.

As such, a function administrator of that particular function is considered to be identical to a global administrator in my viewpoint given the responsibilities associated with the function. I believe this finding to be better suited for an Analysis review / QA (NC) and thus of overinflated severity.

To note, all duplicated issues of this exhibit do not refer to privilege escalation, they instead pertain to various centralization abuses that fall under the same SC ruling and thus are considered invalid. If necessary, this finding and its duplicates will be split into separate issues but for now, the whole group falls under centralization risks and is invalid.

@c4-judge c4-judge closed this as completed Dec 5, 2023
@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Dec 5, 2023
@c4-judge
Copy link

c4-judge commented Dec 5, 2023

alex-ppg marked the issue as unsatisfactory:
Invalid

@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as unsatisfactory:
Overinflated severity

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 primary issue Highest quality submission among a set of duplicates 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