Azure RBAC role assignment review
Brief
In Azure RBAC the few roles that can write role assignments decide who can become anyone else in a subscription, and Contributor reaches more data than its name suggests. The review lists standing Owner and role-granting assignments at every scope, custom roles that run code or use wildcards, what is standing against what is eligible in PIM, and the vault and storage settings that let Contributor read secrets.
On this page
- Situation
- A review principal with Reader on the subscriptions in scope, and on their management groups where the letter includes them, signed in with the Azure CLI, and directory read so principal names resolve. Every command reads role assignments, role definitions, PIM schedules or resource properties; nothing assigns, activates, removes or edits a role, and no vault or storage account is opened. Only the tenant, management groups and subscriptions the scope letter names are read.
- Goal
- A table of every principal that can grant roles or holds standing Owner, by scope and type, plus the custom roles and resource settings that give Contributor-level principals a path to code or data.
- Outputs
- Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.
Check first
- The subscriptions and management groups in the letter, and that the review principal sees those and no others, from the scoping page.
- Whether the client uses PIM for Azure resources; without it every assignment is standing.
- The client's break-glass accounts and deployment principals by name, so they are recognised rather than reported as surprises.
- The groups that appear in assignments, since a group's members hold its roles.
- Whether directory read works for the review principal; without it principal names print empty and every row needs resolving by id.
Steps
Azure
Who holds standing Owner or User Access Administrator, and where?
az role assignment list --all \
--query "[?roleDefinitionName=='Owner' || roleDefinitionName=='User Access Administrator'].[principalName,principalType,scope]" -o tsv
az account management-group list --query '[].[name,displayName]' -o tsv
az role assignment list --scope /providers/Microsoft.Management/managementGroups/mg-platform --include-inherited \
--query "[?roleDefinitionName=='Owner' || roleDefinitionName=='User Access Administrator'].[principalName,principalType,scope]" -o tsv
Expected output
$ az role assignment list --all --query "[?roleDefinitionName=='Owner' || ...]" -o tsv
breakglass-01@corp.example.com User /subscriptions/00000000-1111-2222-3333-444444444444
Platform Admins Group /subscriptions/00000000-1111-2222-3333-444444444444 # <- every member is a standing Owner
<app-id> ServicePrincipal /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg-ops # <- a deployment identity that can grant itself anything in rg-ops
$ az role assignment list --scope /providers/Microsoft.Management/managementGroups/mg-platform --include-inherited ...
svc-landing-zone@corp.example.com User /providers/Microsoft.Management/managementGroups/mg-platform # <- inherited by every subscription below
Owner and User Access Administrator both carry Microsoft.Authorization/roleAssignments/write, so either one can give any principal any role at its scope, including itself. --all lists every assignment in the current subscription and below; assignments made on a management group above it do not show there, which is why the second read runs at management group scope with --include-inherited. Groups need their members listed, since each member holds the role, and service principals print an application id that az ad sp show --id resolves. A user account holding Owner through a management group reaches every subscription under it.
Negative result. Owner held only by the documented break-glass accounts, no standing User Access Administrator, and deployment principals scoped to the resource groups they deploy with Contributor.
Fix. Move standing Owner and User Access Administrator to eligible assignments in PIM with approval, leave two break-glass accounts excluded and monitored, and give pipelines Contributor on their own resource groups rather than Owner.
Who else can grant roles?
az role assignment list --all \
--query "[?roleDefinitionName=='Role Based Access Control Administrator'].[principalName,scope,condition]" -o tsv
az role definition list --custom-role-only true \
--query "[?permissions[?contains(actions, 'Microsoft.Authorization/*') || contains(actions, 'Microsoft.Authorization/roleAssignments/write')]].roleName" -o tsv
Expected output
$ az role assignment list --all --query "[?roleDefinitionName=='Role Based Access Control Administrator']..." -o tsv
App Team Leads /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg-app None # <- no condition: they can assign Owner in rg-app
$ az role definition list --custom-role-only true --query ... -o tsv
ops-support # <- a custom role that can write role assignments
Role Based Access Control Administrator was made to delegate role assignment with a condition that limits which roles can be given and to whom. Without that condition it is User Access Administrator under another name. Custom roles reach the same place through Microsoft.Authorization/* or the single write action. The JMESPath contains here tests exact entries in the actions list, so a broader wildcard such as * or Microsoft.* is caught by the next step instead.
Negative result. Every Role Based Access Control Administrator assignment carries a condition naming the roles it may assign, and no custom role holds an authorization write.
Fix. Add a condition to every Role Based Access Control Administrator assignment that excludes Owner, User Access Administrator and itself from the roles it can grant.
Which custom roles carry wildcards or code-running actions?
az role definition list --custom-role-only true \
--query "[].{name:roleName,actions:join(',', permissions[0].actions)}" -o tsv
az role definition list --custom-role-only true \
--query "[].[roleName, join(',', assignableScopes)]" -o tsv
Expected output
$ az role definition list --custom-role-only true --query "[].{name:roleName,actions:...}" -o tsv
vm-operator Microsoft.Compute/virtualMachines/read,Microsoft.Compute/virtualMachines/start/action,Microsoft.Compute/virtualMachines/runCommand/action # <- code on every VM it can see, as that VM's identity
ops-support */read,Microsoft.Support/*,Microsoft.Authorization/*
app-config-reader Microsoft.Web/sites/read,Microsoft.Web/sites/config/list/action # <- reads app settings, which hold connection strings
$ az role definition list --custom-role-only true --query "[].[roleName, join(',', assignableScopes)]" -o tsv
vm-operator /subscriptions/00000000-1111-2222-3333-444444444444
A name says what a role was meant for; its actions say what it does. The ones that matter are actions that run code (virtualMachines/runCommand/action, Microsoft.Automation/automationAccounts/runbooks/write, Microsoft.Web/sites/write), actions that read secrets through the control plane (Microsoft.Web/sites/config/list/action, Microsoft.Storage/storageAccounts/listKeys/action) and wildcards at the provider level. The first query reads the first permission block only, which is how almost every custom role is written; a role with two blocks needs permissions[].actions[] read in full. Assignable scopes say where the role can be used, not where it is.
Negative result. Custom roles list named read actions and the specific writes their job needs, with no provider wildcard and no code-running or key-listing action.
Fix. Rewrite custom roles from the actions the team uses, take out runCommand and key listing unless the job is exactly that, and assign code-running roles only through PIM.
Which assignments are standing, and which are eligible in PIM?
az rest --method get \
--url "https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01&\$filter=atScope()" \
--query "value[].[properties.expandedProperties.principal.displayName,properties.expandedProperties.roleDefinition.displayName,properties.endDateTime]" -o tsv
Expected output
Platform Engineers Owner 2027-04-30T00:00:00Z
Platform Engineers User Access Administrator None # <- eligible with no end date: reviewed by nobody until someone looks
An eligible assignment has to be activated, with whatever MFA, justification and approval the role's PIM settings require, and the activation is logged. A standing assignment has none of that. Any principal in the first step that is not also here holds its role permanently. The backslash keeps the shell from reading $filter as a variable. Eligibility with no end date is a weaker finding than standing access, but it means nobody reviews the list.
Negative result. Every Owner and User Access Administrator assignment outside break-glass is eligible, with an end date and approval on activation.
Fix. Convert standing privileged assignments to eligible ones with an end date and approval, and run access reviews on the eligible list each quarter.
Where does Contributor reach data without a data role?
az keyvault list --query "[].[name,properties.enableRbacAuthorization]" -o tsv
az storage account list --query "[].[name,allowSharedKeyAccess]" -o tsv
Expected output
$ az keyvault list --query "[].[name,properties.enableRbacAuthorization]" -o tsv
prod-kv False # <- vault access policies: anyone who can write the vault can grant itself secret reads
shared-kv True
$ az storage account list --query "[].[name,allowSharedKeyAccess]" -o tsv
prodexports None # <- not set, so shared keys work and Contributor can list them
examplelocked False
Contributor has no data actions, yet two settings hand it data anyway. A vault on the access policy model lets anyone with Microsoft.KeyVault/vaults/write, which Contributor holds, add an access policy granting itself secret reads; on the RBAC model that takes a data role. A storage account that allows shared keys gives every principal with listKeys, Contributor included, a key that reads every blob, and None means the setting was never changed from the default that allows it. We report the setting and stop: no access policy is written and no key is listed.
Negative result. Every vault on the RBAC permission model and every storage account with shared key access set to false.
Fix. Move vaults to the Azure RBAC permission model, set allowSharedKeyAccess to false where applications use Entra ID, and keep Contributor off production vaults and storage accounts.
The defender sees
Nothing on this page appears in the Azure Activity Log, which holds writes and actions, not reads: listing assignments, definitions, PIM schedules, vaults and storage accounts leaves no record there. The review principal's Azure CLI sign-in is in the Entra sign-in logs, and the directory lookups that fill principal names are Graph reads, kept only where the tenant exports Graph activity logs. What a defender should watch is the change this review looks for: Microsoft.Authorization/roleAssignments/write and Microsoft.Authorization/roleDefinitions/write in the Activity Log, and PIM activations in the Entra audit log. An alert on either that nobody tested is a finding of its own; the Activity Log review shows how to check.
Done when
Owner, User Access Administrator and Role Based Access Control Administrator assignments are listed at subscription and management group scope with their conditions, every custom role's risky actions are named, standing and eligible assignments are told apart, and every vault and storage account is marked for the access model it uses.
Not covered
Entra directory roles (see the PIM and privileged role review), what runs as a managed identity (see the managed identity review), deny assignments and Azure Policy; the outputs shown are representative examples on a placeholder tenant, not captured runs.