Detection rules › YARA-L
Entra ID application enumeration observed in the Microsoft Graph API
Identify the use GraphRunner's Invoke-DumpApps function to collect applications and external apps as well as users that consented to permissions in their apps.
References
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule ms_graph_enumerate_applications {
meta:
author = "Google Cloud Security"
description = "Identify the use GraphRunner's Invoke-DumpApps function to collect applications and external apps as well as users that consented to permissions in their apps."
rule_id = "mr_3715d986-b1a9-4bb2-b625-acc54cd5322d"
rule_name = "Entra ID application enumeration observed in the Microsoft Graph API"
assumption = "While additional API endpoints are called in the function, this rule is stripped down to the applications and servicePrincipals endpoint recursively requesting the appRole assigned to."
reference = "https://github.com/dafthack/GraphRunner/blob/main/GraphRunner.ps1"
type = "Alert"
data_source = "MS Graph Activity Logs"
platform = "Azure"
severity = "Low"
priority = "Low"
events:
$app_api.metadata.event_type = "NETWORK_HTTP"
$app_api.metadata.product_event_type = "Microsoft Graph Activity"
$app_api.target.url = "https://graph.microsoft.com/v1.0/applications" nocase
$app_api.network.http.method = "GET"
$app_api.network.http.response_code = 200
//Can be tuned for specific User Agent strings being used - by default GraphRunner does not forge the UA for this action
//$app_api.network.http.user_agent = /PowerShell/ nocase
$app_api.principal.ip = $ip
$app_api.network.session_id = $session
$app_api.metadata.event_timestamp.seconds < $role_api.metadata.event_timestamp.seconds
$role_api.metadata.event_type = "NETWORK_HTTP"
$role_api.metadata.product_event_type = "Microsoft Graph Activity"
re.regex($role_api.target.url, `^https:\/\/graph.microsoft.com\/v1.0\/servicePrincipals\(appId='.*'\)/appRoleAssignedTo$`) nocase
$role_api.network.http.method = "GET"
$role_api.network.http.response_code = 200
//Can be tuned for specific User Agent strings being used - by default GraphRunner does not forge the UA for this action
//$role_api.network.http.user_agent = /PowerShell/ nocase
$role_api.principal.ip = $ip
$role_api.network.session_id = $session
re.capture($role_api.target.url, `^https:\/\/graph.microsoft.com\/v1.0\/servicePrincipals\(appId='(.*)'\)/appRoleAssignedTo$`) = $app_guid
match:
$ip, $session over 5m
outcome:
$risk_score = 35
$event_count = count_distinct($app_api.metadata.id) + count_distinct($role_api.metadata.id)
$requesting_user_guid = array_distinct($app_api.principal.user.userid)
$requesting_ip = array_distinct($app_api.principal.ip)
$user_agent = array_distinct($app_api.network.http.user_agent)
$location = array_distinct($app_api.principal.location.name)
$target_application_id_guid = array_distinct($app_api.target.resource.product_object_id)
$session_id = array_distinct($app_api.network.session_id)
$application_count = count_distinct($app_guid)
$application_list = array_distinct($app_guid) //limited to 25 applications
condition:
$app_api and $role_api
}
YARA-L rule structure
Condition
Fires when at least one $app_api event in the 5m window and at least one $role_api event in the 5m window.
Events
$app_api
metadata.product_event_type = "Microsoft Graph Activity"target.url = "https://graph.microsoft.com/v1.0/applications"network.http.method = "GET"network.http.response_code = "200"
$role_api
metadata.product_event_type = "Microsoft Graph Activity"target.url matches "^https:\/\/graph.microsoft.com\/v1.0\/servicePrincipals\(appId='.*'\)/appRoleAssignedTo$"network.http.method = "GET"network.http.response_code = "200"
Match and correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 35 |
event_count | count_distinct($app_api.metadata.id) + count_distinct($role_api.metadata.id) |
requesting_user_guid | array_distinct($app_api.principal.user.userid) |
requesting_ip | array_distinct($app_api.principal.ip) |
user_agent | array_distinct($app_api.network.http.user_agent) |
location | array_distinct($app_api.principal.location.name) |
target_application_id_guid | array_distinct($app_api.target.resource.product_object_id) |
session_id | array_distinct($app_api.network.session_id) |
application_count | count_distinct($app_guid) |
application_list | array_distinct($app_guid) |