Creation of Hidden Files and Directories via CommandLine
Users can mark specific files as hidden simply by putting a "." as the first character in the file or folder name. Adversaries can use this to their advantage to hide files and folders on the system for persistence and defense evasion. This rule looks for hidden files or folders in common writable directories.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/04/29"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2026/10/08"
6
7[rule]
8author = ["Elastic"]
9description = """
10Users can mark specific files as hidden simply by putting a "." as the first character in the file or folder name.
11Adversaries can use this to their advantage to hide files and folders on the system for persistence and defense evasion.
12This rule looks for hidden files or folders in common writable directories.
13"""
14false_positives = [
15 """
16 Certain tools may create hidden temporary files or directories upon installation or as part of their normal
17 behavior. These events can be filtered by the process arguments, username, or process name values.
18 """,
19]
20from = "now-9m"
21index = ["logs-endpoint.events.process*"]
22language = "eql"
23license = "Elastic License v2"
24max_signals = 33
25name = "Creation of Hidden Files and Directories via CommandLine"
26risk_score = 21
27rule_id = "b9666521-4742-49ce-9ddc-b8e84c35acae"
28setup = """## Setup
29
30This rule requires data coming in from Elastic Defend.
31
32### Elastic Defend Integration Setup
33Elastic 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.
34
35#### Prerequisite Requirements:
36- Fleet is required for Elastic Defend.
37- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
38
39#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
40- Go to the Kibana home page and click "Add integrations".
41- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
42- Click "Add Elastic Defend".
43- Configure the integration name and optionally add a description.
44- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
45- 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).
46- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
47- 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.
48For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
49- Click "Save and Continue".
50- 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.
51For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
52"""
53severity = "low"
54tags = [
55 "Domain: Endpoint",
56 "OS: Linux",
57 "Use Case: Threat Detection",
58 "Tactic: Defense Evasion",
59 "Data Source: Elastic Defend",
60 "Resources: Investigation Guide",
61 "Noise: Low",
62 "Performance: Normal",
63 "Rule Type: Event Correlation (EQL)",
64 "Platform: Linux",
65]
66timestamp_override = "event.ingested"
67type = "eql"
68query = '''
69process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
70process.working_directory in ("/tmp", "/var/tmp", "/dev/shm") and
71process.args regex~ """\.[a-z0-9_\-][a-z0-9_\-\.]{1,254}""" and
72process.name like (
73 "touch", "tee", "cp", "mv", "install", "dd", "vi", "vim", "nano", "truncate", "sed", "awk", "curl", "wget",
74 "ftp", "scp", "rsync", "sftp", "tar", "unzip", "gunzip", "7z", "bzip2", "xz", "python*", "php*", "perl*",
75 "ruby*", "node*", "java", "printf", "echo", "cat", ".*"
76)
77'''
78note = """## Triage and analysis
79
80> **Disclaimer**:
81> 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.
82
83### Investigating Creation of Hidden Files and Directories via CommandLine
84
85In Linux environments, files and directories prefixed with a dot (.) are hidden by default, a feature often exploited by adversaries to conceal malicious activities. Attackers may create hidden files in writable directories like /tmp to evade detection. The detection rule identifies suspicious processes creating such hidden files, excluding benign commands, to flag potential threats. This helps in uncovering stealthy persistence and defense evasion tactics.
86
87### Possible investigation steps
88
89- Review the process details to identify the command executed, focusing on the process.working_directory field to confirm if the hidden file was created in a common writable directory like /tmp, /var/tmp, or /dev/shm.
90- Examine the process.args field to determine the specific hidden file or directory name created, and assess if it matches known malicious patterns or naming conventions.
91- Check the process lineage by investigating the parent process to understand the context of how the hidden file creation was initiated and identify any potential malicious parent processes.
92- Investigate the user account associated with the process to determine if it is a legitimate user or potentially compromised, and review recent activities by this user for any anomalies.
93- Search for any additional hidden files or directories created around the same time or by the same process to identify further suspicious activities or artifacts.
94- Correlate this event with other security alerts or logs from the same host to identify any related suspicious activities or patterns that could indicate a broader attack or compromise.
95
96### False positive analysis
97
98- System maintenance scripts may create hidden files in directories like /tmp for temporary storage. Review these scripts and consider excluding them if they are verified as non-threatening.
99- Development tools and processes, such as version control systems or build scripts, might generate hidden files for configuration or state tracking. Identify these tools and add them to the exclusion list if they are part of regular operations.
100- Monitoring and logging tools may use hidden files to store temporary data or logs. Verify these tools and exclude them if they are essential for system monitoring.
101- User-specific applications or scripts might create hidden files for legitimate purposes. Conduct a review of user activities and exclude known benign applications to reduce noise.
102- Automated backup or synchronization services could generate hidden files as part of their operation. Confirm these services and exclude them if they are part of the expected environment setup.
103
104### Response and remediation
105
106- Immediately isolate the affected system from the network to prevent further malicious activity or lateral movement.
107- Terminate any suspicious processes identified by the detection rule that are creating hidden files in the specified directories.
108- Remove any hidden files or directories created by unauthorized processes in the /tmp, /var/tmp, and /dev/shm directories to eliminate potential persistence mechanisms.
109- Conduct a thorough review of system logs and process execution history to identify any additional indicators of compromise or related malicious activities.
110- Restore any affected files or system components from a known good backup to ensure system integrity.
111- Escalate the incident to the security operations team for further analysis and to determine if additional systems are affected.
112- Implement enhanced monitoring and alerting for similar activities to improve detection and response capabilities for future incidents."""
113
114[[rule.threat]]
115framework = "MITRE ATT&CK"
116
117[[rule.threat.technique]]
118id = "T1564"
119name = "Hide Artifacts"
120reference = "https://attack.mitre.org/techniques/T1564/"
121
122[[rule.threat.technique.subtechnique]]
123id = "T1564.001"
124name = "Hidden Files and Directories"
125reference = "https://attack.mitre.org/techniques/T1564/001/"
126
127[rule.threat.tactic]
128id = "TA0005"
129name = "Defense Evasion"
130reference = "https://attack.mitre.org/tactics/TA0005/"
131
132[[rule.threat]]
133framework = "MITRE ATT&CK"
134
135[rule.threat.tactic]
136id = "TA0003"
137name = "Persistence"
138reference = "https://attack.mitre.org/tactics/TA0003/"
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 Creation of Hidden Files and Directories via CommandLine
In Linux environments, files and directories prefixed with a dot (.) are hidden by default, a feature often exploited by adversaries to conceal malicious activities. Attackers may create hidden files in writable directories like /tmp to evade detection. The detection rule identifies suspicious processes creating such hidden files, excluding benign commands, to flag potential threats. This helps in uncovering stealthy persistence and defense evasion tactics.
Possible investigation steps
- Review the process details to identify the command executed, focusing on the process.working_directory field to confirm if the hidden file was created in a common writable directory like /tmp, /var/tmp, or /dev/shm.
- Examine the process.args field to determine the specific hidden file or directory name created, and assess if it matches known malicious patterns or naming conventions.
- Check the process lineage by investigating the parent process to understand the context of how the hidden file creation was initiated and identify any potential malicious parent processes.
- Investigate the user account associated with the process to determine if it is a legitimate user or potentially compromised, and review recent activities by this user for any anomalies.
- Search for any additional hidden files or directories created around the same time or by the same process to identify further suspicious activities or artifacts.
- Correlate this event with other security alerts or logs from the same host to identify any related suspicious activities or patterns that could indicate a broader attack or compromise.
False positive analysis
- System maintenance scripts may create hidden files in directories like /tmp for temporary storage. Review these scripts and consider excluding them if they are verified as non-threatening.
- Development tools and processes, such as version control systems or build scripts, might generate hidden files for configuration or state tracking. Identify these tools and add them to the exclusion list if they are part of regular operations.
- Monitoring and logging tools may use hidden files to store temporary data or logs. Verify these tools and exclude them if they are essential for system monitoring.
- User-specific applications or scripts might create hidden files for legitimate purposes. Conduct a review of user activities and exclude known benign applications to reduce noise.
- Automated backup or synchronization services could generate hidden files as part of their operation. Confirm these services and exclude them if they are part of the expected environment setup.
Response and remediation
- Immediately isolate the affected system from the network to prevent further malicious activity or lateral movement.
- Terminate any suspicious processes identified by the detection rule that are creating hidden files in the specified directories.
- Remove any hidden files or directories created by unauthorized processes in the /tmp, /var/tmp, and /dev/shm directories to eliminate potential persistence mechanisms.
- Conduct a thorough review of system logs and process execution history to identify any additional indicators of compromise or related malicious activities.
- Restore any affected files or system components from a known good backup to ensure system integrity.
- Escalate the incident to the security operations team for further analysis and to determine if additional systems are affected.
- Implement enhanced monitoring and alerting for similar activities to improve detection and response capabilities for future incidents.
Related rules
- System Log File Deletion
- Masquerading Space After Filename
- GenAI Process Performing Encoding/Chunking Prior to Network Activity
- AppArmor Profile Compilation via apparmor_parser
- Attempt to Clear Kernel Ring Buffer