Detection rules › Splunk

Azure AD Privileged Role Assigned to Service Principal

Status
production
Severity
medium
Group by
aws::recipientAccountId, dest, displayName, initiatedBy, result, role, signature, src, user, vendor_product
Author
Mauricio Velazco, Splunk
Source
github.com/splunk/security_content

The following analytic detects the assignment of privileged roles to service principals in Azure Active Directory (AD). It leverages the AuditLogs log category from ingested Azure AD events. This activity is significant because assigning elevated permissions to non-human entities can lead to unauthorized access or malicious activities. If confirmed malicious, attackers could exploit these service principals to gain elevated access to Azure resources, potentially compromising sensitive data and critical infrastructure. Monitoring this behavior helps prevent privilege escalation and ensures the security of Azure environments.

MITRE ATT&CK coverage

Rule body splunk

name: Azure AD Privileged Role Assigned to Service Principal
id: 5dfaa3d3-e2e4-4053-8252-16d9ee528c41
version: 14
creation_date: '2023-04-28'
modification_date: '2026-05-13'
author: Mauricio Velazco, Splunk
status: production
type: TTP
description: The following analytic detects the assignment of privileged roles to service principals in Azure Active Directory (AD). It leverages the AuditLogs log category from ingested Azure AD events. This activity is significant because assigning elevated permissions to non-human entities can lead to unauthorized access or malicious activities. If confirmed malicious, attackers could exploit these service principals to gain elevated access to Azure resources, potentially compromising sensitive data and critical infrastructure. Monitoring this behavior helps prevent privilege escalation and ensures the security of Azure environments.
data_source:
    - Azure Active Directory Add member to role
search: |-
    `azure_monitor_aad` operationName="Add member to role"
      | rename properties.* as *
      | search "targetResources{}.type"=ServicePrincipal
      | rename initiatedBy.user.userPrincipalName as initiatedBy
      | rename targetResources{}.modifiedProperties{}.newValue as roles
      | eval role=mvindex(roles,1)
      | rename targetResources{}.displayName as apps
      | eval displayName=mvindex(apps,0)
      | fillnull
      | stats count min(_time) as firstTime max(_time) as lastTime
        BY dest user src
           vendor_account vendor_product displayName
           initiatedBy result role
           signature
      | lookup privileged_azure_ad_roles azureadrole AS role OUTPUT isprvilegedadrole description
      | search isprvilegedadrole = True
      | `security_content_ctime(firstTime)`
      | `security_content_ctime(lastTime)`
      | `azure_ad_privileged_role_assigned_to_service_principal_filter`
how_to_implement: You must install the latest version of Splunk Add-on for Microsoft Cloud Services from Splunkbase (https://splunkbase.splunk.com/app/3110/#/details). You must be ingesting Azure Active Directory events into your Splunk environment. This analytic was written to be used with the azure:monitor:aad sourcetype leveraging the AuditLog log category.
known_false_positives: Administrators may legitimately assign the privileged roles to Service Principals as part of administrative tasks. Filter as needed.
references:
    - https://posts.specterops.io/azure-privilege-escalation-via-service-principal-abuse-210ae2be2a5
drilldown_searches:
    - name: View the detection results for - "$initiatedBy$"
      search: '%original_detection_search% | search  initiatedBy = "$initiatedBy$"'
      earliest_offset: $info_min_time$
      latest_offset: $info_max_time$
    - name: View risk events for the last 7 days for - "$initiatedBy$"
      search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$initiatedBy$") | 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: 7d
      latest_offset: "0"
finding:
    title: A privileged Azure AD role was assigned to the Service Principal $displayName$ initiated by $initiatedBy$
    entity:
        field: initiatedBy
        type: user
        score: 50
analytic_story:
    - Azure Active Directory Privilege Escalation
    - NOBELIUM Group
    - Scattered Lapsus$ Hunters
asset_type: Azure Active Directory
mitre_attack_id:
    - T1098.003
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
category: cloud
security_domain: identity
tests:
    - name: True Positive Test
      attack_data:
        - data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1098.003/azure_ad_privileged_role_serviceprincipal/azure-audit.log
          source: Azure AD
          sourcetype: azure:monitor:aad
      test_type: unit

Stages and Predicates

Stage 1: search

`azure_monitor_aad` operationName="Add member to role"

Stage 2: rename

| rename properties.* as *

Stage 3: search

| search "targetResources{}.type"=ServicePrincipal

Stage 4: rename

| rename initiatedBy.user.userPrincipalName as initiatedBy

Stage 5: rename

| rename targetResources{}.modifiedProperties{}.newValue as roles

Stage 6: eval

| eval role=mvindex(roles,1)

Stage 7: rename

| rename targetResources{}.displayName as apps

Stage 8: eval

| eval displayName=mvindex(apps,0)

Stage 9: fillnull

| fillnull

Stage 10: stats

| stats count min(_time) as firstTime max(_time) as lastTime
    BY dest user src
       vendor_account vendor_product displayName
       initiatedBy result role
       signature

Stage 11: lookup

| lookup privileged_azure_ad_roles azureadrole AS role OUTPUT isprvilegedadrole description
Lookup table
privileged_azure_ad_roles
Key field
azureadrole as role
Output columns
['isprvilegedadrole', 'isprvilegedadrole'], ['description', 'description']

Stage 12: search

| search isprvilegedadrole = True

Stage 13: search

| `security_content_ctime(firstTime)`

Stage 14: search

| `security_content_ctime(lastTime)`

Stage 15: search

| `azure_ad_privileged_role_assigned_to_service_principal_filter`

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
"targetResources{}.type"eq
  • ServicePrincipal
isprvilegedadroleeq
  • True
operationNameeq
  • "Add member to role"
sourcetypeeq
  • azure:monitor:aad