Abuse of PowerShell Disable-WindowsOptionalFeature for Defense Impairment
Adversaries leverage the Disable-WindowsOptionalFeature PowerShell cmdlet to disable security features like Windows Defender, facilitating defense impairment and persistence.
The Disable-WindowsOptionalFeature PowerShell cmdlet, a native component of the Deployment Image Servicing and Management (DISM) toolset, is increasingly targeted by adversaries to disable critical Windows security features. By invoking this cmdlet with the -Online and -FeatureName parameters, attackers can programmatically remove or disable built-in services, specifically targeting Windows Defender GUI, features, and application guard components. This technique is part of a broader class of defense impairment where attackers modify system state to reduce visibility or eliminate protective software. As a legitimate administrative function, its misuse often blends with standard system maintenance, making detection dependent on monitoring PowerShell Script Block Logging (Event ID 4104) for specific cmdlet signatures combined with sensitive feature names.
Attack Chain
- Initial access is established through a compromised account or social engineering.
- The attacker gains execution privileges as an administrator, which is required to modify system features.
- The attacker identifies the target security feature to be disabled (e.g., Windows-Defender).
- PowerShell is invoked to execute the Disable-WindowsOptionalFeature cmdlet.
- The -Online parameter is used to target the currently running operating system instance.
- The -FeatureName parameter specifies the security component to be disabled.
- The system process modifications are processed by the DISM subsystem.
- Final objective of defense impairment is achieved, allowing for subsequent malicious activities without detection by local security software.
Impact
Successful exploitation of this technique results in the complete or partial disabling of built-in Windows security mechanisms. This increases the exposure of the host to further malicious activities, as security tooling (like Windows Defender) is rendered inactive, facilitating long-term persistence and unauthorized data exfiltration.
Recommendation
Detection engineers should prioritize the visibility of administrative command-line execution and PowerShell script usage.
- Enable PowerShell Script Block Logging (Event ID 4104) to capture the full command syntax.
- Deploy the provided Sigma rule to monitor for suspicious disabling of security-related feature names.
- Audit administrative access policies to ensure that only authorized personnel can execute modification cmdlets.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104) across all endpoints
Threat Hunt
Search for historical logs of Disable-WindowsOptionalFeature usage
Data: Event ID 4104
Mitigations
Implement GPO to restrict administrative modification of Windows security features
Defense impairment via DISM
Detection coverage 1
Detect Disable-WindowsOptionalFeature for Security Features
highDetects the use of the Disable-WindowsOptionalFeature PowerShell cmdlet to disable Windows Defender components, indicating potential defense impairment.
Detection queries are available on the platform. Get full rules →