Disabling Windows Defender Security Settings via PowerShell
Identifies use of the Set-MpPreference or Add-MpPreference PowerShell commands to disable or weaken certain Windows Defender settings, including detection of base64-encoded variants used to bypass command-line inspection.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2021/07/07"
3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
4maturity = "production"
5updated_date = "2026/04/21"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies use of the Set-MpPreference or Add-MpPreference PowerShell commands to disable or weaken certain Windows
11Defender settings, including detection of base64-encoded variants used to bypass command-line inspection.
12"""
13false_positives = ["Planned Windows Defender configuration changes."]
14from = "now-9m"
15index = [
16 "endgame-*",
17 "logs-crowdstrike.fdr*",
18 "logs-endpoint.events.process-*",
19 "logs-m365_defender.event-*",
20 "logs-sentinel_one_cloud_funnel.*",
21 "logs-system.security*",
22 "logs-windows.forwarded*",
23 "logs-windows.sysmon_operational-*",
24 "winlogbeat-*",
25]
26language = "eql"
27license = "Elastic License v2"
28name = "Disabling Windows Defender Security Settings via PowerShell"
29note = """## Triage and analysis
30
31### Investigating Disabling Windows Defender Security Settings via PowerShell
32
33Microsoft Windows Defender is an antivirus product built into Microsoft Windows, which makes it popular across multiple environments. Disabling it is a common step in threat actor playbooks.
34
35This rule monitors the execution of commands that can tamper the Windows Defender antivirus features.
36
37#### Possible investigation steps
38
39- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
40- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
41- Identify the user account that performed the action and whether it should perform this kind of action.
42- Contact the account owner and confirm whether they are aware of this activity.
43- Investigate other alerts associated with the user/host during the past 48 hours.
44- Examine the command line to determine which action was executed. Based on that, examine exceptions, antivirus state, sample submission, etc.
45
46### False positive analysis
47
48- This mechanism can be used legitimately. Analysts can dismiss the alert if the administrator is aware of the activity, the configuration is justified (for example, it is being used to deploy other security solutions or troubleshooting), and no other suspicious activity has been observed.
49
50### Related rules
51
52- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
53- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
54
55### Response and remediation
56
57- Initiate the incident response process based on the outcome of the triage.
58- Isolate the involved hosts to prevent further post-compromise behavior.
59- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
60- Based on the command line, take actions to restore the appropriate Windows Defender antivirus configurations.
61- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
62- Review the privileges assigned to the user to ensure that the least privilege principle is being followed.
63- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
64- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
65"""
66references = [
67 "https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=windowsserver2019-ps",
68 "https://www.elastic.co/security-labs/operation-bleeding-bear",
69 "https://www.elastic.co/security-labs/invisible-miners-unveiling-ghostengine",
70 "https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_powershell_defender_disable_feature.yml",
71]
72risk_score = 47
73rule_id = "c8cccb06-faf2-4cd5-886e-2c9636cfcb87"
74severity = "medium"
75tags = [
76 "Domain: Endpoint",
77 "OS: Windows",
78 "Use Case: Threat Detection",
79 "Tactic: Defense Evasion",
80 "Tactic: Execution",
81 "Resources: Investigation Guide",
82 "Data Source: Elastic Endgame",
83 "Data Source: Elastic Defend",
84 "Data Source: Windows Security Event Logs",
85 "Data Source: Microsoft Defender XDR",
86 "Data Source: Sysmon",
87 "Data Source: SentinelOne",
88 "Data Source: Crowdstrike",
89]
90timestamp_override = "event.ingested"
91type = "eql"
92
93query = '''
94process where host.os.type == "windows" and event.type == "start" and
95 (
96 process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") or
97 ?process.pe.original_file_name in ("PowerShell.EXE", "pwsh.dll", "powershell_ise.EXE")
98 ) and
99 (
100 (
101 process.args : ("Set-MpPreference", "Add-MpPreference") and
102 process.args : ("-Disable*", "Disabled", "NeverSend", "-Exclusion*")
103 ) or
104 /* base64-encoded (UTF-16LE) fragments of critical Defender settings, 3 byte-alignment offsets each */
105 (
106 process.command_line : ("*-e *", "*-en *", "* -enc*", "*FromBase64String*") and
107 process.command_line : (
108 /* DisableRealtimeMonitoring */
109 "*RABpAHMAYQBiAGwAZQBSAGUAYQBsAHQAaQBtAGUATQBvAG4AaQB0AG8AcgBpAG4AZwAgA*",
110 "*QAaQBzAGEAYgBsAGUAUgBlAGEAbAB0AGkAbQBlAE0AbwBuAGkAdABvAHIAaQBuAGcAIA*",
111 "*EAGkAcwBhAGIAbABlAFIAZQBhAGwAdABpAG0AZQBNAG8AbgBpAHQAbwByAGkAbgBnACAA*",
112 /* disablerealtimemonitoring */
113 "*ZABpAHMAYQBiAGwAZQByAGUAYQBsAHQAaQBtAGUAbQBvAG4AaQB0AG8AcgBpAG4AZwAgA*",
114 "*QAaQBzAGEAYgBsAGUAcgBlAGEAbAB0AGkAbQBlAG0AbwBuAGkAdABvAHIAaQBuAGcAIA*",
115 "*kAGkAcwBhAGIAbABlAHIAZQBhAGwAdABpAG0AZQBtAG8AbgBpAHQAbwByAGkAbgBnACAA*",
116 /* DisableIOAVProtection */
117 "*RABpAHMAYQBiAGwAZQBJAE8AQQBWAFAAcgBvAHQAZQBjAHQAaQBvAG4AIA*",
118 "*QAaQBzAGEAYgBsAGUASQBPAEEAVgBQAHIAbwB0AGUAYwB0AGkAbwBuACAA*",
119 "*EAGkAcwBhAGIAbABlAEkATwBBAFYAUAByAG8AdABlAGMAdABpAG8AbgAgA*",
120 /* disableioavprotection */
121 "*ZABpAHMAYQBiAGwAZQBpAG8AYQB2AHAAcgBvAHQAZQBjAHQAaQBvAG4AIA*",
122 "*QAaQBzAGEAYgBsAGUAaQBvAGEAdgBwAHIAbwB0AGUAYwB0AGkAbwBuACAA*",
123 "*kAGkAcwBhAGIAbABlAGkAbwBhAHYAcAByAG8AdABlAGMAdABpAG8AbgAgA*",
124 /* DisableBehaviorMonitoring */
125 "*RABpAHMAYQBiAGwAZQBCAGUAaABhAHYAaQBvAHIATQBvAG4AaQB0AG8AcgBpAG4AZwAgA*",
126 "*QAaQBzAGEAYgBsAGUAQgBlAGgAYQB2AGkAbwByAE0AbwBuAGkAdABvAHIAaQBuAGcAIA*",
127 "*EAGkAcwBhAGIAbABlAEIAZQBoAGEAdgBpAG8AcgBNAG8AbgBpAHQAbwByAGkAbgBnACAA*",
128 /* disablebehaviormonitoring */
129 "*ZABpAHMAYQBiAGwAZQBiAGUAaABhAHYAaQBvAHIAbQBvAG4AaQB0AG8AcgBpAG4AZwAgA*",
130 "*QAaQBzAGEAYgBsAGUAYgBlAGgAYQB2AGkAbwByAG0AbwBuAGkAdABvAHIAaQBuAGcAIA*",
131 "*kAGkAcwBhAGIAbABlAGIAZQBoAGEAdgBpAG8AcgBtAG8AbgBpAHQAbwByAGkAbgBnACAA*",
132 /* DisableBlockAtFirstSeen */
133 "*RABpAHMAYQBiAGwAZQBCAGwAbwBjAGsAQQB0AEYAaQByAHMAdABTAGUAZQBuACAA*",
134 "*QAaQBzAGEAYgBsAGUAQgBsAG8AYwBrAEEAdABGAGkAcgBzAHQAUwBlAGUAbgAgA*",
135 "*EAGkAcwBhAGIAbABlAEIAbABvAGMAawBBAHQARgBpAHIAcwB0AFMAZQBlAG4AIA*",
136 /* disableblockatfirstseen */
137 "*ZABpAHMAYQBiAGwAZQBiAGwAbwBjAGsAYQB0AGYAaQByAHMAdABzAGUAZQBuACAA*",
138 "*QAaQBzAGEAYgBsAGUAYgBsAG8AYwBrAGEAdABmAGkAcgBzAHQAcwBlAGUAbgAgA*",
139 "*kAGkAcwBhAGIAbABlAGIAbABvAGMAawBhAHQAZgBpAHIAcwB0AHMAZQBlAG4AIA*"
140 )
141 )
142 )
143'''
144
145
146[[rule.threat]]
147framework = "MITRE ATT&CK"
148[[rule.threat.technique]]
149id = "T1562"
150name = "Impair Defenses"
151reference = "https://attack.mitre.org/techniques/T1562/"
152[[rule.threat.technique.subtechnique]]
153id = "T1562.001"
154name = "Disable or Modify Tools"
155reference = "https://attack.mitre.org/techniques/T1562/001/"
156
157
158
159[rule.threat.tactic]
160id = "TA0005"
161name = "Defense Evasion"
162reference = "https://attack.mitre.org/tactics/TA0005/"
163[[rule.threat]]
164framework = "MITRE ATT&CK"
165[[rule.threat.technique]]
166id = "T1059"
167name = "Command and Scripting Interpreter"
168reference = "https://attack.mitre.org/techniques/T1059/"
169[[rule.threat.technique.subtechnique]]
170id = "T1059.001"
171name = "PowerShell"
172reference = "https://attack.mitre.org/techniques/T1059/001/"
173
174
175
176[rule.threat.tactic]
177id = "TA0002"
178name = "Execution"
179reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Investigating Disabling Windows Defender Security Settings via PowerShell
Microsoft Windows Defender is an antivirus product built into Microsoft Windows, which makes it popular across multiple environments. Disabling it is a common step in threat actor playbooks.
This rule monitors the execution of commands that can tamper the Windows Defender antivirus features.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
- Identify the user account that performed the action and whether it should perform this kind of action.
- Contact the account owner and confirm whether they are aware of this activity.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Examine the command line to determine which action was executed. Based on that, examine exceptions, antivirus state, sample submission, etc.
False positive analysis
- This mechanism can be used legitimately. Analysts can dismiss the alert if the administrator is aware of the activity, the configuration is justified (for example, it is being used to deploy other security solutions or troubleshooting), and no other suspicious activity has been observed.
Related rules
- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved hosts to prevent further post-compromise behavior.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Based on the command line, take actions to restore the appropriate Windows Defender antivirus configurations.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Review the privileges assigned to the user to ensure that the least privilege principle is being followed.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Clearing Windows Console History
- Control Panel Process with Unusual Arguments
- ImageLoad via Windows Update Auto Update Client
- Microsoft Build Engine Started by a System Process
- Microsoft Build Engine Started by an Office Application