Query Details
// Hunt : Workload Identity - SP Conditional Access Bypass History (30d)
// Tactics : InitialAccess, DefenseEvasion
// MITRE : T1078.004, T1562
// Purpose : Full 30-day timeline of SPs with ConditionalAccessStatus = notApplied or failure.
// Surfaces SPs repeatedly bypassing CA policies. Correlate with RULE-04 to understand
// which bypasses led to downstream cloud app activity.
//==========================================================================================
let PrivateRanges = dynamic(["10.", "192.168.", "172.16.", "127.", "169.254.", "168.63."]);
(AADServicePrincipalSignInLogs | invoke ExcludeAllowlistedIPs())
| where TimeGenerated > ago(30d)
| where ResultType == "0"
| where ConditionalAccessStatus in ("notApplied", "failure")
| where isnotempty(IPAddress)
| where not(IPAddress has_any (PrivateRanges))
| extend GeoInfo = geo_info_from_ip_address(IPAddress)
| extend Country = tostring(GeoInfo.country_iso_code)
| extend CAPolicies = tostring(ConditionalAccessPolicies)
| summarize
BypassCount = count(),
UniqueIPs = dcount(IPAddress),
UniqueCountries = dcount(Country),
Countries = make_set(Country, 10),
IPList = make_set(IPAddress, 20),
PolicyStatuses = make_set(ConditionalAccessStatus, 3),
Resources = make_set(ResourceDisplayName, 10),
FirstBypass = min(TimeGenerated),
LastBypass = max(TimeGenerated)
by ServicePrincipalName, ServicePrincipalId, AppId
| where BypassCount > 10
| order by BypassCount desc
This query is designed to identify and analyze service principals (SPs) that have bypassed conditional access policies over the past 30 days. Here's a simplified breakdown of what the query does:
Data Source: It starts by examining Azure Active Directory service principal sign-in logs.
Time Frame: It focuses on logs from the last 30 days.
Filter Criteria:
ResultType == "0").ConditionalAccessStatus in ("notApplied", "failure")).Geolocation: It retrieves geographical information based on the IP addresses involved in the sign-ins.
Data Aggregation:
BypassCount).Significant Bypasses: It filters the results to only include service principals that bypassed policies more than 10 times.
Output: The results are sorted by the number of bypasses in descending order, highlighting the most frequently bypassed service principals.
The purpose of this query is to surface service principals that might be repeatedly bypassing conditional access policies, potentially indicating security risks or policy misconfigurations.

David Alonso
Released: April 21, 2026
Tables
Keywords
Operators