Detection: O365 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`o365_management_activity` Operation="Add app role assignment to service principal." "Actor{}.ID"=ServicePrincipal ResultStatus=Success 
2| spath path=ModifiedProperties{} output=targetResources 
3| stats min(_time) as _time values(eval(mvfilter(match(targetResources, "AppRole.Value")))) as appRole, values(eval(mvfilter(match(targetResources, "ServicePrincipal.DisplayName")))) as targetServicePrincipal values(object) as targetAppContext values(user_agent) as user_agent values(user) as servicePrincipal values(UserId) as servicePrincipalId  by Operation InterSystemsId tenant_id 
4| spath input=appRole path=NewValue output=appRole 
5| spath input=targetServicePrincipal path=NewValue output=targetServicePrincipal 
6| where servicePrincipal=targetServicePrincipal 
7| table _time Operation servicePrincipal servicePrincipalId appRole targetAppContext user_agent tenant_id InterSystemsId 
8| `o365_service_principal_privilege_escalation_filter`

Data Source

No data sources specified for this detection.

Macros Used

Name Value
o365_management_activity sourcetype=o365:management:activity
o365_service_principal_privilege_escalation_filter search *
o365_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
T1098 Account Manipulation Privilege Escalation
Exploitation
Installation
DE.CM
CIS 10
LAPSUS$
Scattered Spider
HAFNIUM
Lazarus Group

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 Notable Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Risk Event True
This configuration file applies to all detections of type TTP. These detections will use Risk Based Alerting and generate Notable Events.

Implementation

The Splunk Add-on for Microsoft Office 365 add-on is required to ingest EntraID audit logs via the 365 API. See references for links for further details on how to onboard this log source.

Known False Positives

Unknown

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message:

Service Principal $servicePrincipal$ has elevated privileges by adding themself to app role $appRole$

Risk Object Risk Object Type Risk Score Threat Objects
servicePrincipal user 100 user_agent

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset Office 365 o365:management:activity
Integration ✅ Passing Dataset Office 365 o365:management:activity

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: 1