Detection rules › Splunk

Azure AD Service Principal Privilege Escalation

Status
production
Severity
medium
Group by
aws::recipientAccountId, dest, signature, src, user, vendor_product
Author
Dean Luxton
Source
github.com/splunk/security_content

This detection identifies when an Azure Service Principal elevates privileges by adding themself to a new app role assignment.

Known false positives

  • No false positives have been identified at this time.

MITRE ATT&CK coverage

Telemetry coverage

Rules detecting the same action

These rules filter on the same operation.

Rule body

name: Azure AD Service Principal Privilege Escalation
id: 29eb39d3-2bc8-49cc-99b3-35593191a588
version: 10
creation_date: '2025-01-05'
modification_date: '2026-05-13'
author: Dean Luxton
status: production
type: TTP
description: This detection identifies when an Azure Service Principal elevates privileges by adding themself to a new app role assignment.
data_source:
    - Azure Active Directory Add app role assignment to service principal
search: >-
    `azure_monitor_aad` category=AuditLogs operationName="Add app role assignment to service principal" properties.initiatedBy.app.displayName=* properties.result=Success
    | spath path=properties{}.targetResources{}.modifiedProperties{} output=targetResources
    | rename properties.* as *
    | eval user="NA"
    | eval src="NA"
    | stats min(_time) as firstTime max(_time) as lastTime values(eval(mvfilter(match(targetResources, "AppRole.Value")))) as appRole, values(eval(mvfilter(match(targetResources, "ServicePrincipal.DisplayName")))) as targetServicePrincipal values(eval(mvindex('properties.targetResources{}.displayName',0))) as targetAppContext
    values(user_agent) as user_agent values(identity) as servicePrincipal values(properties.initiatedBy.app.servicePrincipalId) as servicePrincipalId by dest user src vendor_account vendor_product signature
    | spath input=appRole path=newValue output=appRole
    | spath input=targetServicePrincipal path=newValue output=targetServicePrincipal
    | eval appRole=trim(replace(appRole, "\"", "")), targetServicePrincipal=trim(replace(targetServicePrincipal, "\"", ""))
    | where servicePrincipal=targetServicePrincipal
    | `security_content_ctime(firstTime)`
    | `security_content_ctime(lastTime)`
    | `azure_ad_service_principal_privilege_escalation_filter`
how_to_implement: The Splunk Add-on for Microsoft Cloud Services add-on is required to ingest EntraID audit logs via Azure EventHub. See reference for links for further details on how to onboard this log source.
known_false_positives: No false positives have been identified at this time.
references:
    - https://splunkbase.splunk.com/app/3110
    - https://splunk.github.io/splunk-add-on-for-microsoft-cloud-services/Install/
    - https://github.com/mvelazc0/BadZure
    - https://www.splunk.com/en_us/blog/security/hunting-m365-invaders-navigating-the-shadows-of-midnight-blizzard.html
    - https://posts.specterops.io/microsoft-breach-what-happened-what-should-azure-admins-do-da2b7e674ebc
finding:
    title: Service Principal $servicePrincipal$ has elevated privileges by adding themself to app role $appRole$
    entity:
        field: servicePrincipal
        type: user
        score: 50
threat_objects:
    - field: user_agent
      type: http_user_agent
analytic_story:
    - Azure Active Directory Privilege Escalation
asset_type: Azure Tenant
mitre_attack_id:
    - T1098.003
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
category: cloud
security_domain: identity

Stages and Predicates

Stage 1: search

`azure_monitor_aad` category=AuditLogs operationName="Add app role assignment to service principal" properties.initiatedBy.app.displayName=* properties.result=Success

Stage 2: spath

| spath path=properties{}.targetResources{}.modifiedProperties{} output=targetResources

Stage 3: rename

| rename properties.* as *

Stage 4: eval

| eval user="NA"

Stage 5: eval

| eval src="NA"

Stage 6: stats

| stats min(_time) as firstTime max(_time) as lastTime values(eval(mvfilter(match(targetResources, "AppRole.Value")))) as appRole, values(eval(mvfilter(match(targetResources, "ServicePrincipal.DisplayName")))) as targetServicePrincipal values(eval(mvindex('properties.targetResources{}.displayName',0))) as targetAppContext values(user_agent) as user_agent values(identity) as servicePrincipal values(properties.initiatedBy.app.servicePrincipalId) as servicePrincipalId by dest user src vendor_account vendor_product signature

Stage 7: spath

| spath input=appRole path=newValue output=appRole

Stage 8: spath

| spath input=targetServicePrincipal path=newValue output=targetServicePrincipal

Stage 9: eval

| eval appRole=trim(replace(appRole, "\"", "")), targetServicePrincipal=trim(replace(targetServicePrincipal, "\"", ""))

Stage 10: where

| where servicePrincipal=targetServicePrincipal

Stage 11: search

| `security_content_ctime(firstTime)`

Stage 12: search

| `security_content_ctime(lastTime)`

Stage 13: search

| `azure_ad_service_principal_privilege_escalation_filter`

Indicators

These rows show field, operator, and value matches.