AZ_RUNS_AS

Summary

FSProtect ACL Alias

AZ_RUNS_AS

Entra ID (Azure AD) Alias

Runs As Identity

Affected Object Types

Virtual Machines, App Services, Function Apps, Logic Apps, Automation Accounts, Container Instances, Azure Kubernetes Service

Exploitation Certainty

Certain

Description

AZ_RUNS_AS represents the relationship where an Azure resource executes code or performs actions using a specific identity. This edge shows that Resource X runs as Identity Y, meaning the resource can authenticate and access other Azure resources using that identity's permissions.

This relationship is critical for understanding privilege escalation paths because:

  • Managed Identities: Virtual Machines, App Services, Function Apps, and other compute resources can have system-assigned or user-assigned managed identities that grant them access to Azure resources.

  • Automation Run As Accounts: Azure Automation accounts use Run As accounts (service principals) to authenticate when executing runbooks.

  • Service Principal Credentials: Applications and services may run using service principal credentials stored in configuration.

An attacker who compromises a resource with AZ_RUNS_AS can leverage the associated identity to:

  • Access Azure Key Vault secrets, certificates, and keys.

  • Read/write to Azure Storage accounts.

  • Manage Azure resources (VMs, databases, etc.).

  • Access Microsoft Graph API with the identity's permissions.

  • Pivot to other resources accessible by the identity.

Identification

Get Virtual Machines with Managed Identities

Get App Services with Managed Identities

Get Function Apps with Managed Identities

Get Automation Account Run As Accounts

Get All Resources with Managed Identities

Exploitation

If you have access to a resource that runs as a managed identity or service principal, you can leverage that identity to access other Azure resources.

From a Compromised Virtual Machine

From a Compromised App Service / Function App

Access Key Vault Using Managed Identity

Mitigation

  • Apply least-privilege RBAC: Only grant managed identities the minimum permissions required.

  • Use User-Assigned Managed Identities: Prefer user-assigned over system-assigned identities for better control and auditability.

  • Regular access reviews: Periodically review what permissions managed identities have.

  • Network restrictions: Limit where managed identities can be used (e.g., restrict Key Vault access to specific VNets).

  • Disable unnecessary identities: Remove managed identities from resources that don't need them.

  • Monitor identity usage: Enable diagnostic logging on resources to track managed identity usage.

Detection

Monitor for suspicious use of managed identities:

Log Source
Event/Signal
Description

Azure Activity Log

Resource access from unexpected sources

Managed identity used outside normal patterns

Microsoft Entra Sign-in Logs

Service principal sign-ins

Filter by managed identity application IDs

Key Vault Diagnostic Logs

SecretGet, KeyGet operations

Track what secrets are being accessed

Azure Monitor

Unusual API calls

Detect reconnaissance or privilege escalation

Query Sign-in Logs for Managed Identity Usage

References

  • https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview

  • https://learn.microsoft.com/en-us/azure/automation/automation-security-overview

  • https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity

  • https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token

  • https://learn.microsoft.com/en-us/azure/key-vault/general/managed-identity

Was this helpful?