Skip to content

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

  • mediumDeviceProcessEvents
    KQL 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
  • mediumDeviceProcessEvents
    KQL for DeviceProcessEvents that detects Base64-encoded PowerShell command lines run with -EncodedCommand, a frequent obfuscated-execution technique.
    ExecutionT1059.001
  • highAuditLogs
    KQL for AuditLogs that detects user and admin consent granted to OAuth applications, the core signal for illicit consent-grant (OAuth phishing) attacks.
    Credential AccessT1528
  • mediumIdentityQueryEvents
    KQL for IdentityQueryEvents that detects high-volume LDAP reconnaissance against Active Directory, the enumeration BloodHound and similar tools generate.
    DiscoveryT1087.002
  • highDeviceLogonEvents
    KQL for DeviceLogonEvents that detects brute-force authentication: many failed logons followed by a success, from one source against a single device.
    Credential AccessT1110.001
  • highDeviceProcessEvents
    KQL for DeviceProcessEvents that detects LSASS credential dumping with rundll32 and comsvcs.dll MiniDump, a common living-off-the-land dump technique.
    Credential AccessT1003.001
  • highOfficeActivity
    KQL for OfficeActivity that detects new mailbox delegate and send-as permissions in Exchange Online, a persistence and collection technique in BEC.
    PersistenceT1098.002
  • mediumCloudAppEvents
    KQL 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
  • highSigninLogs
    KQL 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
  • highAuditLogs
    KQL for AuditLogs that detects credentials or certificates added to Entra ID app registrations and service principals, a stealthy cloud persistence technique.
    PersistenceT1098.001
  • highDeviceProcessEvents
    KQL for DeviceProcessEvents that detects Microsoft Office applications spawning script interpreters or LOLBins — a strong macro-malware and phishing signal.
    ExecutionT1204.002
  • highSigninLogs
    KQL 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
  • highAuditLogs
    KQL for AuditLogs that detects accounts being added to privileged Microsoft Entra ID directory roles — a common privilege-escalation and persistence step.
    Privilege EscalationT1098.003
  • mediumDeviceNetworkEvents
    KQL for DeviceNetworkEvents that detects one host opening RDP to several internal systems in a short window — a strong lateral-movement indicator.
    Lateral MovementT1021.001
  • mediumDeviceRegistryEvents
    KQL for DeviceRegistryEvents that detects writes to autostart Run, RunOnce and Winlogon registry keys, a classic Windows persistence technique.
    PersistenceT1547.001
  • highUrlClickEvents
    KQL 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
  • mediumDeviceProcessEvents
    KQL for DeviceProcessEvents that detects scheduled tasks created or changed with schtasks.exe, a widely used persistence and execution technique.
    PersistenceT1053.005
  • highDeviceProcessEvents
    KQL for DeviceProcessEvents that detects volume shadow copy deletion via vssadmin, wmic, wbadmin or PowerShell — a reliable pre-ransomware impact signal.
    ImpactT1490
  • highOfficeActivity
    KQL for OfficeActivity that flags new or changed Exchange inbox rules that forward, redirect or delete mail — a hallmark of business email compromise.
    CollectionT1114.003
  • highDeviceProcessEvents
    KQL for DeviceProcessEvents that detects Windows event logs being cleared with wevtutil or PowerShell, a defense-evasion and anti-forensics technique.
    Defense EvasionT1070.001
  • mediumDeviceProcessEvents
    KQL for DeviceProcessEvents that detects new Windows services created with sc.exe or New-Service, used for persistence and SYSTEM-level execution.
    PersistenceT1543.003
  • mediumDeviceProcessEvents
    KQL for DeviceProcessEvents that detects processes spawned via WMI — WmiPrvSE children and wmic process call create — a stealthy execution technique.
    ExecutionT1047
  • highEmailEvents
    KQL 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
  • mediumSigninLogs
    KQL 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
  • mediumSigninLogs
    KQL 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