Detecting WMI event subscription persistence with Sysmon Events 19 to 21 gives you a repeatable way to spot permanent WMI subscriptions, see how they were created, and decide whether they are expected administration or suspicious persistence. By the end, you will know which telemetry to enable, how to query it, and how to validate the result at your desk.
You will need Sysmon deployed on the endpoints you want to monitor, a SIEM or hunting workspace that receives Windows event data, and enough access to change the Sysmon configuration. If you already use Microsoft Sentinel or Microsoft Defender XDR, you can apply the hunt directly. If you are still shaping your logging approach, the broader context in detecting malicious activity using Sysmon and Windows Event Logs is useful before you tune this specific detection.
WMI event subscription persistence matters because it is a durable mechanism. A filter, consumer and binding can survive reboots and keep triggering on a condition you may not notice from process telemetry alone. MITRE ATT&CK tracks this technique as Event Triggered Execution, which is a useful way to frame the hunt and to map it into your detection coverage. For a broader view of how this fits into endpoint telemetry, the article on tuning Sysmon configuration for high-fidelity process telemetry is a good companion piece.
Key takeaways
- Use Sysmon Event IDs 19, 20 and 21 together, because the filter, consumer and binding events only make sense as a chain.
- Build the hunt around concrete artefacts such as namespace, filter name, consumer type, query text and host context.
- Treat approved management tooling as the main source of false positives, then tune allow lists by host group and exact pattern.
- Verify the full path from endpoint to SIEM before you trust the alert, because parsing and ingestion issues are common failure points.
Confirm the telemetry you need before you start
Before changing anything, confirm that your endpoints are generating the right Windows telemetry and that your SIEM can receive it. Sysmon Event ID 19 records WMI event filter activity, Event ID 20 records WMI event consumer activity, and Event ID 21 records WMI event filter to consumer binding activity. You need all three to understand the full persistence chain. One event on its own is useful, but the combination is what gives you confidence.
Check that your Sysmon deployment is consistent across the estate. If only a subset of devices has the right configuration, your hunt will be patchy and your alerting will be harder to trust. In practice, this means verifying the Sysmon service is installed, the configuration file is current, and the event channel is being forwarded or ingested into your platform with the host name, user context and timestamp intact.
If you are using Microsoft Sentinel, confirm that the data lands in a table you can query. When Sysmon is collected as a Windows event log, its records arrive in the Event table with the Source value Microsoft-Windows-Sysmon. Microsoft Defender XDR does not ingest Sysmon, but Defender for Endpoint records the binding of a filter to a consumer in its own DeviceEvents table, which gives you a second, independent source. The exact table name depends on your ingestion path, so the important point is whether you can query Event IDs 19, 20 and 21 reliably.
Enable the Sysmon event IDs that expose WMI subscriptions
Sysmon does not help if the relevant event IDs are disabled. Update the configuration so that Event IDs 19, 20 and 21 are included in your logging policy. If you already run a curated Sysmon configuration, add these rules rather than replacing the whole file. That keeps your existing process, network and file telemetry intact.
The exact configuration pattern depends on your current Sysmon baseline, but the goal is simple, include WMI event filter, consumer and binding logging. If you maintain configuration as code, commit the change, review it, and roll it out in a controlled way. If you manage endpoints through Group Policy, Intune or another software distribution tool, stage the update to a pilot group first so you can confirm the volume and quality of the new events.
The snippet below shows the rule to add. In a Sysmon configuration one rule element, WmiEvent, covers Event IDs 19, 20 and 21. An exclude rule with nothing inside it means log every event of that type, which is what you want here because WMI subscriptions are rare on most endpoints.
<Sysmon schemaversion="4.90">
<EventFiltering>
<!-- Event IDs 19, 20 and 21: log every WMI filter, consumer and binding -->
<WmiEvent onmatch="exclude" />
</EventFiltering>
</Sysmon>
This rule switches on the three WMI events that Sysmon uses for persistence hunting. Use the schema version that matches the Sysmon release you run, and merge the rule into your existing EventFiltering section. If your configuration is accepted by Sysmon and the service restarts cleanly, you should begin to see the corresponding Event IDs in your logs after the next relevant WMI activity occurs.
After deployment, confirm the change on a test endpoint with a simple service check and a log check. On Windows, you can verify the Sysmon service and recent events with PowerShell and Event Viewer. The exact commands below are safe to run on a managed endpoint and they confirm whether the service is active and whether the channel is producing the expected event IDs.
Get-Service -Name Sysmon*
Get-WinEvent -FilterHashtable @{ LogName = 'Microsoft-Windows-Sysmon/Operational'; Id = 19, 20, 21 } -MaxEvents 20 |
Select-Object TimeCreated, Id, Message
If the service is running and the query returns recent WMI-related events, your collection path is ready for hunting. If it reports that no events were found, check the Sysmon configuration, the service status, and whether your test host has actually generated WMI subscription activity.
Collect and normalise the event data in your SIEM
Once Sysmon is producing the right events, make sure your SIEM preserves the fields you need for triage. For this use case, the most important values are the host name, the event ID, the WMI namespace, the filter name, the consumer type, the consumer name, the query text and the user or process context. Without those fields, you can still detect activity, but you will struggle to explain it.
Normalisation matters because WMI telemetry is only useful if you can search it consistently. If your platform flattens the raw XML into individual columns, map them into a stable schema and document the field names. If it keeps the event as raw XML, create parsing logic before you build the detection. This is a good place to align with your general logging design, especially if you already use a central pipeline for endpoint telemetry and want to avoid one-off parsing logic in each rule.
At this stage, also decide how long you retain the events. WMI subscriptions are persistent by design, so a short retention window can hide the creation event even when the subscription is still active. If you can only keep a limited amount of data hot, make sure you can still search historical logs for the same host and user when an alert fires.
Hunt for suspicious WMI event filters, consumers and bindings
The hunt works best when you treat the three Sysmon events as a chain rather than isolated alerts. Event ID 19 tells you a filter was created or modified, Event ID 20 tells you a consumer exists, and Event ID 21 tells you the filter and consumer were bound together. A suspicious result often shows up as a new filter with a broad or unusual query, a consumer that launches a script or command, and a binding that connects the two on a workstation that should not normally host such automation.
Use MITRE ATT&CK as a guide for what to look for, but keep your triage grounded in the actual artefacts. A legitimate management tool may create WMI subscriptions, especially in environments with endpoint management, inventory, or monitoring software. The question is whether the namespace, query, consumer type and host role match what you expect. If they do not, investigate further rather than assuming the event is malicious.
The KQL query below is a starting point for Microsoft Sentinel when Sysmon is collected into the Event table. It selects Event IDs 19, 20 and 21, extracts the most useful fields from the event text, and returns a compact view for triage. If your environment stores Sysmon data in a different table, change the table and the source filter, and keep the event IDs and field names the same.
Event
| where TimeGenerated > ago(7d)
| where Source == "Microsoft-Windows-Sysmon" and EventID in (19, 20, 21)
| extend Operation = extract(@"Operation: ([^rn]+)", 1, RenderedDescription),
WmiUser = extract(@"User: ([^rn]+)", 1, RenderedDescription),
WmiNamespace = extract(@"EventNamespace: ([^rn]+)", 1, RenderedDescription),
FilterQuery = extract(@"Query: ([^rn]+)", 1, RenderedDescription),
ConsumerType = extract(@"bType: ([^rn]+)", 1, RenderedDescription),
Destination = extract(@"Destination: ([^rn]+)", 1, RenderedDescription),
BoundConsumer = extract(@"bConsumer: ([^rn]+)", 1, RenderedDescription),
BoundFilter = extract(@"bFilter: ([^rn]+)", 1, RenderedDescription)
| project TimeGenerated, Computer, EventID, Operation, WmiUser, WmiNamespace, FilterQuery,
ConsumerType, Destination, BoundConsumer, BoundFilter
| order by TimeGenerated desc
This query returns the event ID alongside the WMI artefacts you need for triage. A useful result means you can see the filter, consumer and query text in one place, rather than jumping between raw event records. If your platform stores the fields differently, adjust the extraction patterns to match the message format you actually ingest.
If you run Microsoft Defender for Endpoint, the query below finds the same activity without Sysmon. Defender records each binding of a filter to a consumer, with the namespace and the consumer in AdditionalFields. Use it to cross-check hosts where Sysmon is missing or out of date.
DeviceEvents
| where Timestamp > ago(30d)
| where ActionType == "WmiBindEventFilterToConsumer"
| project Timestamp, DeviceName, InitiatingProcessAccountName, InitiatingProcessFileName,
InitiatingProcessCommandLine, AdditionalFields
| order by Timestamp desc
When you review the output, treat a few patterns as higher priority. A consumer that launches PowerShell, WScript, CScript, rundll32 or mshta deserves attention, especially if the command line points to a user profile, temp directory or encoded content. A filter with a broad query that triggers on common system events may be legitimate in a management tool, but it is worth checking whether that tool is approved on the host. If you want a broader process context for those consumer types, the article on detecting living-off-the-land binaries with Sysmon process events helps you interpret the downstream execution.
Decision making is easier if you separate expected from unexpected. Expected activity usually comes from known endpoint management, software deployment or monitoring tooling, runs under a service account, and appears on a small set of designated hosts. Unexpected activity often appears on user workstations, uses an unfamiliar namespace, references a script or executable path in a writable location, or creates a consumer that does not match your standard tooling. If you see a binding without a clear business reason, treat it as an investigation item.
Triage the alert and validate whether the subscription is malicious
When the hunt produces a candidate, validate it in a structured way. Start with the host role, then the account, then the surrounding process and logon context. If the host is a server that normally runs management tooling, check whether the filter or consumer matches that tooling. If the host is a user workstation, ask whether there is a documented reason for a persistent WMI subscription at all.
On the host itself, list what is registered. These three commands read the permanent subscriptions in the root/subscription namespace and change nothing. A filter and consumer named SCM Event Log are present on a standard Windows installation and are not a finding.
Get-CimInstance -Namespace root/subscription -ClassName __EventFilter |
Select-Object Name, Query
Get-CimInstance -Namespace root/subscription -ClassName __EventConsumer |
Select-Object Name, CommandLineTemplate, ScriptText
Get-CimInstance -Namespace root/subscription -ClassName __FilterToConsumerBinding |
Select-Object Filter, Consumer
Next, inspect the consumer type and the command or script path. WMI persistence often becomes interesting when the consumer points to a script interpreter or a command shell with arguments that are hard to justify. Look for paths under AppData, ProgramData, Temp or a user profile, and check whether the file exists, who owns it, and when it was created. If the consumer launches a legitimate binary, verify the parent process and whether the command line is consistent with your environment.
Then correlate the event with adjacent telemetry. Process creation, network connections, scheduled tasks and logon events can help you decide whether the WMI subscription is part of a wider chain. If the same host also shows unusual PowerShell activity, suspicious service creation or remote administration from an unexpected source, the case becomes stronger. If you need a model for building that wider context, the article on scheduled task persistence hunting in KQL is a useful comparison because it uses the same triage discipline on a different persistence mechanism.
Do not jump straight to removal unless you have a clear operational reason. First preserve the event data, the relevant files, and the surrounding process tree. If you are working in a live incident, capture the artefacts you need for later analysis before you change the host. If the subscription is clearly malicious, follow your incident response process and contain the affected endpoint in line with your internal playbook.
Reduce false positives and improve detection fidelity
Once you have a few real alerts, tune the detection so it reflects your environment. The most common source of noise is legitimate management software that uses WMI for inventory, remote configuration or monitoring. Build an allow list around the specific host groups, service accounts, namespaces and consumer names that are approved, rather than suppressing all WMI subscription activity. Broad suppression will hide the signal you actually want.
Use host role as a filter. Domain controllers, management servers and monitoring appliances may legitimately generate WMI subscriptions, while ordinary user endpoints usually should not. If your estate is small, a simple host group allow list may be enough. If it is larger, maintain a watchlist or reference table in your SIEM so you can update approved tooling without editing the detection every time a server is rebuilt.
Also tune for event quality. If the query text is often missing, your Sysmon configuration or parsing logic is incomplete. If the same host repeatedly generates expected events from the same approved tool, consider suppressing only that exact pattern. If a consumer type is consistently benign in your environment, document why it is allowed so future analysts do not have to rediscover the same decision.
For teams that already use detection engineering practices, this is a good candidate for version control and peer review. Keep the Sysmon configuration, the KQL query and the allow list logic together so changes are traceable. That makes it easier to explain why the rule exists and what evidence it depends on. It also helps when you map the control into a broader framework such as NIST CSF Detect and Respond or MITRE ATT&CK coverage reporting.
Verify the detection end to end and record the common failure points
Finish by proving the whole chain works from endpoint to alert. On a test host, create a benign WMI subscription in a controlled lab or use an approved test method from your internal validation process, then confirm that Sysmon logs Event IDs 19, 20 and 21, that the events reach your SIEM, and that your query returns the expected record. If you cannot see the event in the SIEM, the problem is usually in collection or parsing, not in the detection logic itself.
Common failure points are predictable. Sysmon is installed but the WMI event IDs are not enabled. The host is generating events, but the SIEM parser drops the namespace or query text. The detection runs, but the time window is too short to catch delayed ingestion. The rule fires, but there is no host context, so analysts cannot tell whether the activity is expected. Each of these issues is fixable once you know where the chain breaks.
Document the final state in your runbook. Record the Sysmon configuration version, the SIEM table or parser used, the allow-listed host groups, and the review steps for analysts. If you want to extend the same approach to other persistence techniques, keep the same structure, telemetry first, hunt second, triage third, tuning last. That gives you a repeatable detection pattern rather than a one-off query.
If you want help turning this into a production-ready detection set, or you want a second pair of eyes on your Sysmon coverage and SIEM tuning, Speak to a consultant.
Frequently asked questions
What do Sysmon Event IDs 19, 20 and 21 each show in a WMI persistence investigation?
Event ID 19 shows WMI event filter activity, Event ID 20 shows WMI event consumer activity, and Event ID 21 shows the binding between the filter and the consumer. Used together, they show the full persistence chain rather than a single isolated action.
How do you separate legitimate WMI subscriptions from suspicious ones in Windows telemetry?
Start with host role, approved tooling and service account context, then review the namespace, query text, consumer type and file path. Legitimate subscriptions usually map to known management software on expected hosts, while suspicious ones often appear on user endpoints, use unusual consumers, or point to writable locations.
