Skip to content
WETNav

PersistenceHigh

WMI event subscription persistence

Also known as Permanent WMI subscription, FilterToConsumerBinding

Fileless persistence that binds a WMI event filter to a consumer so attacker code runs on a trigger. WMI 5861 records the binding.

Signals in the logs

  1. 01WMI5861WMI permanent event subscription registeredAny host

    A permanent event consumer was bound in root\subscription.

    Consumer
    CommandLineEventConsumer or ActiveScriptEventConsumer and its payload
    Query
    the WQL filter query that triggers the consumer
  2. 02Sysmon20WMI Event Consumer Activity DetectedAny host

    A WMI event consumer was created; the Destination carries the command or script.

    Operation
    Created
    Consumer
    consumer name
    Destination
    command line or script run
  3. 03Sysmon21WMI Event Consumer To Filter Activity DetectedAny host

    A WMI consumer was bound to a filter (the binding that activates persistence).

    Operation
    Created
    Consumer
    consumer name
    Filter
    filter name
  4. 04Sysmon19WMI Event Filter Activity DetectedAny host

    A WMI event filter was created with a trigger query.

    Operation
    Created
    EventNamespace
    root\cimv2
    Query
    the WQL trigger query

What happens

A permanent WMI event subscription persists code without a Run key, a scheduled task, or a file on disk in an obvious startup location. The operator creates three objects in the root\subscription namespace: an __EventFilter (a WQL query that fires on a condition such as a time interval or a process start), an __EventConsumer (usually a CommandLineEventConsumer or ActiveScriptEventConsumer that runs a command or script), and a __FilterToConsumerBinding that ties them together. When the filter condition is met the consumer runs, typically as SYSTEM, surviving reboots. WMI records the permanent consumer binding as event 5861 in its operational log, and Sysmon, if configured, records the filter (19), consumer (20), and binding (21) separately, giving independent visibility into each object.

Logging you need

  • WMI-Activity 5861 is written to the operational log, which is enabled by default on current Windows.
  • Sysmon 19, 20, and 21 require a Sysmon configuration that includes the WmiEvent rules.
  • Reading the payload from 5861 needs the full event XML, since the consumer command is in the message body.

Hunt queries

Starting points. Tune thresholds and exclusions to your environment before alerting on them.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-WMI-Activity/Operational'; Id=5861}

Benign look-alikes

  • Management and monitoring platforms (SCCM, some antivirus, hardware agents) that register their own permanent subscriptions.
  • PowerShell DSC and other configuration tooling that uses WMI subscriptions.
  • Legacy in-house scripts that implement scheduled behavior through WMI rather than Task Scheduler.

Notes

  • ActiveScriptEventConsumer and CommandLineEventConsumer are the consumer classes used for execution; a subscription using either with an unusual payload warrants review.
  • The three objects can be created seconds apart; correlate the Sysmon 19/20/21 trio by time and by filter and consumer names.

References