Skip to content

Add hunting queries: Entra ID tenant policy changes hunting pack (3 queries) - #15517

Merged
v-atulyadav merged 2 commits into
Azure:masterfrom
descambiado:add-entra-tenant-policy-hunting-pack-v2
Nov 2, 2026
Merged

v-atulyadav merged 2 commits into
Azure:masterfrom
descambiado:add-entra-tenant-policy-hunting-pack-v2

Conversation

@descambiado

Copy link
Copy Markdown
Contributor

Continuation of #15321

This PR replaces #15321. The review there is finished (Copilot's three points and the last one from v-skharode are applied), but its license/cla status never registered after I force-pushed to replace the author email with my GitHub noreply address, and it has stayed pending for two weeks even after the agree comment. This branch is a single commit on top of current master with the same three files, byte for byte, as the last commit of #15321 (d2a772835d). My two previous PRs opened this way (#15434 and #15444) registered the CLA normally. I will close #15321 once this one is open.

Review points already applied in those files:

  1. The guest suffix #EXT# is matched without regard to case.
  2. Applications are keyed by service principal id instead of display name, and an event with neither a user nor an application is only grouped with itself.
  3. An empty list is only labelled "First recorded value" when it really means "no previous value"; for PermissionGrantPolicyIds an empty list is a real value.
  4. The fallback actor key uses the activity's unique Id instead of CorrelationId, which can be empty or shared across activities.

Summary

Three hunting queries for changes to tenant-wide Entra ID policies. A change to one of these policies weakens every account in the tenant at once, and user-level detections (MFA registration, Temporary Access Pass creation, app registration) never see it. I searched the repository on 14 October for the three operations (Authentication Methods Policy Update, Update authorization policy, Set device registration policies) and found none in AuditLogs; the only match is a CloudAppEvents hunting query for Update authorization policy.

Change(s):

  • Adds AuthenticationMethodsPolicyChanged, TenantAuthorizationPolicyChanged and DeviceRegistrationPolicyChanged under Hunting Queries/AuditLogs.

Reason for Change(s):

  • Fills the gap above for the authentication methods policy, the default user permissions and the device registration policy.

Version Updated:

  • Not applicable, new hunting queries (version 1.0.0).

AuthenticationMethodsPolicyChanged (AuditLogs)

One row per changed setting of the authentication methods policy: method, setting, whether a method was enabled or disabled, and the old and new value. The entry that holds the values is not the first TargetResources entry, so every entry is expanded instead of reading a fixed index.

MITRE: T1556.006, T1098

TenantAuthorizationPolicyChanged (AuditLogs)

One row per changed setting of the authorization policy (what ordinary users may do by default: create apps, groups or tenants, invite guests, consent to applications). It marks sensitive settings, separates a first recorded value from a change, and for list values shows which items were added or removed. Saving the user settings page in the portal added two Teams and chat permission grant policies by itself, so the added items matter.

MITRE: T1098, T1528

DeviceRegistrationPolicyChanged (AuditLogs)

Who changed the device registration policy and when, plus how many other tenant policy changes the same person made in the same hour. This event carries no old or new value, and the description says so. The account is normalized before comparing, because the same external account is written in two forms by different services.

MITRE: T1098.005

Testing Completed

  • Operation names and the shape of modifiedProperties come from real events captured by changing each of the three policies in my own Entra ID tenant (25 events, read through Microsoft Graph).
  • I ran the three queries against those 25 events and 12 synthetic edge cases (failed save, unrelated operation, null targets, values in the second TargetResources entry, nested setting names, application actors, a consent policy change to the legacy policy, mixed case account names, bursts across two hours) as an inline datatable in Log Analytics. Each returned the expected rows. After the review changes I also compared the old and new versions of each query on the same data, plus synthetic cases for the guest suffix in lower case, two applications with the same display name, and two unidentified events with an empty or shared CorrelationId.
  • I have not run them on a workspace fed by the Entra ID connector, because my lab workspace stopped receiving data. The fields used (InitiatedBy, TargetResources, modifiedProperties with displayName, oldValue and newValue as JSON encoded strings) have the same structure in Graph and in the one AuditLogs record that workspace did ingest, which I compared.
  • The three queries also compile and execute unchanged on the real AuditLogs table in Log Analytics (Microsoft's public demo workspace and my own workspace; both tables are empty, so this checks the schema and the query engine, not the results), and an invented column fails there with SEM0100.
  • Limits: one tenant and one user; setting names that were not observed come from the Graph documentation; the device registration event has no values.

Validation

  • Kqlvalidations.Tests passes locally for the three files (6 of 6).
  • Descriptions under 255 characters, names under 100, no non-ASCII characters, GUIDs unique in the repository.
  • MITRE techniques and tactics checked against the ATT&CK site; the repository schema accepts DefenseEvasion, which ATT&CK now calls Defense Impairment for T1556.006.
  • Reference links checked (HTTP 200).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the three new tenant-wide policy-change hunting queries.

No open issues 🎉

What changed in this PR

Adds three AuditLogs hunting queries for tenant-wide Microsoft Entra ID policy changes, complementing existing user-level detections. This continues #15321 with the previously reviewed fixes preserved.

Changes:

  • Reports authentication-method setting changes with old/new values and enabled/disabled labels.
  • Highlights sensitive authorization-policy settings, distinguishes first recorded values, and shows list additions/removals.
  • Correlates device-registration policy changes with the same actor’s tenant-policy activity in fixed hourly buckets.
File Description
Hunting Queries/​AuditLogs/​TenantAuthorizationPolicyChanged.yaml Adds per-setting authorization-policy hunting with sensitivity flags and list differences.
Hunting Queries/​AuditLogs/​DeviceRegistrationPolicyChanged.yaml Adds device-registration policy hunting with hourly actor correlation.
Hunting Queries/​AuditLogs/​AuthenticationMethodsPolicyChanged.yaml Adds per-setting authentication-method policy hunting with state-change labels.

Review effort: Balanced

@v-skharode

Copy link
Copy Markdown
Contributor

Hey Descambiado (@descambiado)
Thanks, the three queries and test evidence look strong.
One mismatch remains in DeviceRegistrationPolicyChanged: PolicyChangesInHour = count() includes the current device-registration event, but the description says it counts other policy changes. Please count only the other operations or rename the field and description to clarify that it includes the current event.
Also confirm the remaining check passes on the latest commit; then I can approve.

@descambiado

Copy link
Copy Markdown
Contributor Author

Thanks for the review v-skharode. I took the first option. PolicyChangesInHour in DeviceRegistrationPolicyChanged now uses countif(OperationName !~ "Set device registration policies"), so it counts only the changes to the other two policies (authentication methods policy and default user permissions) and no longer includes the device registration event on the row. The detailed description now says so explicitly. This also makes the count match the existing OtherPolicyOperationsInHour column. The version stays 1.0.0 because the query has not been published yet.

Kqlvalidations.Tests passes locally for the three files (6 of 6) on the new commit. I changed one expression and did not re-run the datatable cases in Log Analytics.

@v-atulyadav
v-atulyadav merged commit 86d81e2 into Azure:master Nov 2, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hunting Hunting specialty review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants