Detection rules › Splunk

Bypass or Unrestricted PowerShell Execution (PowerShell)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

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

References

Event coverage

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.

FieldKindExcluded values
processmatch"(?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.

FieldKindValues
EventCodeeq
  • 4103 corpus 105 (splunk 105)
  • 4104 corpus 268 (splunk 268)

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.

StageTerm
1TERM
1"<EventID>4103<"
1TERM
1"<EventID>4104<"
1" -ExecutionPolicy "
1" -ep "
1" -exec "
1"Unrestricted"
1"bypass"
1"RemoteSigned"