Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
id: splunk-security-content-02c1d8e9-044c-401f-906c-cc95445af8bd
name: PowerShell Environment Variable Execution
description: The following analytic detects the execution of PowerShell scripts that
combine environment variable access (`$env:` or `[Environment]::SetEnvironmentVariable`)
with `Invoke-Expression` or its alias `iex` to dynamically construct and run code
at runtime. This technique is commonly used by adversaries to stage and execute
payloads by embedding commands or encoded content inside environment variables,
then evaluating them on the fly — effectively hiding the true execution intent from
static inspection. Detection is based on PowerShell Script Block Logging (Event
ID 4104), which captures the de-obfuscated script block before it executes. Triggering
this analytic indicates a potential attempt to execute environment-variable-stored
code, a behavior observed in malware loaders and stagers, including those associated
with the VIP Keylogger campaign.
severity: medium
enabled: false
tags:
mitre:
- T1059.001
categories:
- endpoint
references:
- https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly?view=net-5.0
- https://help.splunk.com/en/security-offerings/splunk-user-behavior-analytics/get-data-in/5.4.1/add-other-data-to-splunk-uba/configure-powershell-logging-to-see-powershell-anomalies-in-splunk-uba.
- https://blog.palantir.com/tampering-with-windows-event-tracing-background-offense-and-defense-4be7ac62ac63
- https://static1.squarespace.com/static/552092d5e4b0661088167e5c/t/59c1814829f18782e24f1fe2/1505853768977/Windows+PowerShell+Logging+Cheat+Sheet+ver+Sept+2017+v2.1.pdf
- https://www.crowdstrike.com/blog/investigating-powershell-command-and-script-logging/
logsource:
product: splunk
detection:
splunk_spl: "`powershell`\nEventCode=4104\nScriptBlockText=\"*$env:*\"\nScriptBlockText\
\ IN (\n \"*.Invoke()*\",\n \"*[scriptblock]::Create*\",\n \"*iex *\"\
,\n \"*Invoke-Expression*\"\n)\nScriptBlockText=\"*[Environment]::SetEnvironmentVariable*\"\
\n| regex ScriptBlockText=\"(?i)((invoke-expression|iex\\s+|\\biex\\b).*\\$env:|\\\
[scriptblock\\]::create\\s*\\(\\s*\\$env:[^)]+\\)\\s*(?:\\.\\s*invoke\\s*\\(\\\
s*\\))?)\"\n| fillnull\n| stats count min(_time) as firstTime max(_time) as lastTime\n\
by dest signature signature_id user_id vendor_product EventID Guid Opcode Name\
\ Path ProcessID ScriptBlockId ScriptBlockText\n| `security_content_ctime(firstTime)`\n\
| `security_content_ctime(lastTime)`\n| `powershell_environment_variable_execution_filter`"
provenance:
source: splunk/security_content
source_id: 02c1d8e9-044c-401f-906c-cc95445af8bd
source_commit: 4d4c7ee
license: Apache-2.0
license_url: https://github.com/splunk/security_content/blob/develop/LICENSE
imported_at: '2026-05-04'
imported_by: splunk_importer
upstream_path: detections/endpoint/powershell_environment_variable_execution.yml
notes:
splunk_status: production
splunk_data_source: []
quarantine_reason: raw SPL — needs translation to AiSOC detection schema