Windows Process Creation: Cmd Invokes PowerShell via Obfuscated Environment Variable Expansion
Alerts on cmd.exe command lines that use obfuscated environment-variable SET to execute PowerShell.
- Product
- windows
- Category
- process_creation
- Author
- Jonathan Cheong, oscd.community (SigmaHQ), DRL 1.1
- Published
- 2020-10-15
- Updated
- 2026-07-31
ATT&CK techniques
Execution → Defense EvasionRecon
Resource Dev
Initial Access
Execution
Persistence
Priv Esc
Defense Evasion
Cred Access
Discovery
Lateral Movement
Collection
C2
Exfiltration
Impact
What it detects
This rule flags Windows command interpreter executions that use obfuscated environment variable expansion to construct and run PowerShell, matching a specific cmd /c or /r pattern containing a SET statement and encoded PowerShell invocation fragments. Such behavior matters because attackers often hide PowerShell payloads and reduce detection by dynamically building commands from environment variables. The detection relies on process creation telemetry, specifically the full CommandLine field for cmd.exe with the expected obfuscation characteristics.
Reporting behind it
Changelog
v2- v2Candidate ingested via manual entry.2026-07-31
- v1No changelog recorded for this version.2026-07-30
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.
title: "Windows Process Creation: Cmd Invokes PowerShell via Obfuscated Environment Variable Expansion"
id: f36e3df0-0b36-46a9-aa05-cf1922d4ca72
status: test
description: This rule flags Windows command interpreter executions that use obfuscated environment variable expansion to construct and run PowerShell, matching a specific cmd /c or /r pattern containing a SET statement and encoded PowerShell invocation fragments. Such behavior matters because attackers often hide PowerShell payloads and reduce detection by dynamically building commands from environment variables. The detection relies on process creation telemetry, specifically the full CommandLine field for cmd.exe with the expected obfuscation characteristics.
references:
- https://github.com/SigmaHQ/sigma/issues/1009
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_hktl_invoke_obfuscation_var.yml
author: Jonathan Cheong, oscd.community, Huntrule Team
date: 2020-10-15
modified: 2024-04-15
tags:
- attack.stealth
- attack.t1027
- attack.execution
- attack.t1059.001
logsource:
category: process_creation
product: windows
detection:
selection:
CommandLine|re: cmd.{0,5}(?:/c|/r)(?:\s|)\"set\s[a-zA-Z]{3,6}.*(?:\{\d\}){1,}\\\"\s+?\-f(?:.*\)){1,}.*\"
condition: selection
falsepositives:
- Unknown
level: high
license: DRL-1.1
related:
- id: 27aec9c9-dbb0-4939-8422-1742242471d0
type: derived