File Permission Modification in Writable Directory

Identifies file permission modifications in common writable directories by a non-root user. Adversaries often drop files or payloads into a writable directory and change permissions prior to execution.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/04/21"
  3integration = ["endpoint"]
  4maturity = "production"
  5min_stack_comments = "Multiple field support in the New Terms rule type was added in Elastic 8.6"
  6min_stack_version = "8.6.0"
  7updated_date = "2024/02/20"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies file permission modifications in common writable directories by a non-root user. Adversaries often drop files
 13or payloads into a writable directory and change permissions prior to execution.
 14"""
 15false_positives = [
 16    """
 17    Certain programs or applications may modify files or change ownership in writable directories. These can be exempted
 18    by username.
 19    """,
 20]
 21from = "now-9m"
 22index = ["logs-endpoint.events.*"]
 23language = "kuery"
 24license = "Elastic License v2"
 25name = "File Permission Modification in Writable Directory"
 26risk_score = 21
 27rule_id = "9f9a2a82-93a8-4b1a-8778-1780895626d4"
 28setup = """## Setup
 29
 30This rule requires data coming in from one of the following integrations:
 31- Elastic Defend
 32- Auditbeat
 33
 34### Elastic Defend Integration Setup
 35Elastic 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.
 36
 37#### Prerequisite Requirements:
 38- Fleet is required for Elastic Defend.
 39- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 40
 41#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 42- Go to the Kibana home page and click "Add integrations".
 43- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 44- Click "Add Elastic Defend".
 45- Configure the integration name and optionally add a description.
 46- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 47- 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).
 48- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 49- 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.
 50For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 51- Click "Save and Continue".
 52- 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.
 53For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 54
 55### Auditbeat Setup
 56Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
 57
 58#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 59- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 60- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
 61- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
 62- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
 63- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
 64"""
 65severity = "low"
 66tags = [
 67        "Domain: Endpoint",
 68        "OS: Linux",
 69        "Use Case: Threat Detection",
 70        "Tactic: Defense Evasion",
 71        "Data Source: Elastic Defend"
 72        ]
 73timestamp_override = "event.ingested"
 74type = "new_terms"
 75query = '''
 76host.os.type:linux and event.category:process and event.type:start and
 77process.name:(chattr or chgrp or chmod or chown) and process.working_directory:(/dev/shm or /tmp or /var/tmp) and
 78not process.parent.name:(apt-key or update-motd-updates-available)
 79'''
 80
 81[[rule.threat]]
 82framework = "MITRE ATT&CK"
 83
 84[[rule.threat.technique]]
 85id = "T1222"
 86name = "File and Directory Permissions Modification"
 87reference = "https://attack.mitre.org/techniques/T1222/"
 88
 89[rule.threat.tactic]
 90id = "TA0005"
 91name = "Defense Evasion"
 92reference = "https://attack.mitre.org/tactics/TA0005/"
 93
 94[rule.new_terms]
 95field = "new_terms_fields"
 96value = ["host.id", "process.parent.executable", "process.command_line"]
 97
 98[[rule.new_terms.history_window_start]]
 99field = "history_window_start"
100value = "now-14d"

Related rules

to-top