Potential Suspicious DebugFS Root Device Access
This rule monitors for the usage of the built-in Linux DebugFS utility to access a disk device without root permissions. Linux users that are part of the "disk" group have sufficient privileges to access all data inside of the machine through DebugFS. Attackers may leverage DebugFS in conjunction with "disk" permissions to read sensitive files owned by root, such as the shadow file, root ssh private keys or other sensitive files that may allow them to further escalate privileges.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/08/30"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/01/15"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule monitors for the usage of the built-in Linux DebugFS utility to access a disk device without root permissions.
11Linux users that are part of the "disk" group have sufficient privileges to access all data inside of the machine
12through DebugFS. Attackers may leverage DebugFS in conjunction with "disk" permissions to read sensitive files owned by
13root, such as the shadow file, root ssh private keys or other sensitive files that may allow them to further escalate
14privileges.
15"""
16from = "now-9m"
17index = ["logs-endpoint.events.*"]
18language = "eql"
19license = "Elastic License v2"
20name = "Potential Suspicious DebugFS Root Device Access"
21references = [
22 "https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe#disk-group",
23]
24risk_score = 21
25rule_id = "2605aa59-29ac-4662-afad-8d86257c7c91"
26setup = """## Setup
27
28This rule requires data coming in from Elastic Defend.
29
30### Elastic Defend Integration Setup
31Elastic 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.
32
33#### Prerequisite Requirements:
34- Fleet is required for Elastic Defend.
35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
36
37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
38- Go to the Kibana home page and click "Add integrations".
39- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
40- Click "Add Elastic Defend".
41- Configure the integration name and optionally add a description.
42- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
43- 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).
44- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
45- 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.
46For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
47- Click "Save and Continue".
48- 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.
49For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
50"""
51severity = "low"
52tags = [
53 "Domain: Endpoint",
54 "OS: Linux",
55 "Use Case: Threat Detection",
56 "Tactic: Privilege Escalation",
57 "Data Source: Elastic Defend",
58 "Resources: Investigation Guide",
59]
60timestamp_override = "event.ingested"
61type = "eql"
62
63query = '''
64process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
65process.name == "debugfs" and process.args : "/dev/sd*" and not process.args == "-R" and
66not user.Ext.real.id == "0" and not group.Ext.real.id == "0"
67'''
68note = """## Triage and analysis
69
70> **Disclaimer**:
71> 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.
72
73### Investigating Potential Suspicious DebugFS Root Device Access
74
75DebugFS is a Linux utility that provides a low-level interface to access and manipulate file systems, typically used for debugging purposes. It can be exploited by adversaries with "disk" group privileges to access sensitive files without root permissions, potentially leading to privilege escalation. The detection rule identifies non-root users executing DebugFS on disk devices, flagging potential unauthorized access attempts.
76
77### Possible investigation steps
78
79- Review the process execution details to identify the non-root user and group involved in the DebugFS execution by examining the user.Ext.real.id and group.Ext.real.id fields.
80- Check the command-line arguments (process.args) to determine which specific disk device was accessed and assess if the access was legitimate or necessary for the user's role.
81- Investigate the user's recent activity and login history to identify any unusual patterns or unauthorized access attempts that might indicate malicious intent.
82- Verify the user's group memberships, particularly focusing on the "disk" group, to understand if the user should have such privileges and if any recent changes were made to their group assignments.
83- Examine system logs and other security alerts around the time of the DebugFS execution to identify any correlated suspicious activities or potential indicators of compromise.
84- Assess the system for any unauthorized changes or access to sensitive files, such as the shadow file or root SSH keys, which could indicate privilege escalation attempts.
85
86### False positive analysis
87
88- Non-root system administrators or maintenance scripts may use DebugFS for legitimate disk diagnostics or recovery tasks. To handle this, identify and whitelist specific users or scripts that are known to perform these tasks regularly.
89- Automated backup or monitoring tools might invoke DebugFS as part of their operations. Review and exclude these tools by adding their process identifiers or user accounts to an exception list.
90- Developers or testers with disk group privileges might use DebugFS during development or testing phases. Establish a policy to document and approve such activities, and exclude these users from triggering alerts.
91- Educational or training environments where DebugFS is used for learning purposes can generate false positives. Create exceptions for these environments by specifying the associated user accounts or groups.
92
93### Response and remediation
94
95- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
96- Revoke "disk" group privileges from non-essential users to limit access to disk devices and prevent misuse of DebugFS.
97- Conduct a thorough review of user accounts and group memberships to ensure only authorized personnel have "disk" group privileges.
98- Check for unauthorized access to sensitive files such as the shadow file or root SSH private keys and reset credentials if necessary.
99- Monitor for any additional suspicious activity on the affected system and related systems, focusing on privilege escalation attempts.
100- Escalate the incident to the security operations team for further investigation and to determine if additional systems are compromised.
101- Implement enhanced logging and monitoring for DebugFS usage and access to disk devices to detect similar threats in the future."""
102
103[[rule.threat]]
104framework = "MITRE ATT&CK"
105
106[[rule.threat.technique]]
107id = "T1078"
108name = "Valid Accounts"
109reference = "https://attack.mitre.org/techniques/T1078/"
110
111[[rule.threat.technique.subtechnique]]
112id = "T1078.003"
113name = "Local Accounts"
114reference = "https://attack.mitre.org/techniques/T1078/003/"
115
116[rule.threat.tactic]
117id = "TA0004"
118name = "Privilege Escalation"
119reference = "https://attack.mitre.org/tactics/TA0004/"
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 Potential Suspicious DebugFS Root Device Access
DebugFS is a Linux utility that provides a low-level interface to access and manipulate file systems, typically used for debugging purposes. It can be exploited by adversaries with "disk" group privileges to access sensitive files without root permissions, potentially leading to privilege escalation. The detection rule identifies non-root users executing DebugFS on disk devices, flagging potential unauthorized access attempts.
Possible investigation steps
- Review the process execution details to identify the non-root user and group involved in the DebugFS execution by examining the user.Ext.real.id and group.Ext.real.id fields.
- Check the command-line arguments (process.args) to determine which specific disk device was accessed and assess if the access was legitimate or necessary for the user's role.
- Investigate the user's recent activity and login history to identify any unusual patterns or unauthorized access attempts that might indicate malicious intent.
- Verify the user's group memberships, particularly focusing on the "disk" group, to understand if the user should have such privileges and if any recent changes were made to their group assignments.
- Examine system logs and other security alerts around the time of the DebugFS execution to identify any correlated suspicious activities or potential indicators of compromise.
- Assess the system for any unauthorized changes or access to sensitive files, such as the shadow file or root SSH keys, which could indicate privilege escalation attempts.
False positive analysis
- Non-root system administrators or maintenance scripts may use DebugFS for legitimate disk diagnostics or recovery tasks. To handle this, identify and whitelist specific users or scripts that are known to perform these tasks regularly.
- Automated backup or monitoring tools might invoke DebugFS as part of their operations. Review and exclude these tools by adding their process identifiers or user accounts to an exception list.
- Developers or testers with disk group privileges might use DebugFS during development or testing phases. Establish a policy to document and approve such activities, and exclude these users from triggering alerts.
- Educational or training environments where DebugFS is used for learning purposes can generate false positives. Create exceptions for these environments by specifying the associated user accounts or groups.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
- Revoke "disk" group privileges from non-essential users to limit access to disk devices and prevent misuse of DebugFS.
- Conduct a thorough review of user accounts and group memberships to ensure only authorized personnel have "disk" group privileges.
- Check for unauthorized access to sensitive files such as the shadow file or root SSH private keys and reset credentials if necessary.
- Monitor for any additional suspicious activity on the affected system and related systems, focusing on privilege escalation attempts.
- Escalate the incident to the security operations team for further investigation and to determine if additional systems are compromised.
- Implement enhanced logging and monitoring for DebugFS usage and access to disk devices to detect similar threats in the future.
References
Related rules
- At Job Created or Modified
- Cron Job Created or Modified
- Docker Escape via Nsenter
- Kernel Load or Unload via Kexec Detected
- Modification of Dynamic Linker Preload Shared Object