Skip to content

fix(standards): prevent role delegation to a dead admin role from freezing role management - #3476

Merged
mmagician merged 6 commits into
nextfrom
refactor-rbac
Aug 8, 2026
Merged

fix(standards): prevent role delegation to a dead admin role from freezing role management#3476
mmagician merged 6 commits into
nextfrom
refactor-rbac

Conversation

@onurinanc

Copy link
Copy Markdown
Collaborator

Closes: #3475

@PhilippGackstatter PhilippGackstatter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

This means we loose the ability for "irreversible finalization" of a role, i.e. a role without an effective admin. It seems like this may be useful in some cases, similar to renouncing ownership in Ownable2Step. If so, I think we may not need to add it right away, but we could open an issue to document the gap.

Comment on lines +473 to +474
push.ADMIN_ROLE swap
# => [is_memberless, ADMIN_ROLE, effective_admin_role_symbol]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
push.ADMIN_ROLE swap
# => [is_memberless, ADMIN_ROLE, effective_admin_role_symbol]
push.ADMIN_ROLE swap
# => [is_memberless, admin_role, effective_admin_role_symbol]

Comment on lines +470 to +474
dup exec.get_role_member_count_internal eq.0
# => [is_memberless, effective_admin_role_symbol]

push.ADMIN_ROLE swap
# => [is_memberless, ADMIN_ROLE, effective_admin_role_symbol]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dup exec.get_role_member_count_internal eq.0
# => [is_memberless, effective_admin_role_symbol]
push.ADMIN_ROLE swap
# => [is_memberless, ADMIN_ROLE, effective_admin_role_symbol]
push.ADMIN_ROLE
dup.1 exec.get_role_member_count_internal eq.0
# => [is_memberless, admin_role, effective_admin_role_symbol]

nit: avoid unnecessary swap

// MINTER is delegated to MINT_ADMIN, which has no members — an unpopulated or mistyped role.
let set_admin_note = build_note(admin, set_role_admin_script(&minter, Some(&mint_admin)))?;
let updated = execute_note_and_apply(&mock_chain, &account, &set_admin_note).await?;
assert_eq!(get_role_config(&updated, &mint_admin)?.0, Felt::ZERO);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's hard to read what this asserts just by looking at the code. Using a dedicated get_role_member_count helper (that wraps get_role_config) would be useful, or returning a test-only struct with public fields.

@PhilippGackstatter

Copy link
Copy Markdown
Contributor

I somehow hadn't realized that we haven't merged this PR yet. I think the reaches_populated_role check introduced in #3515 becomes much simpler once we do. We only need to check if ADMIN has members, iiuc.

@mmagician mmagician left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@mmagician
mmagician added this pull request to the merge queue Aug 8, 2026
Merged via the queue into next with commit bcbf097 Aug 8, 2026
19 checks passed
@mmagician
mmagician deleted the refactor-rbac branch August 8, 2026 14:37
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.

Role Admin Delegation to a Memberless Role Permanently Freezes Role Management

3 participants