Skip to content
Business logic Audit finding Intermediate

AccessControl: unnecessary box usage in _grant_role

The report notes that the internal role-granting routine writes the default admin role into storage for every new role, even though the role-admin lookup already falls back to that same default when no entry exists. This is a redundant storage write rather than an exploitable vulnerability, so no attacker impact is claimed.

ustas Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#49250 [SC-Insight] `AccessControl`: unnecessary box usage in `_grant_role`

Submitted on Jul 13th 2025 at 19:10:11 UTC by @ustas for Audit Comp | Folks Smart Contract Library

Description

Description

When grant_role is called, the internal _grant_role subroutine explicitly sets the admin of a role to default_admin_role.

Python
    @subroutine
    def _grant_role(self, role: Bytes16, account: Address) -> Bool:
        # if new role then add the default admin role
        if role not in self.roles:
            self.roles[role] = self.default_admin_role()

However, this explicit storage change is redundant. The get_role_admin function returns default_admin_role if a role's admin is not found in the roles box. This provides an implicit default.

Python
    @abimethod(readonly=True)
    def get_role_admin(self, role: Bytes16) -> Bytes16:
        """Returns the admin role that controls a role

        Args:
            role: The role to get its admin of

        Returns:
            The role admin
        """
        if role not in self.roles:
            return self.default_admin_role()
        return self.roles[role]

Remediation

Remove the if condition block in _grant_role.

Proof of Concept

Proof of Concept

  1. Add any new role
  2. There's a storage write

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

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

Likely the code stores the default admin role explicitly on first grant instead of relying on the existing implicit fallback in the role-admin lookup.

Impact

No security impact is claimed; the only effect is an unnecessary storage write when a new role is granted.

What the attacker needed

None

The fix

The redundant conditional block in the role-granting routine should be removed so the implicit default is relied upon.

How it was found

  1. Add any new role
  2. Observe that a storage write occurs

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.

Smart contracts store data on a blockchain, and every write costs money and space. This code saves a default value into storage even though a separate lookup function already returns that same default when nothing is stored. The report is a code-quality observation, not a security hole.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ustas

View all

2 more disclosed reports, best first.

More from Folks Smart Contract Library

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.