Detection rules › Elastic

Suspicious Windows Defender Exclusions Added via PowerShell

Time window
1m
Sequence by
process.entity_id, process.parent.entity_id
Source
github.com/elastic/protections-artifacts

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

MITRE ATT&CK coverage

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.

FieldKindExcluded valuesSearch
process.Ext.token.integrity_level_nameeqsystemexcludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.code_signature.trustedne
  • true transforms: boolean corpus 8 (elastic 8)
field:"process.code_signature.trusted" kind:ne value:"true"
process.command_linewildcard
  • *-DisableArchiveScanning*
  • *-DisableRealtimeMonitoring*
  • *-DisableScriptScanning*
  • *-ExclusionPath* corpus 3 (kusto 2, elastic 1)
  • *Add-MpPreference* corpus 4 (sigma 2, elastic 1, kusto 1)
  • *Set-MpPreference* corpus 7 (sigma 3, splunk 2, elastic 1, kusto 1)
field:"CommandLine" kind:wildcard
process.executablewildcard
  • ?:\ProgramData\* corpus 17 (elastic 17)
  • ?:\Users\*\AppData\Local\Temp\*
  • ?:\Users\*\AppData\Roaming\* corpus 5 (elastic 5)
  • ?:\Users\*\Documents\* corpus 2 (elastic 2)
  • ?:\Users\*\Pictures\* corpus 2 (elastic 2)
  • ?:\Users\Public\* corpus 4 (elastic 4)
  • ?:\Windows\Microsoft.NET\* corpus 5 (elastic 5)
  • ?:\Windows\Resources\Themes\*
field:"Image" kind:wildcard
process.namewildcard
  • WScript.exe corpus 83 (elastic 82, splunk 1)
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • regsvr32.exe corpus 73 (elastic 68, splunk 5)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
field:"process_name" kind:wildcard