KQL detection & threat hunting queries
25 KQL queries for Microsoft Sentinel and Defender XDR, each explained line by line with the tables and columns it needs, its MITRE ATT&CK mapping, tuning notes and limitations. Filter by table, tactic or product, or browse the data-source hubs and ATT&CK tactic hubs. New to KQL? Start with the KQL for hunting primer.
25 queries
- mediumDeviceProcessEventsKQL for DeviceProcessEvents that detects certutil.exe used to download files from a URL, a living-off-the-land ingress-tool-transfer technique.Command and ControlT1105
- mediumDeviceProcessEventsKQL for DeviceProcessEvents that detects Base64-encoded PowerShell command lines run with -EncodedCommand, a frequent obfuscated-execution technique.ExecutionT1059.001
- highAuditLogsKQL for AuditLogs that detects user and admin consent granted to OAuth applications, the core signal for illicit consent-grant (OAuth phishing) attacks.Credential AccessT1528
- mediumIdentityQueryEventsKQL for IdentityQueryEvents that detects high-volume LDAP reconnaissance against Active Directory, the enumeration BloodHound and similar tools generate.DiscoveryT1087.002
- highDeviceLogonEventsKQL for DeviceLogonEvents that detects brute-force authentication: many failed logons followed by a success, from one source against a single device.Credential AccessT1110.001
- highDeviceProcessEventsKQL for DeviceProcessEvents that detects LSASS credential dumping with rundll32 and comsvcs.dll MiniDump, a common living-off-the-land dump technique.Credential AccessT1003.001
- highOfficeActivityKQL for OfficeActivity that detects new mailbox delegate and send-as permissions in Exchange Online, a persistence and collection technique in BEC.PersistenceT1098.002
- mediumCloudAppEventsKQL for CloudAppEvents that detects a user downloading an unusually large number of files from cloud apps in a short window — a data-exfiltration signal.ExfiltrationT1567
- highSigninLogsKQL for SigninLogs that detects MFA fatigue / push-bombing: repeated multi-factor challenges that the user never completes, from the same account and IP.Credential AccessT1621
- highAuditLogsKQL for AuditLogs that detects credentials or certificates added to Entra ID app registrations and service principals, a stealthy cloud persistence technique.PersistenceT1098.001
- highDeviceProcessEventsKQL for DeviceProcessEvents that detects Microsoft Office applications spawning script interpreters or LOLBins — a strong macro-malware and phishing signal.ExecutionT1204.002
- highSigninLogsKQL for SigninLogs that flags password spray: a single source IP failing to sign in across many Microsoft Entra ID accounts in a short window.Credential AccessT1110.003
- highAuditLogsKQL for AuditLogs that detects accounts being added to privileged Microsoft Entra ID directory roles — a common privilege-escalation and persistence step.Privilege EscalationT1098.003
- mediumDeviceNetworkEventsKQL for DeviceNetworkEvents that detects one host opening RDP to several internal systems in a short window — a strong lateral-movement indicator.Lateral MovementT1021.001
- mediumDeviceRegistryEventsKQL for DeviceRegistryEvents that detects writes to autostart Run, RunOnce and Winlogon registry keys, a classic Windows persistence technique.PersistenceT1547.001
- highUrlClickEventsKQL for UrlClickEvents that detects users clicking through Safe Links to URLs with a phishing or malware verdict — a high-value spearphishing-link signal.Initial AccessT1566.002
- mediumDeviceProcessEventsKQL for DeviceProcessEvents that detects scheduled tasks created or changed with schtasks.exe, a widely used persistence and execution technique.PersistenceT1053.005
- highDeviceProcessEventsKQL for DeviceProcessEvents that detects volume shadow copy deletion via vssadmin, wmic, wbadmin or PowerShell — a reliable pre-ransomware impact signal.ImpactT1490
- highOfficeActivityKQL for OfficeActivity that flags new or changed Exchange inbox rules that forward, redirect or delete mail — a hallmark of business email compromise.CollectionT1114.003
- highDeviceProcessEventsKQL for DeviceProcessEvents that detects Windows event logs being cleared with wevtutil or PowerShell, a defense-evasion and anti-forensics technique.Defense EvasionT1070.001
- mediumDeviceProcessEventsKQL for DeviceProcessEvents that detects new Windows services created with sc.exe or New-Service, used for persistence and SYSTEM-level execution.PersistenceT1543.003
- mediumDeviceProcessEventsKQL for DeviceProcessEvents that detects processes spawned via WMI — WmiPrvSE children and wmic process call create — a stealthy execution technique.ExecutionT1047
- highEmailEventsKQL for EmailEvents that finds phishing and malware emails that were delivered to the inbox or junk folder despite a threat verdict — post-delivery risk.Initial AccessT1566
- mediumSigninLogsKQL for SigninLogs that finds successful sign-ins over legacy protocols like IMAP, POP, SMTP and MAPI, which bypass modern MFA and conditional access.Initial AccessT1078.004
- mediumSigninLogsKQL for SigninLogs that surfaces users signing in successfully from two or more countries within the same hour — a lightweight impossible-travel heuristic.Initial AccessT1078.004