Detection rules › Sigma

Potentially Suspicious Powershell Script Execution From Temp Folder

Status
test
Severity
medium
Log source
product windows, category process_creation
Author
Florian Roth (Nextron Systems), Max Altgelt (Nextron Systems), Tim Shelton
Source
github.com/SigmaHQ/sigma

Detects a potentially suspicious powershell script executions from temporary folder

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Potentially Suspicious Powershell Script Execution From Temp Folder
id: a6a39bdb-935c-4f0a-ab77-35f4bbf44d33
status: test
description: Detects a potentially suspicious powershell script executions from temporary folder
references:
    - https://www.microsoft.com/security/blog/2021/07/13/microsoft-discovers-threat-actor-targeting-solarwinds-serv-u-software-with-0-day-exploit/
author: Florian Roth (Nextron Systems), Max Altgelt (Nextron Systems), Tim Shelton
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

Stages and Predicates

Stage 0: condition

selection and not 1 of filter_optional_*

Stage 1: selection

selection:
    Image|endswith:
        - '\powershell.exe'
        - '\pwsh.exe'
    CommandLine|contains:
        - '\Windows\Temp'
        - '\Temporary Internet'
        - '\AppData\Local\Temp'
        - '\AppData\Roaming\Temp'
        - '%TEMP%'
        - '%TMP%'
        - '%LocalAppData%\Temp'

Stage 2: not filter_optional_*

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'

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
ParentImageeqC:\Windows\SysWOW64\Msiexec.exe
ParentImageeqC:\Windows\System32\Msiexec.exe
CommandLinematch-NoProfile -ExecutionPolicy Bypass -Command
CommandLinematchAppData\Local\Temp\
CommandLinematchInstall-Chocolatey.ps1
Imageends_with\powershell.exe
CommandLinematch >
CommandLinematch-WindowStyle hidden -Verb runAs
CommandLinematchConvertTo-Json
CommandLinematchOut-File
CommandLinematch\Windows\system32\config\systemprofile\AppData\Local\Temp\Amazon\EC2-Windows\

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
CommandLinematch
  • %LocalAppData%\Temp corpus 2 (sigma 2)
  • %TEMP% corpus 16 (sigma 13, chronicle 2, kusto 1)
  • %TMP% corpus 15 (sigma 13, chronicle 2)
  • \AppData\Local\Temp corpus 8 (sigma 8)
  • \AppData\Roaming\Temp corpus 2 (sigma 2)
  • \Temporary Internet corpus 7 (sigma 7)
  • \Windows\Temp corpus 3 (sigma 3)
Imageends_with
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)