Sysmon Event ID 22: dns query
What Sysmon Event ID 22 (dns query) means, the fields to check, what is normal and what is suspicious, with PowerShell and KQL queries to find it.
Sysmon event ID 22 records a DNS query made by a process, with the process name and the answers. That process detail is what network DNS logs lack: it tells you that rundll32.exe, not the browser, looked up the suspicious domain.
The fields that matter
| Field | What it tells you |
|---|---|
| Image | The process that made the query. |
| QueryName | The domain looked up. |
| QueryResults | The returned addresses or CNAMEs. |
| QueryStatus | 0 for success; other values are DNS error codes. |
| ProcessGuid / ProcessId | Link to Sysmon event 1 for the process. |
What is normal
Browsers, Office, update agents and Windows services resolving their usual domains.
When Sysmon Event ID 22 is suspicious
- Queries from
powershell.exe,rundll32.exe,regsvr32.exe,mshta.exeor Office apps to new or unusual domains. - Many queries to long random-looking subdomains of one domain: DNS tunnelling or DGA.
- Queries for paste sites, file sharing or dynamic DNS domains from servers.
Common false positive: Telemetry from browsers and endpoint agents is very chatty. Most Sysmon configurations exclude well-known domains to keep volume down.
Find Sysmon Event ID 22 with PowerShell
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Sysmon/Operational'; Id=22; StartTime=(Get-Date).AddDays(-7)} -MaxEvents 50 |
ForEach-Object {
$d = [ordered]@{ Time = $_.TimeCreated; Computer = $_.MachineName }
([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]$d
} | Format-List
Microsoft Sentinel (KQL)
Event
| where TimeGenerated > ago(7d) and Source == "Microsoft-Windows-Sysmon" and EventID == 22
| project TimeGenerated, Computer, RenderedDescription, EventData
| order by TimeGenerated desc
Related events
- Sysmon Event ID 3: network connection
- Sysmon Event ID 1: process creation
- Event ID 5156: Windows Filtering Platform allowed a connection
FAQ
Does Sysmon 22 work on all Windows versions?
It needs Windows 8.1 / Server 2012 R2 or later and Sysmon 10 or later.
Windows Event Triage reads a CSV, EVTX-to-JSON or XML export in your browser and flags brute force, new admins, suspicious services and log clearing.
IOC Triage, our free browser extension: right-click it for a verdict from 15 threat-intel sources, then copy a ready ticket note.