Disabling Windows Defender Security Settings via PowerShell
Identifies use of the Set-MpPreference PowerShell command to disable or weaken certain Windows Defender settings.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2021/07/07"
3integration = ["endpoint", "windows"]
4maturity = "production"
5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
6min_stack_version = "8.3.0"
7updated_date = "2023/06/22"
8
9[rule]
10author = ["Elastic"]
11description = "Identifies use of the Set-MpPreference PowerShell command to disable or weaken certain Windows Defender settings."
12false_positives = ["Planned Windows Defender configuration changes."]
13from = "now-9m"
14index = ["winlogbeat-*", "logs-endpoint.events.*", "logs-windows.*", "endgame-*"]
15language = "eql"
16license = "Elastic License v2"
17name = "Disabling Windows Defender Security Settings via PowerShell"
18note = """## Triage and analysis
19
20### Investigating Disabling Windows Defender Security Settings via PowerShell
21
22Microsoft 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.
23
24This rule monitors the execution of commands that can tamper the Windows Defender antivirus features.
25
26#### Possible investigation steps
27
28- 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.
29- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
30- Identify the user account that performed the action and whether it should perform this kind of action.
31- Contact the account owner and confirm whether they are aware of this activity.
32- Investigate other alerts associated with the user/host during the past 48 hours.
33- Examine the command line to determine which action was executed. Based on that, examine exceptions, antivirus state, sample submission, etc.
34
35### False positive analysis
36
37- 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.
38
39### Related rules
40
41- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
42- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
43
44### Response and remediation
45
46- Initiate the incident response process based on the outcome of the triage.
47- Isolate the involved hosts to prevent further post-compromise behavior.
48- 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.
49- Based on the command line, take actions to restore the appropriate Windows Defender antivirus configurations.
50- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
51- Review the privileges assigned to the user to ensure that the least privilege principle is being followed.
52- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
53- 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).
54
55## Setup
56
57If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define `event.ingested` and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate `event.ingested` to @timestamp for this rule to work.
58"""
59references = [
60 "https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=windowsserver2019-ps",
61]
62risk_score = 47
63rule_id = "c8cccb06-faf2-4cd5-886e-2c9636cfcb87"
64severity = "medium"
65tags = [
66 "Domain: Endpoint",
67 "OS: Windows",
68 "Use Case: Threat Detection",
69 "Tactic: Defense Evasion",
70 "Resources: Investigation Guide",
71 "Data Source: Elastic Endgame",
72 "Data Source: Elastic Defend"
73]
74timestamp_override = "event.ingested"
75type = "eql"
76
77query = '''
78process where host.os.type == "windows" and event.type == "start" and
79 (process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") or process.pe.original_file_name in ("powershell.exe", "pwsh.dll", "powershell_ise.exe")) and
80 process.args : "Set-MpPreference" and process.args : ("-Disable*", "Disabled", "NeverSend", "-Exclusion*")
81'''
82
83
84[[rule.threat]]
85framework = "MITRE ATT&CK"
86[[rule.threat.technique]]
87id = "T1562"
88name = "Impair Defenses"
89reference = "https://attack.mitre.org/techniques/T1562/"
90[[rule.threat.technique.subtechnique]]
91id = "T1562.001"
92name = "Disable or Modify Tools"
93reference = "https://attack.mitre.org/techniques/T1562/001/"
94
95
96
97[rule.threat.tactic]
98id = "TA0005"
99name = "Defense Evasion"
100reference = "https://attack.mitre.org/tactics/TA0005/"
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).
Setup
If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define event.ingested
and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate event.ingested
to @timestamp for this rule to work.
References
Related rules
- Adding Hidden File Attribute via Attrib
- Clearing Windows Console History
- Clearing Windows Event Logs
- Code Signing Policy Modification Through Built-in tools
- Code Signing Policy Modification Through Registry