Windows forfiles.exe Spawned cmd.exe from Non-System Location
Alerts on forfiles.exe running outside system paths and spawning cmd.exe with a forfiles-encoded command pattern.
- Product
- windows
- Category
- process_creation
- Author
- Nasreddine Bencherchali (Nextron Systems), Anish Bogati (SigmaHQ), DRL 1.1
- Published
- 2024-01-05
- Updated
- 2026-07-31
ATT&CK techniques
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 process executions where forfiles.exe runs from a non-default location and spawns cmd.exe, with cmd.exe being named as \cmd.exe and launched using a command line that begins with /c echo ". The behavior matters because attackers can use forfiles to masquerade activity and indirectly execute commands from the current working directory. It relies on process creation telemetry including parent command line, parent image path, child image path, and child command line.
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 forfiles.exe Spawned cmd.exe from Non-System Location
id: 674ce959-e329-4d8d-8c9c-9cedef5eff34
status: test
description: This rule flags process executions where forfiles.exe runs from a non-default location and spawns cmd.exe, with cmd.exe being named as \cmd.exe and launched using a command line that begins with /c echo ". The behavior matters because attackers can use forfiles to masquerade activity and indirectly execute commands from the current working directory. It relies on process creation telemetry including parent command line, parent image path, child image path, and child command line.
references:
- https://www.hexacorn.com/blog/2023/12/31/1-little-known-secret-of-forfiles-exe/
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_forfiles_child_process_masquerading.yml
author: Nasreddine Bencherchali (Nextron Systems), Anish Bogati, Huntrule Team
date: 2024-01-05
tags:
- attack.stealth
- attack.t1036
logsource:
category: process_creation
product: windows
detection:
selection:
ParentCommandLine|endswith:
- .exe
- .exe"
Image|endswith: \cmd.exe
CommandLine|startswith: /c echo "
filter_main_parent_not_sys:
ParentImage|contains:
- :\Windows\System32\
- :\Windows\SysWOW64\
ParentImage|endswith: \forfiles.exe
Image|contains:
- :\Windows\System32\
- :\Windows\SysWOW64\
Image|endswith: \cmd.exe
condition: selection and not 1 of filter_main_*
falsepositives:
- Unknown
level: high
license: DRL-1.1
related:
- id: f53714ec-5077-420e-ad20-907ff9bb2958
type: derived