Azure AD Graph Potential Enumeration (ROADrecon)

Detects a burst of Azure AD Graph (graph.windows.net) directory enumeration by a single identity, keyed on the internal API version that ROADrecon hardcodes (1.61-internal, with 1.6-internal as a related tooling value) plus a per-user request burst. ROADrecon's gather command walks the directory via this internal API version using aiohttp. This rule also detects the "evade" argument that routes every read through a single "/$batch" OData endpoint under a benign "Microsoft ADO.NET Data Services" user-agent. A lower burst threshold applies when a scripting user-agent (aiohttp/python/fasthttp) is present and a higher volume threshold applies otherwise.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/05/20"
  3integration = ["azure"]
  4maturity = "production"
  5updated_date = "2026/10/09"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects a burst of Azure AD Graph (graph.windows.net) directory enumeration by a single identity, keyed on the internal
 11API version that ROADrecon hardcodes (`1.61-internal`, with `1.6-internal` as a related tooling value) plus a per-user
 12request burst. ROADrecon's gather command walks the directory via this internal API version using aiohttp.
 13This rule also detects the "evade" argument that routes every read through a single "/$batch" OData endpoint under a benign
 14"Microsoft ADO.NET Data Services" user-agent. A lower burst threshold applies when a scripting user-agent (aiohttp/python/fasthttp)
 15is present and a higher volume threshold applies otherwise.
 16"""
 17false_positives = [
 18    """
 19    Legitimate first-party Microsoft components (for example the Azure Graph Client Library used by portal or Office
 20    experiences) occasionally call AAD Graph with the internal API version, but at single-digit to low-double-digit
 21    volume; the burst thresholds exclude them. Validate the calling `azure.aadgraphactivitylogs.properties.app_id` and
 22    user if a low-volume match appears.
 23    """,
 24    """
 25    Developer activity using aiohttp or python HTTP libraries against AAD Graph for prototyping. Rare in production
 26    tenants and typically low-volume.
 27    """,
 28    """
 29    Authorized red team activity exercising ROADrecon. Document the engagement window and add exceptions on the source
 30    IP or calling user.
 31    """,
 32]
 33from = "now-9m"
 34language = "esql"
 35license = "Elastic License v2"
 36name = "Azure AD Graph Potential Enumeration (ROADrecon)"
 37note = """## Triage and analysis
 38
 39### Investigating Azure AD Graph Potential Enumeration (ROADrecon)
 40
 41This is an ES|QL aggregation rule. Alert documents contain summarized fields per burst window: the calling identity, the tenant, and a one-minute bucket. The alert itself is the signal that something resembling ROADrecon's `gather` walk happened against AAD Graph; the actual investigation happens against the raw `logs-azure.aadgraphactivitylogs-*` events for the same identity and window.
 42
 43The rule anchors on the hardcoded internal API version and a per-user burst rather than the user-agent alone, so it catches all three `gather` transports:
 44
 45- Default: `aiohttp` user-agent across ~16 directory collections.
 46- `--evade`: a single `/$batch` OData endpoint under a `Microsoft ADO.NET Data Services` user-agent (defeats user-agent and distinct-endpoint based matching).
 47- `-ua <value>`: an arbitrary browser user-agent.
 48
 49### Possible investigation steps
 50
 51- Confirm the burst by filtering raw AAD Graph activity for the alerting user, tenant, and time window.
 52    - Filter `logs-azure.aadgraphactivitylogs-*` on the alerting user, tenant, and burst window.
 53    - A default `gather` walks ~16 collections (many distinct `url.path`); `--evade` concentrates volume on `/$batch` (high `request_count`, one path).
 54- Tool fingerprint: the internal API version is the primary anchor.
 55    - `api_version = 1.61-internal` (hardcoded in `gather.py`, returns internal-only fields like `strongAuthenticationDetail`). No first-party Microsoft component pins this at volume.
 56    - `user_agent.original` is a secondary tell: `aiohttp`/`python` (overt), `Microsoft ADO.NET Data Services` with `/$batch` (the `--evade` signature), or a browser string (`-ua`).
 57- Calling client + auth method: the typical device-code-flow ROADrecon entrypoint.
 58    - ROADrecon is usually pointed at the Azure CLI client (`04b07795-…`) via the `-c` flag.
 59    - Uses a public-client auth method (no client secret or certificate).
 60- HTTP shape distinguishes enumeration from operator follow-on.
 61    - `gather` reads only, so GETs dominate (the `--evade` `/$batch` requests are POSTs to the batch endpoint).
 62    - A 403/404 tail indicates the identity probing endpoints it lacks permission for.
 63    - PATCH / POST / DELETE against directory objects in the same burst means the operator did more than enumerate.
 64- Source posture: residential ISP, generic VPS, or anonymising-network egress raises triage priority.
 65- Pivot to sign-in logs (`logs-azure.signinlogs-*`) via the sign-in correlation ID on each AAD Graph event to land on the originating token-mint.
 66- Pivot to audit logs (`logs-azure.auditlogs-*`) for any directory writes by the same user near the burst that suggest persistence or modification activity.
 67- Confirm the activity is not attributable to authorized testing before treating as malicious.
 68    - Check for red team engagement, penetration test, or internal tooling validation.
 69    - Validate against the engagement window and the operator's known source range.
 70
 71### Response and remediation
 72
 73- Enumerate device registrations created by the user during or around the burst window.
 74    - `GET /v1.0/users/{id}/registeredDevices` and `GET /v1.0/users/{id}/ownedDevices`.
 75    - De-register anything not attributable to a known endpoint via `DELETE /v1.0/devices/{deviceObjectId}`.
 76    - Do this BEFORE session revocation: device-bound PRTs survive `revokeSignInSessions`.
 77- Revoke refresh tokens and active sessions for the calling user.
 78    - `POST /v1.0/users/{id}/revokeSignInSessions`.
 79- Temporarily disable the user if the alert is high-confidence or you need to halt further activity while investigation continues.
 80    - `PATCH /v1.0/users/{id}` with body `{"accountEnabled": false}`.
 81- Audit OAuth grants and app role assignments the user holds; revoke anything minted from a kit-egress or otherwise suspicious source.
 82    - `GET /v1.0/oauth2PermissionGrants?$filter=principalId eq '{id}'`, revoke via `DELETE /v1.0/oauth2PermissionGrants/{grantId}`.
 83    - `GET /v1.0/users/{id}/appRoleAssignments`, revoke via `DELETE /v1.0/servicePrincipals/{spId}/appRoleAssignedTo/{assignmentId}`.
 84- Reset the user's password and audit authentication methods added during the window.
 85    - `GET /v1.0/users/{id}/authentication/methods` to list.
 86    - Remove anything unexpected via the method-type-specific endpoint.
 87- Audit directory writes by the user near the burst and roll back unauthorized changes.
 88    - Query `logs-azure.auditlogs-*` for `Register device`, `Update user`, `User registered security info`, role assignment activity by the same user in the window.
 89- If the calling application has no legitimate AAD Graph dependency, block further use by that app.
 90    - `PATCH /beta/applications/{id}` with body `{"authenticationBehaviors": {"blockAzureADGraphAccess": true}}`.
 91    - This property lives on the Graph beta endpoint, not v1.0.
 92"""
 93references = [
 94    "https://github.com/dirkjanm/ROADtools",
 95    "https://github.com/dirkjanm/ROADtools/blob/master/roadrecon/roadtools/roadrecon/gather.py",
 96    "https://unit42.paloaltonetworks.com/roadtools-cloud-attacks/",
 97    "https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-overview",
 98]
 99risk_score = 73
100rule_id = "80aa6cca-b343-457b-877e-5877cd71a1f8"
101setup = """#### Azure AD Graph Activity Logs
102Requires Azure AD Graph Activity Logs ingested into `logs-azure.aadgraphactivitylogs-*` via the Elastic Azure integration. Enable the `AzureADGraphActivityLogs` diagnostic-settings category on Entra ID.
103"""
104severity = "high"
105tags = [
106    "Domain: Cloud",
107    "Data Source: Azure",
108    "Data Source: Azure AD Graph",
109    "Data Source: Azure AD Graph Activity Logs",
110    "Use Case: Threat Detection",
111    "Tactic: Discovery",
112    "Resources: Investigation Guide",
113    "Noise: Unknown",
114    "Performance: Fast",
115    "Rule Type: ES|QL",
116    "Platform: Entra ID",
117    "Domain: Identity",
118]
119timestamp_override = "event.ingested"
120type = "esql"
121
122query = '''
123from logs-azure.aadgraphactivitylogs-* metadata _id, _version, _index
124
125| where data_stream.dataset == "azure.aadgraphactivitylogs"
126  and azure.aadgraphactivitylogs.properties.api_version in ("1.61-internal", "1.6-internal")
127
128| eval Esql.ua_lower = to_lower(user_agent.original)
129| eval Esql.scripting_user_agent = Esql.ua_lower like "*aiohttp*" or Esql.ua_lower like "python*" or Esql.ua_lower like "*fasthttp*"
130| eval Esql.target_endpoint = case(
131    url.path like "*$batch*",                   "batch",
132    url.path like "*/eligibleRoleAssignments*", "eligibleRoleAssignments",
133    url.path like "*/roleAssignments*",         "roleAssignments",
134    url.path like "*/users*",                   "users",
135    url.path like "*/groups*",                  "groups",
136    url.path like "*/servicePrincipals*",       "servicePrincipals",
137    url.path like "*/applications*",            "applications",
138    url.path like "*/devices*",                 "devices",
139    url.path like "*/directoryRoles*",          "directoryRoles",
140    url.path like "*/roleDefinitions*",         "roleDefinitions",
141    url.path like "*/administrativeUnits*",     "administrativeUnits",
142    url.path like "*/contacts*",                "contacts",
143    url.path like "*/oauth2PermissionGrants*",  "oauth2PermissionGrants",
144    url.path like "*/authorizationPolicy*",     "authorizationPolicy",
145    url.path like "*/settings*",                "settings",
146    url.path like "*/policies*",                "policies",
147    url.path like "*/tenantDetails*",           "tenantDetails",
148    "other"
149  )
150
151| eval Esql.time_window = date_trunc(1 minutes, @timestamp)
152
153| stats
154    Esql.request_count             = count(*),
155    Esql.distinct_endpoints        = count_distinct(url.path),
156    Esql.collections               = values(Esql.target_endpoint),
157    Esql.scripting_user_agent_seen = max(case(Esql.scripting_user_agent, 1, 0)),
158    Esql.api_versions              = values(azure.aadgraphactivitylogs.properties.api_version),
159    Esql.app_ids                   = values(azure.aadgraphactivitylogs.properties.app_id),
160    Esql.user_agents               = values(user_agent.original),
161    Esql.http_methods              = values(http.request.method),
162    Esql.status_codes              = values(http.response.status_code),
163    Esql.source_ips                = values(source.ip),
164    Esql.source_asn_orgs           = values(source.`as`.organization.name),
165    Esql.source_countries          = values(source.geo.country_name),
166    Esql.actor_types               = values(azure.aadgraphactivitylogs.properties.actor_type),
167    Esql.client_auth_methods       = values(azure.aadgraphactivitylogs.properties.client_auth_method),
168    Esql.session_ids               = values(azure.aadgraphactivitylogs.properties.session_id),
169    Esql.sign_in_activity_ids      = values(azure.aadgraphactivitylogs.properties.sign_in_activity_id),
170    Esql.scopes                    = values(azure.aadgraphactivitylogs.properties.scopes),
171    Esql.first_seen                = min(@timestamp),
172    Esql.last_seen                 = max(@timestamp)
173  by
174    user.id,
175    azure.tenant_id,
176    Esql.time_window
177
178| eval Esql.enum_detected = case(
179    Esql.scripting_user_agent_seen == 1 and Esql.distinct_endpoints >= 5, true,
180    Esql.distinct_endpoints >= 15, true,
181    Esql.request_count >= 150, true,
182    false
183  )
184| where Esql.enum_detected == true
185
186| keep
187    user.id,
188    azure.tenant_id,
189    Esql.*
190'''
191
192[rule.alert_suppression]
193group_by = ["user.id", "azure.tenant_id"]
194missing_fields_strategy = "suppress"
195
196[rule.alert_suppression.duration]
197unit = "m"
198value = 5
199
200[[rule.threat]]
201framework = "MITRE ATT&CK"
202[[rule.threat.technique]]
203id = "T1069"
204name = "Permission Groups Discovery"
205reference = "https://attack.mitre.org/techniques/T1069/"
206[[rule.threat.technique.subtechnique]]
207id = "T1069.003"
208name = "Cloud Groups"
209reference = "https://attack.mitre.org/techniques/T1069/003/"
210
211
212[[rule.threat.technique]]
213id = "T1087"
214name = "Account Discovery"
215reference = "https://attack.mitre.org/techniques/T1087/"
216[[rule.threat.technique.subtechnique]]
217id = "T1087.004"
218name = "Cloud Account"
219reference = "https://attack.mitre.org/techniques/T1087/004/"
220
221
222[[rule.threat.technique]]
223id = "T1526"
224name = "Cloud Service Discovery"
225reference = "https://attack.mitre.org/techniques/T1526/"
226
227
228[rule.threat.tactic]
229id = "TA0007"
230name = "Discovery"
231reference = "https://attack.mitre.org/tactics/TA0007/"
232
233[rule.investigation_fields]
234field_names = ["user.id", "azure.tenant_id"]

Triage and analysis

Investigating Azure AD Graph Potential Enumeration (ROADrecon)

This is an ES|QL aggregation rule. Alert documents contain summarized fields per burst window: the calling identity, the tenant, and a one-minute bucket. The alert itself is the signal that something resembling ROADrecon's gather walk happened against AAD Graph; the actual investigation happens against the raw logs-azure.aadgraphactivitylogs-* events for the same identity and window.

The rule anchors on the hardcoded internal API version and a per-user burst rather than the user-agent alone, so it catches all three gather transports:

  • Default: aiohttp user-agent across ~16 directory collections.
  • --evade: a single /$batch OData endpoint under a Microsoft ADO.NET Data Services user-agent (defeats user-agent and distinct-endpoint based matching).
  • -ua <value>: an arbitrary browser user-agent.

Possible investigation steps

  • Confirm the burst by filtering raw AAD Graph activity for the alerting user, tenant, and time window.
    • Filter logs-azure.aadgraphactivitylogs-* on the alerting user, tenant, and burst window.
    • A default gather walks ~16 collections (many distinct url.path); --evade concentrates volume on /$batch (high request_count, one path).
  • Tool fingerprint: the internal API version is the primary anchor.
    • api_version = 1.61-internal (hardcoded in gather.py, returns internal-only fields like strongAuthenticationDetail). No first-party Microsoft component pins this at volume.
    • user_agent.original is a secondary tell: aiohttp/python (overt), Microsoft ADO.NET Data Services with /$batch (the --evade signature), or a browser string (-ua).
  • Calling client + auth method: the typical device-code-flow ROADrecon entrypoint.
    • ROADrecon is usually pointed at the Azure CLI client (04b07795-…) via the -c flag.
    • Uses a public-client auth method (no client secret or certificate).
  • HTTP shape distinguishes enumeration from operator follow-on.
    • gather reads only, so GETs dominate (the --evade /$batch requests are POSTs to the batch endpoint).
    • A 403/404 tail indicates the identity probing endpoints it lacks permission for.
    • PATCH / POST / DELETE against directory objects in the same burst means the operator did more than enumerate.
  • Source posture: residential ISP, generic VPS, or anonymising-network egress raises triage priority.
  • Pivot to sign-in logs (logs-azure.signinlogs-*) via the sign-in correlation ID on each AAD Graph event to land on the originating token-mint.
  • Pivot to audit logs (logs-azure.auditlogs-*) for any directory writes by the same user near the burst that suggest persistence or modification activity.
  • Confirm the activity is not attributable to authorized testing before treating as malicious.
    • Check for red team engagement, penetration test, or internal tooling validation.
    • Validate against the engagement window and the operator's known source range.

Response and remediation

  • Enumerate device registrations created by the user during or around the burst window.
    • GET /v1.0/users/{id}/registeredDevices and GET /v1.0/users/{id}/ownedDevices.
    • De-register anything not attributable to a known endpoint via DELETE /v1.0/devices/{deviceObjectId}.
    • Do this BEFORE session revocation: device-bound PRTs survive revokeSignInSessions.
  • Revoke refresh tokens and active sessions for the calling user.
    • POST /v1.0/users/{id}/revokeSignInSessions.
  • Temporarily disable the user if the alert is high-confidence or you need to halt further activity while investigation continues.
    • PATCH /v1.0/users/{id} with body {"accountEnabled": false}.
  • Audit OAuth grants and app role assignments the user holds; revoke anything minted from a kit-egress or otherwise suspicious source.
    • GET /v1.0/oauth2PermissionGrants?$filter=principalId eq '{id}', revoke via DELETE /v1.0/oauth2PermissionGrants/{grantId}.
    • GET /v1.0/users/{id}/appRoleAssignments, revoke via DELETE /v1.0/servicePrincipals/{spId}/appRoleAssignedTo/{assignmentId}.
  • Reset the user's password and audit authentication methods added during the window.
    • GET /v1.0/users/{id}/authentication/methods to list.
    • Remove anything unexpected via the method-type-specific endpoint.
  • Audit directory writes by the user near the burst and roll back unauthorized changes.
    • Query logs-azure.auditlogs-* for Register device, Update user, User registered security info, role assignment activity by the same user in the window.
  • If the calling application has no legitimate AAD Graph dependency, block further use by that app.
    • PATCH /beta/applications/{id} with body {"authenticationBehaviors": {"blockAzureADGraphAccess": true}}.
    • This property lives on the Graph beta endpoint, not v1.0.

References

Related rules

to-top