Skip to content

Fix role admin guardian cancellation in AccessManager - #6885

Open
Chandain wants to merge 2 commits into
OpenZeppelin:masterfrom
Chandain:fix/accessmanager-role-admin-guardian-cancel
Open

Chandain wants to merge 2 commits into
OpenZeppelin:masterfrom
Chandain:fix/accessmanager-role-admin-guardian-cancel

Conversation

@Chandain

Copy link
Copy Markdown

Fixes #6877.

The guardian check in _canCancel uses the role assigned to the target
function. For scheduled grantRole and revokeRole operations, however,
authorization is derived from the administered role's admin role.

This change also allows the guardian of that derived admin role to cancel
the scheduled operation, while preserving the existing role-admin and
global-admin paths.

Tests cover:

  • Guardian cancellation of scheduled grantRole
  • Guardian cancellation of scheduled revokeRole
  • Rejection of accounts that are neither the role admin nor its guardian

Validation:

  • AccessManager.test.js: 482 passing

@Chandain
Chandain requested a review from a team as a code owner November 18, 2026 16:14
@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fa4f385

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For manager-targeted admin-restricted calls whose required role is not ADMIN_ROLE, AccessManager now permits cancellation by members of the required role or its guardian role. Tests cover successful cancellation by guardians, rejection of an unauthorized caller, and clearing the scheduled operation.

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to cca67

This change lets the guardian of a role's admin role cancel scheduled grant and revoke operations, matching the linked issue. No behavioral risk was found. The CI check still needs a changeset file added before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the role admin guardian can now cancel scheduled grantRole and revokeRole operations in AccessManager. The raw summary confirms that _canCancel now accepts the guardia…
Description check Passed The description gives the purpose of the change. It explains that the _canCancel guardian check used the target function's role, while scheduled grantRole and revokeRole operations derive authorizatio…
Linked Issues check Passed Issue #6877 requires the guardian of the administered role's derived admin role to be able to cancel scheduled grantRole and revokeRole operations. The reviewed diff changes AccessManager._canCancel (…
Out of Scope Changes check Passed The code change is a two-line edit inside _canCancel. It affects only the admin-restricted, non-ADMIN_ROLE branch that #6877 addresses. The added tests cover the new guardian behavior and the rejectio…
Full details: Title check

Explanation

The title names the main change: the role admin guardian can now cancel scheduled grantRole and revokeRole operations in AccessManager. The raw summary confirms that _canCancel now accepts the guardian of the role's admin role.

Full details: Description check

Explanation

The description gives the purpose of the change. It explains that the _canCancel guardian check used the target function's role, while scheduled grantRole and revokeRole operations derive authorization from the administered role's admin role. It also lists the tests added and the validation result, which match the raw summary.

Full details: Linked Issues check

Explanation

Issue #6877 requires the guardian of the administered role's derived admin role to be able to cancel scheduled grantRole and revokeRole operations. The reviewed diff changes AccessManager._canCancel (contracts/access/manager/AccessManager.sol, around line 730). For admin-restricted calls where roleId != ADMIN_ROLE, the function now returns inRole || isRoleGuardian, where isRoleGuardian = hasRole(getRoleGuardian(roleId), msgsender). This matches the change suggested in #6877. The existing role-admin-member check and the earlier guardian check on getTargetFunctionRole(...) are unchanged, so the role-admin and global-admin paths are preserved. The test diff adds three cases in test/access/manager/AccessManager.test.js: guardian cancels scheduled revokeRole, guardian of the role admin cancels scheduled grantRole, and an unrelated account is rejected with AccessManagerUnauthorizedCancel. The PR reports 482 passing for AccessManager.test.js. I did not run the test suite, so that result is taken from the PR description only. The code path supports the requirement.

Full details: Out of Scope Changes check

Explanation

The code change is a two-line edit inside _canCancel. It affects only the admin-restricted, non-ADMIN_ROLE branch that #6877 addresses. The added tests cover the new guardian behavior and the rejection case. No unrelated files or hunks appear in the reviewed diff for the merge base to head comparison. The changed files are contracts/access/manager/AccessManager.sol and test/access/manager/AccessManager.test.js.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59a1345d-cc44-4f8a-93d3-20792d7f6209
Commits

Reviewing files that changed from the base of the PR and between 7ee8e00 and cca679a.

Files selected for processing: 2

  • contracts/access/manager/AccessManager.sol
  • test/access/manager/AccessManager.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor
view gas comparison

Changes to gas costs

Contract Method Min (+/-) % Max (+/-) % Median (+/-) % Avg (+/-) %
$AccessManager [constructor] - - - - - - - - - 2584488 +14707 +0.57% ❌
$AccessManagerMock [constructor] - - - - - - - - - 2624901 +14730 +0.56% ❌
$AccessManagerMock $_grantRole 11921 0 0.00% ➖ 28258 0 0.00% ➖ 28198 0 0.00% ➖ 27468 -85 -0.31% ✔️
$AccessManagerMock $_setRoleGuardian 7629 -12 -0.16% ✔️ 24789 0 0.00% ➖ 16191 -24 -0.15% ✔️ 16193 -22 -0.14% ✔️
$AccessManagerMock cancel 9816 0 0.00% ➖ 30886 +5408 +21.23% ❌ 20609 +5398 +35.49% ❌ 19933 +3516 +21.42% ❌
$AccessManagerMock hasRole 1610 0 0.00% ➖ 4232 0 0.00% ➖ 4104 0 0.00% ➖ 3889 +9 +0.23% ❌
$AccessManagerMock schedule 19849 0 0.00% ➖ 38296 0 0.00% ➖ 36949 0 0.00% ➖ 35803 +23 +0.06% ❌

This branch is waiting to be deployed

1 waiting deployment
certora — fa4f3857 Waiting Nov 18, 2026 by Chandain via verify #816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AccessManager: guardian of the role admin still cannot cancel scheduled grantRole/revokeRole after #6573

1 participant