Skip to content
Access control Audit finding Intermediate

Freezing roles in ERC721NFTProduct and ERC1155NFTProduct is moot

The role-freezing feature in the NFT contracts is ineffective because the ADMIN_ROLE can bypass all role restrictions, including DEFAULT_ADMIN_ROLE, allowing the admin to still grant and revoke roles. An attacker with ADMIN_ROLE could modify roles despite the intended freeze.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-nftport-judging/issues/81

Found by

0x52

Summary

In ERC721NFTProduct and ERC1155NFTProduct roles can be frozen which is supposed to lock role to current addresses and not allow any changes. The problem is that admin can still use AccessControlUpgradable#grantRole and revokeRole to grant and remove roles to addresses because hasRole allows "ADMIN_ROLE" to bypass all role restrictions even "DEFAULT_ADMIN_ROLE".

Vulnerability Detail

function hasRole(bytes32 role, address account)
    public
    view
    virtual
    override
    returns (bool)
{
    return
        super.hasRole(ADMIN_ROLE, account) || super.hasRole(role, account);
}

In GranularRoles.sol and AccessControlUpgradable.sol, developers are careful to never grant the "DEFAULT_ADMIN_ROLE" to any user. Additionally they never set the admin role of any role so that it's admin will remain "DEFAULT_ADMIN_ROLE". In theory this should make so that there is no way to grant or revoke roles outside of GranularRoles#_initRoles and updateRoles. The issue is that the override by GranularRoles#hasRole allows "ADMIN_ROLE" to bypass any role restriction including "DEFAULT_ADMIN_ROLE". This allows "ADMIN_ROLE" to directly call AccessControlUpgradable#grantRole and revokeRole, which makes the entire freezing system useless as it doesn't actually stop any role modification.

Impact

Freezing roles doesn't actually prevent "ADMIN_ROLE" from modifying roles as intended. Submitting as high due to gross over-extension of admin authority clearly violating intended guardrails.

Code Snippet

GranularRoles.sol#L87-L96

Tool used

Manual Review

Recommendation

Override AccessControlUpgradable#grantRole and revokeRole in GranularRoles.sol to revert when called:

 GranularRoles.sol

+   function grantRole(bytes32 role, address account) public virtual override {
+       revert();
+   }

+   function revokeRole(bytes32 role, address account) public virtual override {
+       revert();
+   }

Discussion

Evert0x

Admin role having more power than intended is not a med/high issue for the protocol team.

hyperspacebunny

@Evert0x This actually is valid and pretty high priority for us since it's a workaround for some pretty explicit rules in our permissions system. Can you reopen it?

hyperspacebunny

Fixed in https://github.com/nftport/evm-minting-sherlock-fixes/pull/15

rayn731

The fix will disable DEFAULT_ADMIN_ROLE to grant/revoke roles, but _owner still has the ability to grant/revoke roles even if all roles are frozen?

hyperspacebunny

Yup, our current intent is that the owner should always have control over the roles if they want to self-manage, freezing is just to remove the delegation to ADMIN_ROLE

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The hasRole function override in GranularRoles.sol allows ADMIN_ROLE to bypass all role checks, including DEFAULT_ADMIN_ROLE, enabling the admin to call grantRole and revokeRole directly.

Impact

Freezing roles does not prevent the ADMIN_ROLE from modifying roles, violating the intended guardrails and giving the admin more authority than intended.

What the attacker needed

ADMIN_ROLE privileges

The fix

The issue was fixed by overriding grantRole and revokeRole in GranularRoles.sol to revert when called.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

These smart contracts have a system where an admin can freeze roles so that no one can change who has which permissions. But the code that checks permissions lets the main admin role ignore all restrictions, so the admin can still change roles even after freezing. This means the freeze does not actually stop the admin from making changes.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0x52

View all

211 more disclosed reports, best first.

More from NFTPort

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.