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.
- 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
- Report ID: #49250
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/Folks-Finance/algorand-smart-contract-library/blob/main/contracts/library/AccessControl.py
- Impacts:
Description
Description
When grant_role is called, the internal _grant_role subroutine explicitly sets the admin of a role to default_admin_role.
@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.
@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
- Add any new role
- There's a storage write
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
- Add any new role
- 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.