Windows forfiles.exe Executed With /c Flag

Flags forfiles.exe executions that include the /c flag, indicating potential indirect command execution.

FreeUnreviewedSigmamediumv1
title: Windows forfiles.exe Executed With /c Flag
id: 9e3e4878-1857-4d14-9fa6-ac6fe2bf1d71
related:
  - id: a85cf4e3-56ee-4e79-adeb-789f8fb209a8
    type: obsolete
  - id: fa47597e-90e9-41cd-ab72-c3b74cfb0d02
    type: obsolete
  - id: 9aa5106d-bce3-4b13-86df-3a20f1d5cf0b
    type: derived
status: test
description: This rule flags process creation where forfiles.exe is launched with the /c option. Attackers can use this flag to proxy or indirectly execute commands, which may help bypass application control or whitelisting. It relies on Windows process creation telemetry, specifically the executed image (forfiles.exe) and command-line content containing the /c flag.
references:
  - https://lolbas-project.github.io/lolbas/Binaries/Forfiles/
  - https://pentestlab.blog/2020/07/06/indirect-command-execution/
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_forfiles_proxy_execution_.yml
author: Tim Rauch, Elastic, E.M. Anhaus (originally from Atomic Blue Detections, Endgame), oscd.community, Huntrule Team
date: 2022-06-14
modified: 2024-03-05
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_img:
    - Image|endswith: \forfiles.exe
    - OriginalFileName: forfiles.exe
  selection_cli:
    CommandLine|contains|windash: " -c "
  condition: all of selection_*
falsepositives:
  - Legitimate use via a batch script or by an administrator.
level: medium
license: DRL-1.1

What it detects

This rule flags process creation where forfiles.exe is launched with the /c option. Attackers can use this flag to proxy or indirectly execute commands, which may help bypass application control or whitelisting. It relies on Windows process creation telemetry, specifically the executed image (forfiles.exe) and command-line content containing the /c flag.

Known false positives

  • Legitimate use via a batch script or by an administrator.

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.