WMI Permanent Event Subscription Abuse for Persistence
Attackers use WMI permanent event subscriptions to execute malicious scripts or binaries for persistence by creating event consumers other than the default NTEventLogEventConsumer.
Attackers are increasingly leveraging Windows Management Instrumentation (WMI) permanent event subscriptions to establish persistence on compromised systems. This technique involves creating WMI event consumers that trigger malicious actions in response to specific system events. Unlike legitimate uses of WMI subscriptions for system administration, attackers create non-standard consumers to execute arbitrary code. By monitoring for deviations from expected WMI consumer behavior, defenders can identify and disrupt this persistence mechanism. This activity is significant because it allows attackers to maintain a foothold on the system, potentially leading to data theft, ransomware deployment, or other malicious activities.
Attack Chain
- An attacker gains initial access to a Windows system, often through phishing or exploiting a vulnerability.
- The attacker uses a tool like PowerShell to interact with the WMI service.
- The attacker creates a WMI filter to define specific events that will trigger the malicious action, using
__EventFilterWMI class. - The attacker creates a WMI consumer to execute a malicious script or binary, using
__CommandLineEventConsumeror__ScriptingEventConsumerWMI classes. - The attacker binds the filter and consumer together using
__FilterToConsumerBindingWMI class, creating a permanent event subscription. - The system event defined in the filter occurs (e.g., system startup, process creation).
- The WMI service executes the malicious script or binary defined in the consumer.
- The attacker maintains persistence, with the malicious code executing automatically whenever the specified event occurs.
Impact
Successful exploitation via WMI permanent event subscriptions can lead to long-term persistence on a compromised system. This can enable attackers to steal sensitive data, deploy ransomware, or perform other malicious activities undetected. The number of potential victims is broad, as this technique can be used against any Windows system where the attacker has sufficient privileges. The impact includes data breaches, financial losses, and reputational damage.
Recommendation
- Enable Windows WMI activity logs by configuring the input stanza
[WinEventLog://Microsoft-Windows-WMI-Activity/Operational]ininputs.conf. - Deploy the Sigma rule "Detect Suspicious WMI Event Consumer" to identify deviations from expected WMI consumer behavior.
- Investigate any alerts generated by the Sigma rule "Detect WMI FilterToConsumerBinding Creation" to determine if the activity is malicious.
- Monitor process creation events for unexpected processes spawned by
WmiPrvSE.exe, as this is the WMI Provider Host process.
Detection coverage 2
Detect Suspicious WMI Event Consumer
highDetects WMI event consumers other than the default NTEventLogEventConsumer, indicating potential malicious persistence.
Detect WMI FilterToConsumerBinding Creation
mediumDetects the creation of WMI FilterToConsumerBinding objects, which link event filters to consumers.
Detection queries are available on the platform. Get full rules →