Detection rules › Splunk
Bypass or Unrestricted PowerShell Execution (PowerShell)
This use case identifies instances where PowerShell is executed with specific, potentially insecure execution policies such as Unrestricted, Bypass, or RemoteSigned. Threat actors may exploit these settings to execute malicious scripts or commands, as they allow scripts to run without the usual restrictions and without requiring digital signatures
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059.001 Command and Scripting Interpreter: PowerShell |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4103 | Payload Context: ContextInfo User Data: UserData. |
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '22489.40177'
title: Bypass or Unrestricted PowerShell Execution
description: 'This use case identifies instances where PowerShell is executed with
specific, potentially insecure execution policies such as Unrestricted, Bypass,
or RemoteSigned. Threat actors may exploit these settings to execute malicious scripts
or commands, as they allow scripts to run without the usual restrictions and without
requiring digital signatures. -- Threat Actor Association: UNC4990 - Software Association:
Rhysida'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4103) OR
"<EventID>4103<" OR TERM(EventCode=4104) OR "<EventID>4104<") (" -ExecutionPolicy
" OR " -ep " OR " -exec ") ("Unrestricted" OR "bypass" OR "RemoteSigned") | where
not match(process, "(?i):\x5c(Program\sFiles|ProgramData|AppData\x5cRoaming\x5cCode\x5c)")
| table _time, host, user process, process_*, signature_id | bin span=1s | stats
values(*) as * by _time, host '
techniques:
- execution:command and scripting interpreter:powershell
technique_id:
- T1059.001
data_category:
- PowerShell logs
references:
- https://thedfirreport.com/2021/11/01/from-zero-to-domain-admin/
- https://adsecurity.org/?p=2604
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4103) OR "<EventID>4103<" OR TERM(EventCode=4104) OR "<EventID>4104<") (" -ExecutionPolicy " OR " -ep " OR " -exec ") ("Unrestricted" OR "bypass" OR "RemoteSigned")
Stage 2: where
| where not match(process, "(?i):\x5c(Program\sFiles|ProgramData|AppData\x5cRoaming\x5cCode\x5c)")
Stage 3: table
| table _time, host, user process, process_*, signature_id
Stage 4: bucket
| bin span=1s
Stage 5: stats
| stats values(*) as * by _time, host
Exclusions
Top-level NOT(...) conjuncts: predicates this rule actively suppresses.
| Field | Kind | Excluded values |
|---|---|---|
process | match | "(?i):\x5c(Program\sFiles|ProgramData|AppData\x5cRoaming\x5cCode\x5c)" |
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
Search terms
Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | "<EventID>4103<" |
| 1 | TERM |
| 1 | "<EventID>4104<" |
| 1 | " -ExecutionPolicy " |
| 1 | " -ep " |
| 1 | " -exec " |
| 1 | "Unrestricted" |
| 1 | "bypass" |
| 1 | "RemoteSigned" |