A CommandLineEventConsumer is a WMI event consumer that starts a command-line process when a matching event occurs. It can execute an arbitrary command or script through the Windows eventing framework, so defenders treat it as a persistence and execution mechanism.
What the term means in Windows persistence terms
CommandLineEventConsumer is a WMI event consumer that turns a Windows Management Instrumentation event into process execution. In practice, that means an attacker or administrator can bind a script or command to a trigger, then have Windows launch it automatically when the condition is met.
Because the consumer is event-driven rather than interactive, it can run without a visible logon session and can blend into normal system activity. That makes it a durable mechanism for hands-off execution, persistence, and follow-on actions after initial compromise.
Windows eventing is the important concept here: the consumer is not a standalone scheduler, it is part of the WMI subscription model. Defenders therefore look for the subscription, the consumer object, and the process tree it creates, rather than only the final payload.
Why it is dangerous
The danger is not the command line itself, but the trust Windows places in WMI subscriptions. A malicious consumer can launch arbitrary commands in response to a matching event, which gives an attacker a low-friction way to maintain persistence, stage additional tooling, or execute payloads with the context available to the WMI host.
This pattern is especially useful to defenders because it can survive simple cleanup of the initial malware process. If the subscription remains in place, the system can keep re-running the payload until the event source or consumer is removed.
For a broader control lens on WMI abuse, T1047 Windows Management Instrumentation Defensive Guide is the most direct internal reference for hunting, blocking, and containing this class of activity.
How defenders find exposure
Exposure starts with knowing where WMI subscription abuse could matter. That means inventorying endpoints and servers that allow WMI activity, checking whether remote WMI is permitted, and reviewing whether the environment has logging that can surface permanent event subscriptions, child processes from WmiPrvSE.exe, and suspicious command lines.
It also helps to review administrative tooling and endpoint baselines for signs that the system is set up to create or persist WMI consumers in the first place. If WMI is common in the environment, defenders need a normal baseline for legitimate subscriptions so malicious ones stand out.
Microsoft and other vendor guidance should be used to confirm the exact eventing artefacts and logging sources available in a given build, because practical visibility depends on platform configuration as much as on the technique itself.
Containment, detection, and removal
When this mechanism is found, defenders should treat it as both an execution path and a persistence artefact. The investigation needs to include the command payload, the WMI filter or trigger that activates it, and any related processes created after the event fires.
Detection is strongest when event telemetry, process creation telemetry, and WMI subscription review are correlated together. A single suspicious command line may be noisy on its own, but a command launched by a WMI consumer is much more actionable because the relationship reveals intent and persistence.
Removal must address both the consumer and its trigger. If only the script or command is deleted, the subscription can still point to a new payload later. After cleanup, defenders should review for any additional persistence, credential access, or lateral movement that may have followed the same WMI path.
Risk and Threat Considerations
This technique is attractive because it gives an intruder a resilient execution mechanism that can survive process termination and can be triggered repeatedly by the operating system. It is a common way to keep code running after initial access is lost, which raises the cost of eradication.
Failure mechanism: A WMI event subscription is created or modified so that a command-line payload launches whenever the chosen event occurs, allowing persistence to continue even after the original malware process is removed.
Impact: The attacker can regain execution, re-stage tools, and extend dwell time, while defenders may miss the persistence point if they only inspect active processes instead of subscription objects and their triggers.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1047 — Windows Management Instrumentation | Defines WMI abuse as an adversary technique that includes event consumers and persistence. |
| Recommendation — Map suspicious WMI subscriptions to T1047 and hunt for spawned child processes and related persistence artefacts. | ||
| NIST SP 800-53 Rev 5 | AU-6 — Audit Record Review, Analysis, and Reporting | Supports reviewing logs to detect WMI-triggered execution and related anomalous processes. |
| SI-4 — System Monitoring | Covers active monitoring for hostile or abnormal WMI event consumer activity. | |
| CM-7 — Least Functionality | Supports limiting unnecessary WMI exposure and administrative pathways that enable persistence abuse. | |
| Recommendation — Correlate WMI telemetry with process and security logs to identify unexpected command execution. Monitor for suspicious WMI subscription creation and command-spawning activity across endpoints. Restrict WMI use to justified management scenarios and remove unnecessary execution paths. | ||
| CIS Controls v8 | CIS-8 — Audit Log Management | Addresses collecting and using logs needed to spot WMI-based execution and persistence. |
| Recommendation — Centralise logs that can reveal WMI subscription abuse and unexpected child process creation. | ||
Practitioner Guidance
What to watch for: Look for WMI subscriptions that create child processes unexpectedly, especially when the spawned command line is not part of a known management workflow. In practice, the best clue is often the relationship between the event consumer and the process it launches, not the command itself.
Governance implication: Treat WMI event consumers as a controlled persistence surface. Administrators should know which teams are allowed to create them, which endpoints legitimately need them, and what logging is required to validate their use.
Practitioner takeaway: If you cannot explain why a system should launch commands from WMI events, assume it deserves an investigation rather than a waiver.
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 29, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org