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"
5updated_date = "2024/10/17"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies file permission modifications in common writable directories by a non-root user. Adversaries often drop files
11or payloads into a writable directory and change permissions prior to execution.
12"""
13false_positives = [
14 """
15 Certain programs or applications may modify files or change ownership in writable directories. These can be exempted
16 by username.
17 """,
18]
19from = "now-9m"
20index = ["logs-endpoint.events.*"]
21language = "kuery"
22license = "Elastic License v2"
23name = "File Permission Modification in Writable Directory"
24risk_score = 21
25rule_id = "9f9a2a82-93a8-4b1a-8778-1780895626d4"
26setup = """## Setup
27
28This rule requires data coming in from one of the following integrations:
29- Elastic Defend
30- Auditbeat
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
53### Auditbeat Setup
54Auditbeat 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.
55
56#### The following steps should be executed in order to add the Auditbeat on a Linux System:
57- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
58- 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).
59- 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).
60- 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).
61- 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).
62"""
63severity = "low"
64tags = [
65 "Domain: Endpoint",
66 "OS: Linux",
67 "Use Case: Threat Detection",
68 "Tactic: Defense Evasion",
69 "Data Source: Elastic Defend",
70]
71timestamp_override = "event.ingested"
72type = "new_terms"
73
74query = '''
75host.os.type:linux and event.category:process and event.type:start and
76process.name:(chattr or chgrp or chmod or chown) and process.working_directory:(/dev/shm or /tmp or /var/tmp) and
77not process.parent.name:(apt-key or update-motd-updates-available or apt-get)
78'''
79
80
81[[rule.threat]]
82framework = "MITRE ATT&CK"
83[[rule.threat.technique]]
84id = "T1222"
85name = "File and Directory Permissions Modification"
86reference = "https://attack.mitre.org/techniques/T1222/"
87
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[[rule.new_terms.history_window_start]]
98field = "history_window_start"
99value = "now-14d"
Related rules
- Creation of Hidden Files and Directories via CommandLine
- Dynamic Linker Creation or Modification
- File made Immutable by Chattr
- System Binary Moved or Copied
- Attempt to Disable IPTables or Firewall