File Creation in World-Writable Directory by Unusual Process
This rule detects the creation of files in world-writable directories by an unusual process. Attackers may attempt to hide their activities by creating files in world-writable directories, which are commonly used for temporary file storage. This behavior is often associated with lateral movement and can be an indicator of an attacker attempting to move laterally within a network.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/04/09"
3integration = ["endpoint", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2026/04/09"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects the creation of files in world-writable directories by an unusual process. Attackers may
11attempt to hide their activities by creating files in world-writable directories, which are commonly used
12for temporary file storage. This behavior is often associated with lateral movement and can be an indicator
13of an attacker attempting to move laterally within a network.
14"""
15from = "now-9m"
16index = [
17 "endgame-*",
18 "logs-endpoint.events.file*",
19 "logs-sentinel_one_cloud_funnel.*",
20]
21language = "kuery"
22license = "Elastic License v2"
23name = "File Creation in World-Writable Directory by Unusual Process"
24note = """
25## Triage and analysis
26
27> **Disclaimer**:
28> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
29
30### Investigating File Creation in World-Writable Directory by Unusual Process
31
32This alert flags a Linux process that normally should not stage content in shared writable locations such as /tmp, /var/tmp, /run, or /dev/shm. Attackers abuse these directories because many users and services can write there, which makes payloads and helper scripts easier to hide; for example, a compromised shell may use curl or python to drop an ELF backdoor into /dev/shm and execute it from that transient path.
33
34### Possible investigation steps
35
36- Reconstruct the full process lineage and execution context around the file creation to determine whether it originated from an interactive session, scheduled task, container, service account, or a parent process already running from an unusual location.
37- Inspect the dropped file’s type, permissions, ownership, hash, and contents to assess whether it is a script, ELF, archive, or disguised payload, and determine if it was later executed, renamed, or moved to a more persistent path.
38- Correlate the alert with nearby authentication, privilege escalation, and network activity on the same host to identify signs of compromise such as recent SSH access, sudo use, remote command execution, or outbound connections to untrusted infrastructure.
39- Validate whether the activity aligns with known administrative or software deployment behavior by checking package ownership, change records, automation tooling, and host or user prevalence, since one-off staging in shared writable paths is more suspicious than common fleetwide behavior.
40
41### False positive analysis
42
43- Legitimate package installation, OS update, or local maintenance script activity can use interpreters or utilities such as cp, mv, chmod, curl, or python to stage temporary files in /tmp or /var/tmp before moving them into place, so verify whether the process tree, user, and event time align with expected system change or package management activity on the host.
44- Normal service startup or deployment automation may create transient files in /run or /dev/shm for configuration generation, caching, or runtime state, so confirm the file owner, contents, and parent process match a known application or boot-time workflow and that the same behavior is regularly seen on comparable systems.
45
46### Response and remediation
47- Isolate the affected Linux host from the network while preserving forensic access, stop the malicious process and any spawned tools, and collect copies of the dropped file before cleanup.
48- Remove attacker footholds by deleting the dropped file.
49- Restore the system to a known-good state by rebuilding from a trusted image or validated backup and verifying core packages, shell configuration files, scheduled tasks, and remote access settings match the approved baseline before reconnecting it.
50- Escalate to incident response immediately if the file creation was followed by privilege escalation, credential access, outbound tool downloads, lateral movement over SSH, or the same behavior is identified on multiple hosts, and expand scoping to related accounts and systems.
51"""
52references = ["https://www.rapid7.com/blog/post/tr-new-whitepaper-stealthy-bpfdoor-variants/"]
53risk_score = 47
54rule_id = "1f56f548-94ec-4678-b1ed-b1a14cca4e3a"
55setup = """## Setup
56
57This rule requires data coming in from Elastic Defend.
58
59### Elastic Defend Integration Setup
60Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
61
62#### Prerequisite Requirements:
63- Fleet is required for Elastic Defend.
64- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
65
66#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
67- Go to the Kibana home page and click "Add integrations".
68- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
69- Click "Add Elastic Defend".
70- Configure the integration name and optionally add a description.
71- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
72- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
73- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
74- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
75For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
76- Click "Save and Continue".
77- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
78For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
79"""
80severity = "medium"
81tags = [
82 "Domain: Endpoint",
83 "OS: Linux",
84 "Use Case: Threat Detection",
85 "Tactic: Defense Evasion",
86 "Data Source: Elastic Defend",
87 "Data Source: Elastic Endgame",
88 "Data Source: SentinelOne",
89 "Resources: Investigation Guide",
90]
91timestamp_override = "event.ingested"
92type = "new_terms"
93query = '''
94host.os.type:linux and event.category:file and event.type:creation and (
95 process.name:(
96 "cp" or "mv" or "chmod" or "chown" or "chattr" or "chgrp" or "curl" or "wget" or "timeout" or
97 "env" or "node" or "deno" or "nodejs" or .* or python* or perl* or ruby* or php* or lua*
98 ) or
99 process.executable:(
100 ./* or /tmp/* or /var/tmp/* or /dev/shm/* or /run/* or /var/run/* or /boot/* or /sys/* or
101 /lost+found/* or /proc/* or /var/mail/* or /var/www/*
102 )
103) and
104file.path:(/run/* or /var/run/* or /dev/shm/* or /tmp/* or /var/tmp/*) and
105not (
106 file.path:(
107 /var/tmp/dracut.* or /var/tmp/mkinitramfs_* or /tmp/.*-00000000.so or /run/udev/rules.d/* or
108 /tmp/new_root/* or /tmp/newroot/* or /run/user/*/.bubblewrap/newroot/* or /tmp/tmp.*/docker-scout_* or
109 /var/tmp/portage/* or /tmp/yarn--* or /run/k3s/containerd/* or /var/tmp/pamac-build-* or
110 /tmp/mkinitcpio* or /run/user/*/netns/netns-*
111 ) or
112 file.extension:("json" or "txt")
113)
114'''
115
116[[rule.threat]]
117framework = "MITRE ATT&CK"
118
119[[rule.threat.technique]]
120id = "T1222"
121name = "File and Directory Permissions Modification"
122reference = "https://attack.mitre.org/techniques/T1222/"
123
124[[rule.threat.technique.subtechnique]]
125id = "T1222.002"
126name = "Linux and Mac File and Directory Permissions Modification"
127reference = "https://attack.mitre.org/techniques/T1222/002/"
128
129[rule.threat.tactic]
130id = "TA0005"
131name = "Defense Evasion"
132reference = "https://attack.mitre.org/tactics/TA0005/"
133
134[rule.new_terms]
135field = "new_terms_fields"
136value = ["host.id", "process.executable", "file.path"]
137
138[[rule.new_terms.history_window_start]]
139field = "history_window_start"
140value = "now-5d"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating File Creation in World-Writable Directory by Unusual Process
This alert flags a Linux process that normally should not stage content in shared writable locations such as /tmp, /var/tmp, /run, or /dev/shm. Attackers abuse these directories because many users and services can write there, which makes payloads and helper scripts easier to hide; for example, a compromised shell may use curl or python to drop an ELF backdoor into /dev/shm and execute it from that transient path.
Possible investigation steps
- Reconstruct the full process lineage and execution context around the file creation to determine whether it originated from an interactive session, scheduled task, container, service account, or a parent process already running from an unusual location.
- Inspect the dropped file’s type, permissions, ownership, hash, and contents to assess whether it is a script, ELF, archive, or disguised payload, and determine if it was later executed, renamed, or moved to a more persistent path.
- Correlate the alert with nearby authentication, privilege escalation, and network activity on the same host to identify signs of compromise such as recent SSH access, sudo use, remote command execution, or outbound connections to untrusted infrastructure.
- Validate whether the activity aligns with known administrative or software deployment behavior by checking package ownership, change records, automation tooling, and host or user prevalence, since one-off staging in shared writable paths is more suspicious than common fleetwide behavior.
False positive analysis
- Legitimate package installation, OS update, or local maintenance script activity can use interpreters or utilities such as cp, mv, chmod, curl, or python to stage temporary files in /tmp or /var/tmp before moving them into place, so verify whether the process tree, user, and event time align with expected system change or package management activity on the host.
- Normal service startup or deployment automation may create transient files in /run or /dev/shm for configuration generation, caching, or runtime state, so confirm the file owner, contents, and parent process match a known application or boot-time workflow and that the same behavior is regularly seen on comparable systems.
Response and remediation
- Isolate the affected Linux host from the network while preserving forensic access, stop the malicious process and any spawned tools, and collect copies of the dropped file before cleanup.
- Remove attacker footholds by deleting the dropped file.
- Restore the system to a known-good state by rebuilding from a trusted image or validated backup and verifying core packages, shell configuration files, scheduled tasks, and remote access settings match the approved baseline before reconnecting it.
- Escalate to incident response immediately if the file creation was followed by privilege escalation, credential access, outbound tool downloads, lateral movement over SSH, or the same behavior is identified on multiple hosts, and expand scoping to related accounts and systems.
References
Related rules
- Data Encrypted via OpenSSL Utility
- Attempt to Disable Auditd Service
- Attempt to Disable IPTables or Firewall
- Attempt to Disable Syslog Service
- BPF Program Tampering via bpftool