Windows Management Instrumentation (WMI) is Microsoft’s implementation of the Common Information Model (CIM), a standard way to describe and interact with management data on Windows systems. Administrators use it to query system information, run processes and scripts, and react to system events, on the local machine or on a remote one.
WMI uses several components together to manage and interact with Windows resources.
wmic.exe. A client sends a request to read data, run a method, or subscribe to an event.Microsoft has removed the WMIC command-line utility (wmic.exe) from Windows 11 24H2 and 25H2 as of the September 2026 Security Update.
%SystemRoot%\System32\wbem\Repository. It holds class definitions and persistent objects that WMI uses to provide management functionality. Win32_Process exposes Name, ProcessId, and CommandLine.Create to start a process or Terminate to stop one.Win32_Process, service information through Win32_Service, and network adapter information through Win32_NetworkAdapter. Their registration details are stored in the WMI repository so WMI can locate the appropriate provider.WmiPrvSE.exe, the WMI Provider Host. Multiple instances can run simultaneously under accounts such as SYSTEM, LOCAL SERVICE, or NETWORK SERVICE, depending on the providers’ hosting requirements.svchost.exe service-host process.
Common examples include:
| Namespace | Typical purpose |
|---|---|
root\cimv2 |
Common Windows management classes covering processes, services, the operating system, and hardware. |
root\subscription |
The recommended location for permanent event subscriptions, including their filters, consumers, and bindings. |
root\default |
Includes access to registry-related functionality through the Registry Provider. |
Namespaces provide both organization and an access-control boundary: permissions help determine who can connect and which operations they can perform.
Suppose a client runs Get-CimInstance -Namespace root\cimv2 -ClassName Win32_Process:
Win32_Process in the root\cimv2 namespace of the repository, which says which provider serves it.WmiPrvSE.exe if it isn’t already running.
WMI clients retrieve information using WQL (WMI Query Language), a query language with syntax similar to SQL.
For example:
SELECT * FROM Win32_Process WHERE Name = 'notepad.exe'
This asks WMI to return the available properties of running processes named notepad.exe. Here, Win32_Process identifies the class, while WHERE limits the results to matching instances.
WMI processes the request and obtains the information from the appropriate provider. The results return as objects whose properties the client can display, filter, or use in further operations.
WMI eventing is a mechanism in Windows Management Instrumentation (WMI) that allows applications and administrative scripts to receive notifications when specific system events or changes occur, such as a process starting, a service stopping, or available disk space falling below a defined threshold.
WMI supports both temporary (in-process, transient) and permanent event subscriptions.
root\subscription namespace: an event filter that defines what to watch for, an event consumerOnce the WMI service is running after a reboot, permanent subscriptions can respond to matching events again without the original client being present. This makes them useful for administrative automation, but also gives attackers a way to maintain persistence through WMI objects.
WMI is built in, present on every Windows host and used by administrators, so malicious use blends in with normal activity. Red Canary ranks it seventh among the techniques it detects most in its Threat Detection Report. Attackers use it to:
wmic or Impacket’s wmiexec.Each of these deserves its own treatment, and we will cover them in upcoming posts. This post stays on persistence through WMI eventing, how attackers use it, and the telemetry that helps detect it.
Attackers set up Permanent WMI Event Subscriptions, which run when specific system conditions or triggers occur. The commonly abused command and script consumers run in the background under NT AUTHORITY\SYSTEM. Depending on how the payload is stored and executed, this can work without dropping a separate malicious executable to disk.
Unlike a temporary subscription, which ends when the subscribing client disconnects or exits, a permanent subscription is saved in the WMI repository (C:\Windows\System32\wbem\Repository). It stays registered after its creator exits and survives reboots, because WMI reloads it from the repository each time the service starts.
Setting up subscriptions requires local administrator privileges or SYSTEM access on the target machine. Attackers may already have gained this access earlier in the attack, for example through privilege escalation or stolen administrator credentials.
A permanent WMI subscription requires three linked objects stored in the root\subscription namespace (Microsoft’s recommended namespace for permanent subscriptions) of the WMI repository:
__EventFilter): A WQL (WMI Query Language) query that defines the trigger condition. Common triggers include system startup (Win32_ProcessStartTrace), a user logging in, or a set timer.__EventConsumer): The payload or action executed when the filter condition is met. The two most commonly abused consumer types are:
CommandLineEventConsumer: Executes a direct command line or executable.ActiveScriptEventConsumer: Executes VBScript or JScript payloads directly in memory.__FilterToConsumerBinding): The administrative link that joins the Event Filter to the Event Consumer.
When an event matches the filter’s query, WMI invokes the bound consumer. The process activity depends on the consumer type.
CommandLineEventConsumer is the one consumer type whose purpose is to execute an arbitrary command line when its bound __EventFilter condition matches. Its ExecutablePath and CommandLineTemplate properties specify the executable and command line. The new process typically appears as a child of the WmiPrvSE.exe instance hosting the consumer, making this relationship useful for detection.
ActiveScriptEventConsumer doesn’t start a binary directly. It runs a VBScript or JScript payload inside scrcons.exe, the WMI Standard Consumer Scripting Host. The script can be embedded in the consumer's ScriptText property or referenced as a file through ScriptFileName.
Because scrcons.exe is activated through COM, it commonly appears as a child of svchost.exe hosting the DcomLaunch service. Its execution, especially unexpected child processes provides another useful investigation point.
Mandiant’s analysis of POSHSPY, a backdoor attributed to APT29, shows how WMI can provide both payload storage and persistence.
APT29 created a custom WMI class and stored an encrypted, Base64-encoded PowerShell backdoor in one of its text properties. A permanent event filter was bound to a CommandLineEventConsumer that launched an encoded PowerShell command. That command retrieved the stored backdoor, decrypted it, and executed it directly from memory. In observed configuration, the filter triggered at a particular time on selected days of the week.
The subscription and stored payload used names resembling Windows components. Mandiant reported that this installation left no payload files outside the WMI repository, making it harder to identify through traditional file-based host analysis.
Microsoft-Windows-WMI-Activity.
Applications and Services Logs > Microsoft > Windows > WMI-Activity > Operational) for Event ID 5857–5861 to trace WMI namespace, consumer, and provider activity.WMI Event Subscription Created
A permanent subscription connects an event filter to a consumer through a __FilterToConsumerBinding object. This binding associates the monitored condition with the action WMI should perform.
This alert detects newly created bindings referencing CommandLineEventConsumer or ActiveScriptEventConsumer through Sysmon Event 21. It also checks WMI-Activity Event 5861 for references to either consumer type. These are the two execution-capable consumers described in the persistence section: one launches a command or executable, while the other runs a script.
Sysmon Events 19 and 20 can provide additional context about the associated filter and consumer.
(
(norm_id=WindowsSysmon event_id=21
consumer IN ["*CommandLineEventConsumer*", "*ActiveScriptEventConsumer*"] operation="Created")
OR
(norm_id=WinServer event_id=5861 event_source="Microsoft-Windows-WMI-Activity"
message IN ["*ActiveScriptEventConsumer*", "*CommandLineEventConsumer*"])
)
When a CommandLineEventConsumer runs its configured command, the launched process typically appears as a child of WmiPrvSE.exe.
This alert identifies shells, scripting engines, and execution utilities launched directly by WmiPrvSE.exe. It provides visibility into suspicious WMI execution.
Similar activity can occur during legitimate administration, such as using WMI to run a PowerShell troubleshooting script, execute a maintenance batch file, or install software. Connecting the observed command to a suspicious subscription strengthens the evidence that the activity came from the persistence mechanism described above.
label="Process" label=Create
(parent_process ="*\Wmiprvse.exe"
(("process" IN ["*\certutil.exe","*\cscript.exe","*\cmd.exe", "*\powershell.exe", "*\pwsh.exe","*\mshta.exe","*\msiexec.exe","*\regsvr32.exe","*\rundll32.exe","*\verclsid.exe","*\wscript.exe"])
OR
("process"="*\cmd.exe" command IN ["*cscript*","*mshta*","*powershell*","*pwsh*","*regsvr32*","*rundll32*","*wscript*"]))
-"process" IN ["*\conhost.exe", "*\WMIC.exe", "*\WerFault.exe","*\wmprvse.exe"])
WMI Persistence - Script Event Consumer Detected
An ActiveScriptEventConsumer runs VBScript or JScript through scrcons.exe, the WMI scripting host. The script can be embedded in the consumer or loaded from a script file.
The following alert detects scrcons.exe starting from its standard Windows location with svchost.exe as its parent. This can indicate execution through a permanent WMI event subscription.
label="Process" label=Create
"process"="*:\WINDOWS\system32\wbem\scrcons.exe" parent_process="*:\Windows\System32\svchost.exe"
Although scrcons.exe hosts the script itself, the script can launch other programs to carry out further actions.
The following hunt identifies children of scrcons.exe like PowerShell, command shells, scripting hosts, and utilities such as schtasks.exe, regsvr32.exe, and rundll32.exe.
label="Process" label=Create
parent_process="*:\WINDOWS\system32\wbem\scrcons.exe"
"process" IN ["*\svchost.exe", "*\dllhost.exe","*\cmd.exe","*\powershell.exe", "*\pwsh.exe", "*\wscript.exe", "*\cscript.exe", "*\schtasks.exe", "*\regsvr32.exe", "*\mshta.exe", "*\rundll32.exe", "*\msiexec.exe", "*\msbuild.exe"]
WMI Persistence - Script Event Consumer File Write
The script may also create or overwrite a file. Even when its original code is embedded in the WMI repository, its subsequent actions can leave additional disk artifacts.
This alert uses Sysmon Event 11 to identify file creation or overwriting attributed directly to scrcons.exe at the specified path. It does not capture every kind of file modification.
norm_id=WindowsSysmon event_id=11 "process"="C:\WINDOWS\system32\wbem\scrcons.exe" -user IN EXCLUDED_USERS
WMI event subscriptions give attackers a way to maintain access across reboots using built-in Windows features. Because the subscription and even the payload can live in the WMI repository, detection needs to go beyond scanning for malicious files.
To reduce the risk, limit local administrator access, protect privileged credentials, and review permanent WMI subscriptions to confirm they serve a legitimate purpose. Validate the detection rules covered in this blog in your environment, ensuring the required logs reach your SIEM and the alerts fire as expected.