Detection rules › Elastic
Suspicious Windows Defender Exclusions Added via PowerShell
Identifies modifications to the Windows Defender configuration settings using PowerShell to add exclusions at the folder directory or process level.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Defense Impairment |
Rule body
[rule]
description = """
Identifies modifications to the Windows Defender configuration settings using PowerShell to add exclusions at the folder
directory or process level.
"""
id = "2ad8b514-baf0-4e29-a712-d6734868aa57"
license = "Elastic License v2"
name = "Suspicious Windows Defender Exclusions Added via PowerShell"
os_list = ["windows"]
reference = [
"https://docs.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps",
]
version = "1.0.29"
query = '''
sequence with maxspan=1m
[process where event.action == "start" and
not process.Ext.token.integrity_level_name == "system" and
(
(process.code_signature.trusted != true) or
(process.executable : ("?:\\Windows\\Microsoft.NET\\*",
"?:\\Users\\Public\\*",
"?:\\Users\\*\\AppData\\Local\\Temp\\*",
"?:\\Users\\*\\AppData\\Roaming\\*",
"?:\\Users\\*\\Pictures\\*",
"?:\\Users\\*\\Documents\\*",
"?:\\Windows\\Resources\\Themes\\*",
"?:\\ProgramData\\*") and not process.executable : "?:\\ProgramData\\*\\*") or
(process.name : ("rundll32.exe", "regsvr32.exe", "WScript.exe")) or
descendant of [process where event.action == "start" and process.name : "msiexec.exe"]
)] by process.entity_id
[process where event.action == "start" and
process.name : ("cmd.exe", "powershell.exe") and
process.command_line : ("*Add-MpPreference*", "*Set-MpPreference*") and
process.command_line: ("*-ExclusionPath*", "*-DisableRealtimeMonitoring*", "*-DisableScriptScanning*", "*-DisableArchiveScanning*")] by process.parent.entity_id
'''
min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 1
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"
[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1562"
name = "Impair Defenses"
reference = "https://attack.mitre.org/techniques/T1562/"
[[threat.technique.subtechnique]]
id = "T1562.001"
name = "Disable or Modify Tools"
reference = "https://attack.mitre.org/techniques/T1562/001/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "7.15.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1m, correlated by process.entity_id, process.parent.entity_id.
Stage 1: process
[process where event.action == "start" and
not process.Ext.token.integrity_level_name == "system" and
(
(process.code_signature.trusted != true) or
(process.executable : ("?:\\Windows\\Microsoft.NET\\*",
"?:\\Users\\Public\\*",
"?:\\Users\\*\\AppData\\Local\\Temp\\*",
"?:\\Users\\*\\AppData\\Roaming\\*",
"?:\\Users\\*\\Pictures\\*",
"?:\\Users\\*\\Documents\\*",
"?:\\Windows\\Resources\\Themes\\*",
"?:\\ProgramData\\*") and not process.executable : "?:\\ProgramData\\*\\*") or
(process.name : ("rundll32.exe", "regsvr32.exe", "WScript.exe")) or
descendant of [process where event.action == "start" and process.name : "msiexec.exe"]
)] by process.entity_id
Stage 2: process
[process where event.action == "start" and
process.name : ("cmd.exe", "powershell.exe") and
process.command_line : ("*Add-MpPreference*", "*Set-MpPreference*") and
process.command_line: ("*-ExclusionPath*", "*-DisableRealtimeMonitoring*", "*-DisableScriptScanning*", "*-DisableArchiveScanning*")] by process.parent.entity_id
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.token.integrity_level_name | eq | system | excludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"start" |
process.code_signature.trusted | ne |
| field:"process.code_signature.trusted" kind:ne value:"true" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard |
process.executable | wildcard |
| field:"Image" kind:wildcard |
process.name | wildcard |
| field:"process_name" kind:wildcard |