Suspicious PowerShell Execution From Windows Temporary Folders on Windows
Alerts when PowerShell runs with command-line paths pointing to Windows temp directories, excluding some common benign installers.
FreeUnreviewedSigmamediumv1
suspicious-powershell-execution-from-windows-temporary-folders-on-windows-a6a39bdb
title: Suspicious PowerShell Execution From Windows Temporary Folders on Windows
id: ec8f0c3b-be61-4035-8d25-665babec4ee6
status: test
description: This rule flags PowerShell (powershell.exe/pwsh.exe) process launches whose command line references common Windows temporary directory paths such as \Windows\Temp and %TEMP%/%TMP%. Attackers often stage or run scripts from writable temp locations to evade detection and reduce the likelihood of being noticed under normal application paths. It relies on Windows process creation telemetry, matching executable names and command-line strings, while excluding a few known benign patterns (e.g., specific VS Code and Chocolatey installer behaviors).
references:
- https://www.microsoft.com/security/blog/2021/07/13/microsoft-discovers-threat-actor-targeting-solarwinds-serv-u-software-with-0-day-exploit/
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_powershell_script_exec_from_temp_folder.yml
author: Florian Roth (Nextron Systems), Max Altgelt (Nextron Systems), Tim Shelton, Huntrule Team
date: 2021-07-14
modified: 2026-02-17
tags:
- attack.execution
- attack.t1059.001
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith:
- \powershell.exe
- \pwsh.exe
CommandLine|contains:
- \Windows\Temp
- \Temporary Internet
- \AppData\Local\Temp
- \AppData\Roaming\Temp
- "%TEMP%"
- "%TMP%"
- "%LocalAppData%\\Temp"
filter_optional_vscode:
CommandLine|contains: -WindowStyle hidden -Verb runAs
filter_optional_amazon_ec2:
CommandLine|contains: \Windows\system32\config\systemprofile\AppData\Local\Temp\Amazon\EC2-Windows\
filter_optional_generic:
CommandLine|contains:
- " >"
- Out-File
- ConvertTo-Json
filter_optional_chocolatey_installer:
ParentImage:
- C:\Windows\System32\Msiexec.exe
- C:\Windows\SysWOW64\Msiexec.exe
Image|endswith: \powershell.exe
CommandLine|contains|all:
- -NoProfile -ExecutionPolicy Bypass -Command
- AppData\Local\Temp\
- Install-Chocolatey.ps1
condition: selection and not 1 of filter_optional_*
falsepositives:
- Administrative scripts
level: medium
license: DRL-1.1
related:
- id: a6a39bdb-935c-4f0a-ab77-35f4bbf44d33
type: derived
What it detects
This rule flags PowerShell (powershell.exe/pwsh.exe) process launches whose command line references common Windows temporary directory paths such as \Windows\Temp and %TEMP%/%TMP%. Attackers often stage or run scripts from writable temp locations to evade detection and reduce the likelihood of being noticed under normal application paths. It relies on Windows process creation telemetry, matching executable names and command-line strings, while excluding a few known benign patterns (e.g., specific VS Code and Chocolatey installer behaviors).
Known false positives
- Administrative scripts
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.