Entra ID Application Self-Assigned to Privileged Role

Last updated a day ago on 2026-10-19
Created a day ago on 2026-10-19

About

Identifies an Entra ID application (service principal) assigning itself to a privileged directory role. An application typically does not promote itself, and a multi-tenant vendor application is even more uncommon. Any service principal self-assigning a privileged role should be investigated. Adversaries may compromise vendor application credentials and then escalate privileges to Exchange Administrator or Global Administrator, or subsequently add client secrets to other applications.
Tags
Domain: CloudDomain: IdentityData Source: AzureData Source: Microsoft Entra IDData Source: Microsoft Entra ID Audit LogsUse Case: Identity and Access AuditUse Case: Threat DetectionTactic: Privilege EscalationTactic: PersistenceRule Type: ES|QLPlatform: Entra IDProfile: BetaLanguage: esql
Severity
high
Risk Score
73
MITRE ATT&CK™

Privilege Escalation (TA0004)(external, opens in a new tab or window)

Persistence (TA0003)(external, opens in a new tab or window)

False Positive Examples
Vendor onboarding or reconfiguration where a consented third-party management or backup application is deliberately granted a directory role by its own setup workflow. Confirm with the application owner and the change record, then exclude the specific application ID. Local automation or provisioning applications that are designed to assign roles to themselves. Review the owner and purpose, then exclude by application ID.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

azure(external, opens in a new tab or window)

Query
text code block:
from logs-azure.auditlogs-* metadata _id, _version, _index // role assignments performed by an application (service principal actor) | where data_stream.dataset == "azure.auditlogs" and azure.auditlogs.operation_name in ( "Add member to role", "Add member to role outside of PIM (permanent)", "Add member to role in PIM completed (permanent)", "Add member to role in PIM completed (timebound)", "Add eligible member to role in PIM completed (permanent)", "Add eligible member to role in PIM completed (timebound)" ) and event.outcome in ("success", "Success") and azure.auditlogs.properties.initiated_by.app.servicePrincipalId is not null // self-assignment: the acting service principal is the member being added | eval Esql.actor_sp_id = azure.auditlogs.properties.initiated_by.app.servicePrincipalId | where Esql.actor_sp_id == `azure.auditlogs.properties.target_resources.0.id` or Esql.actor_sp_id == `azure.auditlogs.properties.target_resources.1.id` // the role name sits in a different modified_properties slot depending on the operation | eval Esql.role_name_raw = coalesce( case(`azure.auditlogs.properties.target_resources.0.modified_properties.0.display_name` == "Role.DisplayName", `azure.auditlogs.properties.target_resources.0.modified_properties.0.new_value`, null), case(`azure.auditlogs.properties.target_resources.0.modified_properties.1.display_name` == "Role.DisplayName", `azure.auditlogs.properties.target_resources.0.modified_properties.1.new_value`, null), case(`azure.auditlogs.properties.target_resources.0.modified_properties.2.display_name` == "Role.DisplayName", `azure.auditlogs.properties.target_resources.0.modified_properties.2.new_value`, null), case(`azure.auditlogs.properties.target_resources.0.modified_properties.3.display_name` == "Role.DisplayName", `azure.auditlogs.properties.target_resources.0.modified_properties.3.new_value`, null) ) | eval Esql.role_name = replace(Esql.role_name_raw, "\"", "") // privileged roles: every built-in role marked PRIVILEGED in the Microsoft Entra built-in roles reference, plus other // built-in roles with administrative control over major Entra and Microsoft 365 services or access to tenant data. // Matched by exact role name, not by pattern. | where to_lower(Esql.role_name) in ( // marked PRIVILEGED by Microsoft "agent id administrator", "ai administrator", "ai reader", "application administrator", "application developer", "attribute provisioning administrator", "attribute provisioning reader", "authentication administrator", "authentication extensibility administrator", "authentication extensibility password administrator", "b2c ief keyset administrator", "cloud application administrator", "cloud device administrator", "conditional access administrator", "directory writers", "domain name administrator", "entra soc identity responder", "external identity provider administrator", "global administrator", "global reader", "helpdesk administrator", "hybrid identity administrator", "identity governance administrator", "intune administrator", "lifecycle workflows administrator", "partner tier1 support", "partner tier2 support", "password administrator", "privileged authentication administrator", "privileged role administrator", "security administrator", "security operator", "security reader", "tenant governance administrator", "user administrator", // not marked privileged by Microsoft, but with administrative control over major services "attribute assignment administrator", "authentication policy administrator", "cloud app security administrator", "compliance administrator", "directory synchronization accounts", "dynamics 365 administrator", "exchange administrator", "external id user flow administrator", "global secure access administrator", "groups administrator", "knowledge administrator", "microsoft 365 backup administrator", "microsoft 365 migration administrator", "on premises directory sync account", "power platform administrator", "sharepoint administrator", "skype for business administrator", "teams administrator", "teams telephony administrator", "windows 365 administrator", "yammer administrator", // additional roles: mailbox permissions, local administrator on joined devices (current and previous display // name), delegated partner access to the tenant, and approval of Microsoft support access to customer data "exchange recipient administrator", "azure ad joined device local administrator", "microsoft entra joined device local administrator", "customer delegated admin relationship administrator", "customer lockbox access approver", "entra customer lockbox approver", // legacy display name of Global Administrator "company administrator" ) | drop Esql.role_name_raw | keep @timestamp, Esql.*, azure.*, event.*, cloud.*, related.*, tags, source.*, agent.*, client.*, _id, _version, _index, data_stream.namespace

Install detection rules in Elastic Security

Detect Entra ID Application Self-Assigned to Privileged Role in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).