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", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
  4maturity = "production"
  5updated_date = "2024/11/02"
  6min_stack_version = "8.14.0"
  7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
  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 = [
 15    "winlogbeat-*",
 16    "logs-endpoint.events.process-*",
 17    "logs-windows.forwarded*",
 18    "logs-windows.sysmon_operational-*",
 19    "endgame-*",
 20    "logs-system.security*",
 21    "logs-m365_defender.event-*",
 22    "logs-sentinel_one_cloud_funnel.*",
 23    "logs-crowdstrike.fdr*",
 24]
 25language = "eql"
 26license = "Elastic License v2"
 27name = "Disabling Windows Defender Security Settings via PowerShell"
 28note = """## Triage and analysis
 29
 30### Investigating Disabling Windows Defender Security Settings via PowerShell
 31
 32Microsoft 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.
 33
 34This rule monitors the execution of commands that can tamper the Windows Defender antivirus features.
 35
 36#### Possible investigation steps
 37
 38- 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.
 39- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
 40- Identify the user account that performed the action and whether it should perform this kind of action.
 41- Contact the account owner and confirm whether they are aware of this activity.
 42- Investigate other alerts associated with the user/host during the past 48 hours.
 43- Examine the command line to determine which action was executed. Based on that, examine exceptions, antivirus state, sample submission, etc.
 44
 45### False positive analysis
 46
 47- 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.
 48
 49### Related rules
 50
 51- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
 52- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
 53
 54### Response and remediation
 55
 56- Initiate the incident response process based on the outcome of the triage.
 57- Isolate the involved hosts to prevent further post-compromise behavior.
 58- 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.
 59- Based on the command line, take actions to restore the appropriate Windows Defender antivirus configurations.
 60- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 61- Review the privileges assigned to the user to ensure that the least privilege principle is being followed.
 62- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 63- 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).
 64"""
 65references = [
 66    "https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=windowsserver2019-ps",
 67    "https://www.elastic.co/security-labs/operation-bleeding-bear", 
 68    "https://www.elastic.co/security-labs/invisible-miners-unveiling-ghostengine"
 69]
 70risk_score = 47
 71rule_id = "c8cccb06-faf2-4cd5-886e-2c9636cfcb87"
 72severity = "medium"
 73tags = [
 74    "Domain: Endpoint",
 75    "OS: Windows",
 76    "Use Case: Threat Detection",
 77    "Tactic: Defense Evasion",
 78    "Tactic: Execution",
 79    "Resources: Investigation Guide",
 80    "Data Source: Elastic Endgame",
 81    "Data Source: Elastic Defend",
 82    "Data Source: System",
 83    "Data Source: Microsoft Defender for Endpoint",
 84    "Data Source: Sysmon",
 85    "Data Source: SentinelOne",
 86    "Data Source: Crowdstrike",
 87]
 88timestamp_override = "event.ingested"
 89type = "eql"
 90
 91query = '''
 92process where host.os.type == "windows" and event.type == "start" and
 93  (
 94    process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") or
 95    ?process.pe.original_file_name in ("powershell.exe", "pwsh.dll", "powershell_ise.exe")
 96  ) and
 97  process.args : "Set-MpPreference" and process.args : ("-Disable*", "Disabled", "NeverSend", "-Exclusion*")
 98'''
 99
100
101[[rule.threat]]
102framework = "MITRE ATT&CK"
103[[rule.threat.technique]]
104id = "T1562"
105name = "Impair Defenses"
106reference = "https://attack.mitre.org/techniques/T1562/"
107[[rule.threat.technique.subtechnique]]
108id = "T1562.001"
109name = "Disable or Modify Tools"
110reference = "https://attack.mitre.org/techniques/T1562/001/"
111
112
113
114[rule.threat.tactic]
115id = "TA0005"
116name = "Defense Evasion"
117reference = "https://attack.mitre.org/tactics/TA0005/"
118[[rule.threat]]
119framework = "MITRE ATT&CK"
120[[rule.threat.technique]]
121id = "T1059"
122name = "Command and Scripting Interpreter"
123reference = "https://attack.mitre.org/techniques/T1059/"
124[[rule.threat.technique.subtechnique]]
125id = "T1059.001"
126name = "PowerShell"
127reference = "https://attack.mitre.org/techniques/T1059/001/"
128
129
130
131[rule.threat.tactic]
132id = "TA0002"
133name = "Execution"
134reference = "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.
  • 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

to-top