Hidden Directory Creation via Unusual Parent

This rule detects the creation of a hidden directory via an unusual parent executable. Hidden directories are directories that are not visible to the user by default. They are often used by attackers to hide malicious files or tools.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/11/01"
  3integration = ["endpoint", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2025/03/20"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects the creation of a hidden directory via an unusual parent executable. Hidden directories are
 11directories that are not visible to the user by default. They are often used by attackers to hide malicious files or
 12tools.
 13"""
 14false_positives = [
 15    """
 16    Certain tools may create hidden temporary directories upon installation or as part of their normal behavior. These
 17    events can be filtered by the process arguments, username, or process name values.
 18    """,
 19]
 20from = "now-9m"
 21index = ["endgame-*", "logs-endpoint.events.process*", "logs-sentinel_one_cloud_funnel.*"]
 22language = "eql"
 23license = "Elastic License v2"
 24name = "Hidden Directory Creation via Unusual Parent"
 25note = """## 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 Hidden Directory Creation via Unusual Parent
 31
 32In Linux environments, hidden directories, often prefixed with a dot, are typically used for configuration files but can be exploited by attackers to conceal malicious activities. Adversaries may create these directories using unexpected parent processes in sensitive locations. The detection rule identifies such anomalies by monitoring directory creation commands executed by unusual parent executables, focusing on specific directories and excluding known benign patterns.
 33
 34### Possible investigation steps
 35
 36- Review the process.parent.executable field to identify the parent process that initiated the directory creation and assess its legitimacy based on its typical behavior and location.
 37- Examine the process.args field to understand the specific arguments used with the mkdir command, focusing on the directory path and any patterns that may indicate malicious intent.
 38- Check the process.command_line field for any unusual or suspicious command-line patterns that might suggest an attempt to evade detection.
 39- Investigate the context of the parent process by reviewing recent activities or logs associated with it, especially if it originates from sensitive directories like /dev/shm, /tmp, or /var/tmp.
 40- Correlate the alert with other security events or logs from the same host to identify any related suspicious activities or patterns that could indicate a broader attack or compromise.
 41- Consult threat intelligence sources or databases to determine if the parent executable or directory path has been associated with known malicious activities or threat actors.
 42
 43### False positive analysis
 44
 45- Temporary directories used by legitimate applications can trigger false positives. Exclude known benign parent executables like those in "/tmp/newroot/*" or "/run/containerd/*" to reduce noise.
 46- Automated build processes may create hidden directories during software compilation. Add exceptions for parent executables such as "/var/tmp/buildah*" or "/tmp/python-build.*" to prevent unnecessary alerts.
 47- Development tools and scripts might create hidden directories for caching or temporary storage. Consider excluding parent executables like "/tmp/pear/temp/*" or "/tmp/cliphist-wofi-img" if they are part of regular development activities.
 48- Ensure that the command line patterns like "mkdir -p ." or "mkdir ./*" are excluded, as these are common in scripts and do not typically indicate malicious intent.
 49- Regularly review and update the list of excluded patterns and parent executables to align with changes in the environment and reduce false positives effectively.
 50
 51### Response and remediation
 52
 53- Isolate the affected system from the network to prevent further malicious activity and lateral movement.
 54- Terminate any suspicious processes associated with the unusual parent executable identified in the alert to halt potential malicious operations.
 55- Conduct a thorough review of the hidden directory and its contents to identify and remove any malicious files or tools.
 56- Restore any affected files or configurations from a known good backup to ensure system integrity.
 57- Implement stricter access controls and monitoring on sensitive directories to prevent unauthorized directory creation.
 58- Escalate the incident to the security operations team for further investigation and to determine if additional systems are compromised.
 59- Update and enhance endpoint detection and response (EDR) solutions to improve detection capabilities for similar threats in the future."""
 60risk_score = 21
 61rule_id = "b15a15f2-becf-475d-aa69-45c9e0ff1c49"
 62setup = """## Setup
 63
 64This rule requires data coming in from Elastic Defend.
 65
 66### Elastic Defend Integration Setup
 67Elastic 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.
 68
 69#### Prerequisite Requirements:
 70- Fleet is required for Elastic Defend.
 71- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 72
 73#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 74- Go to the Kibana home page and click "Add integrations".
 75- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 76- Click "Add Elastic Defend".
 77- Configure the integration name and optionally add a description.
 78- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 79- 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).
 80- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 81- 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.
 82For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 83- Click "Save and Continue".
 84- 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.
 85For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 86"""
 87severity = "low"
 88tags = [
 89    "Domain: Endpoint",
 90    "OS: Linux",
 91    "Use Case: Threat Detection",
 92    "Tactic: Defense Evasion",
 93    "Data Source: Elastic Defend",
 94    "Tactic: Persistence",
 95    "Data Source: SentinelOne",
 96    "Data Source: Elastic Endgame",
 97    "Resources: Investigation Guide",
 98]
 99timestamp_override = "event.ingested"
100type = "eql"
101
102query = '''
103process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "start", "exec_event") and
104process.name == "mkdir" and process.parent.executable like (
105  "/dev/shm/*", "/tmp/*", "/var/tmp/*", "/var/run/*", "/root/*", "/boot/*", "/var/www/html/*", "/opt/.*"
106) and process.args like (".*", "/*/.*") and process.args_count <= 3 and not (
107  process.parent.executable like ("/tmp/newroot/*", "/run/containerd/*") or
108  process.command_line like ("mkdir -p .", "mkdir ./*") or
109  process.args == "/root/.ssh" or
110  process.parent.executable like (
111    "/tmp/pear/temp/*", "/var/tmp/buildah*", "/tmp/python-build.*", "/tmp/cliphist-wofi-img", "/tmp/snap.rootfs_*"
112  )
113)
114'''
115
116
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119[[rule.threat.technique]]
120id = "T1564"
121name = "Hide Artifacts"
122reference = "https://attack.mitre.org/techniques/T1564/"
123[[rule.threat.technique.subtechnique]]
124id = "T1564.001"
125name = "Hidden Files and Directories"
126reference = "https://attack.mitre.org/techniques/T1564/001/"
127
128
129
130[rule.threat.tactic]
131id = "TA0005"
132name = "Defense Evasion"
133reference = "https://attack.mitre.org/tactics/TA0005/"
134[[rule.threat]]
135framework = "MITRE ATT&CK"
136
137[rule.threat.tactic]
138id = "TA0003"
139name = "Persistence"
140reference = "https://attack.mitre.org/tactics/TA0003/"
...
toml

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.

In Linux environments, hidden directories, often prefixed with a dot, are typically used for configuration files but can be exploited by attackers to conceal malicious activities. Adversaries may create these directories using unexpected parent processes in sensitive locations. The detection rule identifies such anomalies by monitoring directory creation commands executed by unusual parent executables, focusing on specific directories and excluding known benign patterns.

  • Review the process.parent.executable field to identify the parent process that initiated the directory creation and assess its legitimacy based on its typical behavior and location.
  • Examine the process.args field to understand the specific arguments used with the mkdir command, focusing on the directory path and any patterns that may indicate malicious intent.
  • Check the process.command_line field for any unusual or suspicious command-line patterns that might suggest an attempt to evade detection.
  • Investigate the context of the parent process by reviewing recent activities or logs associated with it, especially if it originates from sensitive directories like /dev/shm, /tmp, or /var/tmp.
  • Correlate the alert with other security events or logs from the same host to identify any related suspicious activities or patterns that could indicate a broader attack or compromise.
  • Consult threat intelligence sources or databases to determine if the parent executable or directory path has been associated with known malicious activities or threat actors.
  • Temporary directories used by legitimate applications can trigger false positives. Exclude known benign parent executables like those in "/tmp/newroot/" or "/run/containerd/" to reduce noise.
  • Automated build processes may create hidden directories during software compilation. Add exceptions for parent executables such as "/var/tmp/buildah*" or "/tmp/python-build.*" to prevent unnecessary alerts.
  • Development tools and scripts might create hidden directories for caching or temporary storage. Consider excluding parent executables like "/tmp/pear/temp/*" or "/tmp/cliphist-wofi-img" if they are part of regular development activities.
  • Ensure that the command line patterns like "mkdir -p ." or "mkdir ./*" are excluded, as these are common in scripts and do not typically indicate malicious intent.
  • Regularly review and update the list of excluded patterns and parent executables to align with changes in the environment and reduce false positives effectively.
  • Isolate the affected system from the network to prevent further malicious activity and lateral movement.
  • Terminate any suspicious processes associated with the unusual parent executable identified in the alert to halt potential malicious operations.
  • Conduct a thorough review of the hidden directory and its contents to identify and remove any malicious files or tools.
  • Restore any affected files or configurations from a known good backup to ensure system integrity.
  • Implement stricter access controls and monitoring on sensitive directories to prevent unauthorized directory creation.
  • Escalate the incident to the security operations team for further investigation and to determine if additional systems are compromised.
  • Update and enhance endpoint detection and response (EDR) solutions to improve detection capabilities for similar threats in the future.

Related rules

to-top