Detection: Azure AD Service Principal Privilege Escalation

Description

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

 1`azure_monitor_aad` category=AuditLogs operationName="Add app role assignment to service principal" properties.initiatedBy.app.displayName=* properties.result=Success 
 2| spath path=properties{}.targetResources{}.modifiedProperties{} output=targetResources 
 3| rename properties.* as * 
 4| eval user="NA" 
 5| eval src="NA" 
 6| 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 
 7| spath input=appRole path=newValue output=appRole 
 8| spath input=targetServicePrincipal path=newValue output=targetServicePrincipal 
 9| eval appRole=trim(replace(appRole, "\"", "")), targetServicePrincipal=trim(replace(targetServicePrincipal, "\"", "")) 
10| where servicePrincipal=targetServicePrincipal 
11| `security_content_ctime(firstTime)` 
12| `security_content_ctime(lastTime)` 
13| `azure_ad_service_principal_privilege_escalation_filter`

Data Source

Name Platform Sourcetype Source
Azure Active Directory Add app role assignment to service principal Azure icon Azure 'azure:monitor:aad' 'Azure AD'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
azure_ad_service_principal_privilege_escalation_filter search *
azure_ad_service_principal_privilege_escalation_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1098.003 Additional Cloud Roles Persistence
Exploitation
Installation
DE.CM
CIS 10

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Intermediate Finding (Risk Event) No
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

Implementation

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.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
Service Principal $servicePrincipal$ has elevated privileges by adding themself to app role $appRole$ servicePrincipal user 50

Threat Objects

Field Type
user_agent http_user_agent

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset Azure AD azure:monitor:aad
Integration ✅ Passing Dataset Azure AD azure:monitor:aad

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 10