System Binary Path File Permission Modification
This rule identifies file permission modification events on files located in common system binary paths. Adversaries may attempt to hide their payloads in the default Linux system directories, and modify the file permissions of these payloads prior to execution.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/01/07"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/01/22"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule identifies file permission modification events on files located in common system binary paths. Adversaries may attempt to
11hide their payloads in the default Linux system directories, and modify the file permissions of these payloads prior to execution.
12"""
13from = "now-9m"
14index = ["logs-endpoint.events.*"]
15language = "eql"
16license = "Elastic License v2"
17name = "System Binary Path File Permission Modification"
18references = ["https://blog.exatrack.com/Perfctl-using-portainer-and-new-persistences/"]
19risk_score = 21
20rule_id = "0049cf71-fe13-4d79-b767-f7519921ffb5"
21setup = """## Setup
22
23This rule requires data coming in from Elastic Defend.
24
25### Elastic Defend Integration Setup
26Elastic 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.
27
28#### Prerequisite Requirements:
29- Fleet is required for Elastic Defend.
30- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
31
32#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
33- Go to the Kibana home page and click "Add integrations".
34- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
35- Click "Add Elastic Defend".
36- Configure the integration name and optionally add a description.
37- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
38- 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).
39- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
40- 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.
41For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
42- Click "Save and Continue".
43- 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.
44For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
45"""
46severity = "low"
47tags = [
48 "Domain: Endpoint",
49 "OS: Linux",
50 "Use Case: Threat Detection",
51 "Tactic: Execution",
52 "Data Source: Elastic Defend",
53 "Resources: Investigation Guide",
54]
55timestamp_override = "event.ingested"
56type = "eql"
57
58query = '''
59process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name in ("chmod", "chown") and
60process.args like~ (
61 "/bin/*", "/usr/bin/*", "/usr/local/bin/*", "/sbin/*", "/usr/sbin/*", "/usr/local/sbin/*",
62 "/lib/*", "/usr/lib/*", "/lib64/*", "/usr/lib64/*"
63) and
64process.args in ("4755", "755", "000", "777", "444", "-x", "+x") and not (
65 process.args in ("/bin/chmod", "/usr/bin/chmod", "/usr/local/bin/chmod") or
66 process.parent.executable like~ ("/tmp/newroot/*", "/var/lib/dpkg/info/*") or
67 process.parent.name in ("udevadm", "systemd", "entrypoint", "sudo", "dart") or
68 process.parent.command_line == "runc init" or
69 process.parent.args like "/var/tmp/rpm-tmp.*"
70)
71'''
72note = """## Triage and analysis
73
74> **Disclaimer**:
75> 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.
76
77### Investigating System Binary Path File Permission Modification
78
79In Linux environments, system binary paths contain critical executables. Adversaries may exploit these by altering file permissions to execute malicious payloads. The detection rule monitors processes like `chmod` and `chown` in key directories, flagging suspicious permission changes. It excludes benign activities, focusing on unauthorized modifications to prevent potential execution of harmful scripts.
80
81### Possible investigation steps
82
83- Review the process details to identify the exact command executed, focusing on the process name and arguments, especially those involving `chmod` or `chown` in critical directories like `/bin`, `/usr/bin`, and `/lib`.
84- Examine the parent process information, including the executable path and command line, to determine if the process was initiated by a known or trusted application, excluding those like `udevadm`, `systemd`, or `sudo`.
85- Check the user account associated with the process to verify if the action was performed by an authorized user or if there are signs of compromised credentials.
86- Investigate the file or directory whose permissions were modified to assess its importance and potential impact, focusing on changes to permissions like `4755`, `755`, or `777`.
87- Correlate the event with other security alerts or logs to identify any related suspicious activities, such as unauthorized access attempts or unexpected script executions.
88- Review recent changes or updates in the system that might explain the permission modification, ensuring they align with legitimate administrative tasks or software installations.
89
90### False positive analysis
91
92- System updates and package installations often involve legitimate permission changes in system binary paths. Users can exclude processes with parent executables located in directories like /var/lib/dpkg/info to reduce noise from these activities.
93- Administrative scripts or automation tools may execute chmod or chown commands as part of routine maintenance. Exclude processes with parent names such as udevadm, systemd, or sudo to prevent these from being flagged.
94- Container initialization processes might trigger permission changes. Exclude processes with parent command lines like runc init to avoid false positives related to container setups.
95- Temporary script executions during software installations can cause permission modifications. Exclude processes with parent arguments matching patterns like /var/tmp/rpm-tmp.* to filter out these benign events.
96
97### Response and remediation
98
99- Immediately isolate the affected system from the network to prevent further unauthorized access or execution of malicious payloads.
100- Terminate any suspicious processes identified as executing `chmod` or `chown` commands in critical system binary paths.
101- Revert any unauthorized file permission changes to their original state to ensure system integrity and prevent execution of malicious scripts.
102- Conduct a thorough review of system logs and process execution history to identify any additional unauthorized activities or related threats.
103- Escalate the incident to the security operations team for further investigation and to determine if the threat has spread to other systems.
104- Implement additional monitoring on the affected system and similar environments to detect any recurrence of unauthorized permission modifications.
105- Review and update access controls and permissions policies to minimize the risk of unauthorized modifications in critical system directories."""
106
107[[rule.threat]]
108framework = "MITRE ATT&CK"
109
110[[rule.threat.technique]]
111id = "T1059"
112name = "Command and Scripting Interpreter"
113reference = "https://attack.mitre.org/techniques/T1059/"
114
115[rule.threat.tactic]
116id = "TA0002"
117name = "Execution"
118reference = "https://attack.mitre.org/tactics/TA0002/"
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 System Binary Path File Permission Modification
In Linux environments, system binary paths contain critical executables. Adversaries may exploit these by altering file permissions to execute malicious payloads. The detection rule monitors processes like chmod
and chown
in key directories, flagging suspicious permission changes. It excludes benign activities, focusing on unauthorized modifications to prevent potential execution of harmful scripts.
Possible investigation steps
- Review the process details to identify the exact command executed, focusing on the process name and arguments, especially those involving
chmod
orchown
in critical directories like/bin
,/usr/bin
, and/lib
. - Examine the parent process information, including the executable path and command line, to determine if the process was initiated by a known or trusted application, excluding those like
udevadm
,systemd
, orsudo
. - Check the user account associated with the process to verify if the action was performed by an authorized user or if there are signs of compromised credentials.
- Investigate the file or directory whose permissions were modified to assess its importance and potential impact, focusing on changes to permissions like
4755
,755
, or777
. - Correlate the event with other security alerts or logs to identify any related suspicious activities, such as unauthorized access attempts or unexpected script executions.
- Review recent changes or updates in the system that might explain the permission modification, ensuring they align with legitimate administrative tasks or software installations.
False positive analysis
- System updates and package installations often involve legitimate permission changes in system binary paths. Users can exclude processes with parent executables located in directories like /var/lib/dpkg/info to reduce noise from these activities.
- Administrative scripts or automation tools may execute chmod or chown commands as part of routine maintenance. Exclude processes with parent names such as udevadm, systemd, or sudo to prevent these from being flagged.
- Container initialization processes might trigger permission changes. Exclude processes with parent command lines like runc init to avoid false positives related to container setups.
- Temporary script executions during software installations can cause permission modifications. Exclude processes with parent arguments matching patterns like /var/tmp/rpm-tmp.* to filter out these benign events.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or execution of malicious payloads.
- Terminate any suspicious processes identified as executing
chmod
orchown
commands in critical system binary paths. - Revert any unauthorized file permission changes to their original state to ensure system integrity and prevent execution of malicious scripts.
- Conduct a thorough review of system logs and process execution history to identify any additional unauthorized activities or related threats.
- Escalate the incident to the security operations team for further investigation and to determine if the threat has spread to other systems.
- Implement additional monitoring on the affected system and similar environments to detect any recurrence of unauthorized permission modifications.
- Review and update access controls and permissions policies to minimize the risk of unauthorized modifications in critical system directories.
References
Related rules
- AWS SSM `SendCommand` with Run Shell Command Parameters
- At Job Created or Modified
- BPF filter applied using TC
- Binary Executed from Shared Memory Directory
- Cron Job Created or Modified