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"
  5updated_date = "2024/05/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = "Identifies use of the Set-MpPreference PowerShell command to disable or weaken certain Windows Defender settings."
 10false_positives = ["Planned Windows Defender configuration changes."]
 11from = "now-9m"
 12index = [
 13    "winlogbeat-*",
 14    "logs-endpoint.events.process-*",
 15    "logs-windows.*",
 16    "endgame-*",
 17    "logs-system.security*",
 18]
 19language = "eql"
 20license = "Elastic License v2"
 21name = "Disabling Windows Defender Security Settings via PowerShell"
 22note = """## Triage and analysis
 23
 24### Investigating Disabling Windows Defender Security Settings via PowerShell
 25
 26Microsoft 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.
 27
 28This rule monitors the execution of commands that can tamper the Windows Defender antivirus features.
 29
 30#### Possible investigation steps
 31
 32- 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.
 33- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
 34- Identify the user account that performed the action and whether it should perform this kind of action.
 35- Contact the account owner and confirm whether they are aware of this activity.
 36- Investigate other alerts associated with the user/host during the past 48 hours.
 37- Examine the command line to determine which action was executed. Based on that, examine exceptions, antivirus state, sample submission, etc.
 38
 39### False positive analysis
 40
 41- 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.
 42
 43### Related rules
 44
 45- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
 46- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
 47
 48### Response and remediation
 49
 50- Initiate the incident response process based on the outcome of the triage.
 51- Isolate the involved hosts to prevent further post-compromise behavior.
 52- 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.
 53- Based on the command line, take actions to restore the appropriate Windows Defender antivirus configurations.
 54- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 55- Review the privileges assigned to the user to ensure that the least privilege principle is being followed.
 56- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 57- 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).
 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"
 64setup = """## Setup
 65
 66If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 67events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 68Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 69`event.ingested` to @timestamp.
 70For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 71"""
 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]
 83timestamp_override = "event.ingested"
 84type = "eql"
 85
 86query = '''
 87process where host.os.type == "windows" and event.type == "start" and
 88  (
 89    process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") or
 90    ?process.pe.original_file_name in ("powershell.exe", "pwsh.dll", "powershell_ise.exe")
 91  ) and
 92  process.args : "Set-MpPreference" and process.args : ("-Disable*", "Disabled", "NeverSend", "-Exclusion*")
 93'''
 94
 95
 96[[rule.threat]]
 97framework = "MITRE ATT&CK"
 98[[rule.threat.technique]]
 99id = "T1562"
100name = "Impair Defenses"
101reference = "https://attack.mitre.org/techniques/T1562/"
102[[rule.threat.technique.subtechnique]]
103id = "T1562.001"
104name = "Disable or Modify Tools"
105reference = "https://attack.mitre.org/techniques/T1562/001/"
106
107
108
109[rule.threat.tactic]
110id = "TA0005"
111name = "Defense Evasion"
112reference = "https://attack.mitre.org/tactics/TA0005/"
113[[rule.threat]]
114framework = "MITRE ATT&CK"
115[[rule.threat.technique]]
116id = "T1059"
117name = "Command and Scripting Interpreter"
118reference = "https://attack.mitre.org/techniques/T1059/"
119[[rule.threat.technique.subtechnique]]
120id = "T1059.001"
121name = "PowerShell"
122reference = "https://attack.mitre.org/techniques/T1059/001/"
123
124
125
126[rule.threat.tactic]
127id = "TA0002"
128name = "Execution"
129reference = "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