Windows Defender Exclusions Added via PowerShelledit

Identifies modifications to the Windows Defender configuration settings using PowerShell to add exclusions at the folder directory or process level.

Rule type: eql

Rule indices:

  • winlogbeat-*
  • logs-endpoint.events.*
  • logs-windows.*

Severity: medium

Risk score: 47

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Elastic
  • Host
  • Windows
  • Threat Detection
  • Defense Evasion

Version: 7 (version history)

Added (Elastic Stack release): 7.14.0

Last modified (Elastic Stack release): 8.2.0

Rule authors: Elastic

Rule license: Elastic License v2

Investigation guideedit

## Triage and analysis

### Investigating Windows Defender Exclusions Added via PowerShell

Microsoft Windows Defender is an antivirus product built into Microsoft Windows. Since this software product is
used to prevent and stop malware, it's important to monitor what specific exclusions are made to the product's configuration
settings. These can often be signs of an adversary or malware trying to bypass Windows Defender's capabilities. One of
the more notable [examples](https://www.cyberbit.com/blog/endpoint-security/latest-trickbot-variant-has-new-tricks-up-its-sleeve/)
was observed in 2018 where Trickbot incorporated mechanisms to disable Windows Defender to avoid detection.

#### Possible investigation steps

- Investigate the process execution chain (parent process tree).
- 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.
- Examine the exclusion in order to determine the intent behind it.
- Check for similar behavior in other hosts on the environment.
- If the exclusion specifies a suspicious file, retrieve it and determine if it is malicious:
  - Use a private sandboxed malware analysis system to perform analysis.
    - Observe and collect information about the following activities:
      - Attempts to contact external domains and addresses.
      - File and registry access, modification, and creation activities.
      - Service creation and launch activities.
      - Scheduled tasks creation.
  - Use the PowerShell Get-FileHash cmdlet to get the SHA-256 hash value of the file.
    - Search for the existence and reputation of this file in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

### False positive analysis

- This rule has a high chance to produce false positives due to how often network administrators legitimately configure
exclusions. In order to validate the activity further, review the specific exclusion and its intent. There are many
legitimate reasons for exclusions, so it's important to gain context.

### Related rules

- Windows Defender Disabled via Registry Modification - 2ffa1f1e-b6db-47fa-994b-1512743847eb
- Disabling Windows Defender Security Settings via PowerShell - c8cccb06-faf2-4cd5-886e-2c9636cfcb87

### Response and remediation

- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
  - Implement any temporary network rules, procedures, and segmentation required to contain the malware.
    - Immediately block the identified indicators of compromise (IoCs).
    - Remove and block malicious artifacts identified on the triage.
- Exclusion lists for antimalware capabilities should always be routinely monitored for review.

## Config

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.

Rule queryedit

process where event.type == "start" and (process.name :
("powershell.exe", "pwsh.exe", "powershell_ise.exe") or
process.pe.original_file_name in ("powershell.exe", "pwsh.dll",
"powershell_ise.exe")) and process.args : ("*Add-MpPreference*",
"*Set-MpPreference*") and process.args : ("*-Exclusion*")

Threat mappingedit

Framework: MITRE ATT&CKTM

Rule version historyedit

Version 7 (8.2.0 release)
  • Formatting only
Version 6 (8.1.0 release)
  • Formatting only
Version 5 (8.0.0 release)
  • Updated query, changed from:

    process where event.type == "start" and (process.name :
    ("powershell.exe", "pwsh.exe", "powershell_ise.exe") or
    process.pe.original_file_name in ("powershell.exe", "pwsh.dll",
    "powershell_ise.exe")) and process.args : ("*Add-
    MpPreference*-Exclusion*", "*Set-MpPreference*-Exclusion*")
Version 4 (7.16.0 release)
  • Updated query, changed from:

    process where event.type == "start" and (process.name :
    ("powershell.exe", "pwsh.exe") or process.pe.original_file_name :
    ("powershell.exe", "pwsh.exe")) and process.args : ("*Add-
    MpPreference*-Exclusion*", "*Set-MpPreference*-Exclusion*")
Version 2 (7.15.0 release)
  • Formatting only