Name:Azure AD Service Principal Privilege Escalation id:29eb39d3-2bc8-49cc-99b3-35593191a588 version:1 date:2025-01-06 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:
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 | stats min(_time) as _time 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 operationName tenantId correlationId | 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 | table _time operationName servicePrincipal servicePrincipalId appRole targetAppContext user_agent tenantId correlationId | `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:Unknown References: -https://splunkbase.splunk.com/app/3110 -https://docs.splunk.com/Documentation/AddOns/released/MSCloudServices/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 drilldown_searches: name:'View the detection results for - "$servicePrincipal$"' search:'%original_detection_search% | search servicePrincipal = "$servicePrincipal$"' earliest_offset:'$info_min_time$' latest_offset:'$info_max_time$' name:'View risk events for the last 7 days for - "$servicePrincipal$"' search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$servicePrincipal$") starthoursago=168 | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`' earliest_offset:'$info_min_time$' latest_offset:'$info_max_time$' tags: analytic_story: - 'Azure Active Directory Privilege Escalation' asset_type:Azure Tenant confidence:100 impact:100 message:Service Principal $servicePrincipal$ has elevated privileges by adding themself to app role $appRole$ mitre_attack_id: - 'T1098.003' - 'T1098' observable: name:'servicePrincipal' type:'User' - role: - 'Victim' name:'user_agent' type:'Other' - role: - 'Attacker' product: - 'Splunk Enterprise' - 'Splunk Enterprise Security' - 'Splunk Cloud' required_fields: - 'user_agent' - 'identity' - 'properties.initiatedBy.app.servicePrincipalId' - 'operationName' - 'tenantId' - 'correlationId' - 'category' - 'properties.initiatedBy.app.displayName' - 'properties.result' - 'properties{}.targetResources{}.modifiedProperties{}' - 'properties.targetResources{}.displayName' risk_score:100 security_domain:identity