Command Execution via ForFiles
Detects attempts to execute a command via the forfiles Windows utility. Adversaries may use this utility to proxy execution via a trusted parent process.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/02/03"
3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
4maturity = "production"
5updated_date = "2025/02/21"
6min_stack_version = "8.14.0"
7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
8
9[rule]
10author = ["Elastic"]
11description = """
12Detects attempts to execute a command via the forfiles Windows utility. Adversaries may use this utility to proxy execution via
13a trusted parent process.
14"""
15from = "now-9m"
16index = [
17 "endgame-*",
18 "logs-crowdstrike.fdr*",
19 "logs-endpoint.events.process-*",
20 "logs-m365_defender.event-*",
21 "logs-sentinel_one_cloud_funnel.*",
22 "logs-system.security*",
23 "logs-windows.forwarded*",
24 "logs-windows.sysmon_operational-*",
25 "winlogbeat-*",
26]
27language = "eql"
28license = "Elastic License v2"
29name = "Command Execution via ForFiles"
30note = """## Triage and analysis
31
32### Investigating Command Execution via ForFiles
33
34### Possible investigation steps
35
36- Identify the user account that performed the action and whether it should perform this kind of action.
37- Contact the account owner and confirm whether they are aware of this activity.
38- Investigate other alerts associated with the user/host during the past 48 hours.
39- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
40- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
41
42### False positive analysis
43
44- This is a dual-use tool, meaning its usage is not inherently malicious. Analysts can dismiss the alert if the administrator is aware of the activity, no other suspicious activity was identified.
45
46### Response and Remediation
47
48- Initiate the incident response process based on the outcome of the triage.
49- Isolate the involved host to prevent further post-compromise behavior.
50- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
51- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
52- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
53- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
54"""
55references = ["https://lolbas-project.github.io/lolbas/Binaries/Forfiles/"]
56risk_score = 47
57rule_id = "3f7bd5ac-9711-44b4-82c1-fa246d829f15"
58severity = "medium"
59tags = [
60 "Domain: Endpoint",
61 "OS: Windows",
62 "Use Case: Threat Detection",
63 "Tactic: Defense Evasion",
64 "Data Source: Elastic Endgame",
65 "Data Source: Elastic Defend",
66 "Data Source: Windows Security Event Logs",
67 "Data Source: Microsoft Defender for Endpoint",
68 "Data Source: Sysmon",
69 "Data Source: SentinelOne",
70 "Data Source: Crowdstrike",
71 "Resources: Investigation Guide",
72]
73timestamp_override = "event.ingested"
74type = "eql"
75
76query = '''
77process where host.os.type == "windows" and event.type == "start" and
78 (process.name : "forfiles.exe" or ?process.pe.original_file_name == "forfiles.exe") and process.args : ("/c", "-c")
79'''
80
81
82[[rule.threat]]
83framework = "MITRE ATT&CK"
84[[rule.threat.technique]]
85id = "T1202"
86name = "Indirect Command Execution"
87reference = "https://attack.mitre.org/techniques/T1202/"
88
89
90[rule.threat.tactic]
91id = "TA0005"
92name = "Defense Evasion"
93reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Investigating Command Execution via ForFiles
Possible investigation steps
- Identify the user account that performed the action and whether it should perform this kind of action.
- Contact the account owner and confirm whether they are aware of this activity.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
False positive analysis
- This is a dual-use tool, meaning its usage is not inherently malicious. Analysts can dismiss the alert if the administrator is aware of the activity, no other suspicious activity was identified.
Response and Remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Adding Hidden File Attribute via Attrib
- Attempt to Install Kali Linux via WSL
- Bypass UAC via Event Viewer
- Clearing Windows Console History
- Clearing Windows Event Logs