strix/skills/cloud/azure.md
Azure security spans two related but distinct control planes:
Do not equate an Entra directory role with an Azure resource role. A principal can be weak in one plane and privileged in the other, and many escalation paths cross between them.
Record before testing:
Start with native CLI context:
az cloud show --output json
az account show --output json
az account list --all --refresh --output json
az account management-group list --no-register --output json
az ad signed-in-user show --output json
az role assignment list --subscription <subscription-id> --all --include-inherited --output json
az role assignment list --subscription <subscription-id> --assignee <user-object-id> --all --include-inherited --include-groups --output json
az role definition list --subscription <subscription-id> --output json
For a service principal, az ad signed-in-user show does not apply; resolve the current client/service-principal object explicitly from the reviewed credential context. --all remains scoped to the selected subscription, and --include-groups depends on Microsoft Graph and can still miss nested or workload-derived paths. Repeat the inventory per tenant, management-group root, and in-scope subscription. Never infer identity only from a display name.
An Azure role assignment joins three elements: a security principal, a role definition, and a scope. Scope inheritance runs from management group to subscription to resource group to resource.
Actions, NotActions, DataActions, and NotDataActions; the role name is not a reliable summary.Microsoft.Authorization/elevateAccess/action to grant User Access Administrator at the root / scope. That root assignment can persist after PIM deactivation until it is explicitly removed.Microsoft.Authorization/roleAssignments/write or equivalent role-management authority → grant a stronger role at an allowed scope.Microsoft.ManagedIdentity/userAssignedIdentities/assign/action → inherit its downstream Azure permissions.Model each path using exact principal, action, resource, scope, condition, and resulting effective permission. Check Azure Policy and deny assignments before declaring a theoretical path exploitable.
Microsoft Entra Privileged Identity Management provides time-based and approval-based activation for privileged access. It can govern Microsoft Entra roles, Azure resource roles, and PIM for Groups.
PIM terminology:
With sufficient Microsoft Graph read permissions, compare current schedule instances:
az rest --method GET \
--url 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilityScheduleInstances?$expand=principal,roleDefinition'
az rest --method GET \
--url 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleInstances?$expand=principal,roleDefinition'
Those endpoints cover Microsoft Entra role schedules. Follow @odata.nextLink, and record the exact Graph permissions or delegated role used because weak tokens silently under-enumerate. Azure resource-role PIM is exposed through ARM's Microsoft.Authorization role eligibility/assignment schedule resources; keep the two inventories separate:
az rest --method GET \
--url "https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01&\$filter=atScope()"
az rest --method GET \
--url "https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleAssignmentScheduleInstances?api-version=2020-10-01&\$filter=atScope()"
Follow nextLink there as well. For Entra directory-role inventory, reviewed readers commonly need RoleEligibilitySchedule.Read.Directory and RoleAssignmentSchedule.Read.Directory or an equivalent delegated role/application permission set.
Conditional Access is Entra's identity-driven policy engine and is evaluated after first-factor authentication.
Review:
For workload identities, Conditional Access applies only in limited cases: directly targeted tenant-owned single-tenant service principals can be controlled, but managed identities, Microsoft-owned service principals, most third-party SaaS service principals, and multitenant app registrations do not inherit human MFA semantics. Target the enterprise application service-principal object, not just the app registration, and verify the control at token issuance.
Use sign-in logs and the Conditional Access result to distinguish policy non-application from policy failure. Report-only evaluation is evidence of intended future control, not enforcement.
An app registration is the tenant-level application definition; a service principal is the local security principal representing an application instance in a tenant.
Inventory:
Keep application-object authority separate from service-principal authority. Application ownership and Application.ReadWrite.* can add owners, client secrets, certificates, or federated credentials on the app object; service-principal ownership and ServicePrincipal.ReadWrite.* govern the enterprise application instance. Admin consent is a separate control plane from credential management. Also trace group ownership/membership where a role-bearing group grants app, vault, Azure RBAC, or Entra role access. A secret's metadata proves age/expiry but not that its value is retrievable.
Managed identities remove stored credentials but still carry authority:
Enumerate identity attachments and downstream role assignments. Check who can attach/detach the identity, execute or deploy code in the host workload, access its metadata/token endpoint, or reuse a user-assigned identity across environments. Treat workload control as potential identity control.
A Shared Access Signature (SAS) delegates access to Azure Storage through a signed URI. Review:
listKeys authority, and key-rotation feasibilityMicrosoft recommends a user delegation SAS where supported because it is secured with Entra credentials rather than the account key. User delegation keys and SAS values are time-limited and user-scoped; service/account SAS values derive from account keys, and only service SAS can bind to stored access policies. User delegation SAS is limited to Blob/Data Lake and has a maximum seven-day validity per delegation key. A SAS is a bearer credential; possession can be sufficient even when the holder has no visible Azure role assignment.
Validate each token against its signed permission/resource/time restrictions. Do not treat a redacted or expired SAS found in code as current unauthorized access.
enableRbacAuthorization; RBAC mode invalidates access-policy evaluation for data-plane access.Legacy access-policy write authority on the vault resource can still become self-granting in access-policy mode. In RBAC mode, the equivalent finding depends on DataActions or role-assignment control, not on legacy access-policy mutation.
Treat the following as credential-equivalent or near-equivalent authority when the downstream scope matches:
| Surface | Action or state | Why it matters |
|---|---|---|
| Azure RBAC | Microsoft.Authorization/roleAssignments/write | grants new authority directly |
| Root scope | Microsoft.Authorization/elevateAccess/action | bridges Entra Global Administrator into Azure root access |
| Managed identity | host config write plus .../userAssignedIdentities/assign/action | attaches a stronger identity to attacker-controlled code |
| App object | add secret/cert/federated credential or owner | permits application impersonation |
| Service principal | add credential/owner or modify federation | permits enterprise-app impersonation |
| Storage | listKeys or account-key disclosure | enables service/account SAS and broad account access |
| Storage | generateUserDelegationKey with matching data rights | enables user delegation SAS issuance |
| Key Vault | secret-value read, key sign/decrypt/wrap, or self-grant path | grants equivalent access even without export |
Map whether a principal that lacks direct data access can reconfigure networking, identity, code, diagnostics, export, backup, or deployment to gain an equivalent capability.
For each finding, include:
Actions/DataActions, conditions, scope, or deny assignments block the claimed action.roleAssignments/write or an alternate workload/identity path.Use the official Azure CLI for resource context and az rest for reviewed ARM/Graph queries not exposed cleanly by a command group. Record CLI/API versions and requested permissions. Broad directory inventory often requires Microsoft Graph application permissions and admin consent; absence of results under a weak token is not proof that objects do not exist.
Prowler provides maintained Azure configuration/compliance checks. Install a reviewed pinned release in an isolated environment:
python -m pip install 'prowler==<reviewed-version>'
prowler azure --az-cli-auth --subscription-ids <subscription-id>
Other documented modes include service-principal, browser, and managed-identity authentication. Use a dedicated read-only audit principal with only the documented tenant/subscription permissions. Scope subscription IDs explicitly, protect reports as sensitive asset/identity inventories, account for API volume/throttling, and do not enable cloud upload for assessment data unless approved. Prowler findings are configuration leads; trace effective principal/action/resource paths before treating them as exploitable.
Azure security is an identity-and-scope graph across Entra and ARM. Test directory roles, Azure RBAC, PIM, Conditional Access, service principals, managed identities, delegated storage access, workload control, and service data planes as one system while preserving the distinction between each control plane.