Potential Linux Backdoor User Account Creation
Identifies the attempt to create a new backdoor user by setting the user's UID to 0. Attackers may alter a user's UID to 0 to establish persistence on a system.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/03/07"
3integration = ["endpoint", "auditd_manager"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve User Accounts with a UID of 0"
10query = """
11SELECT description, gid, gid_signed, shell, uid, uid_signed, username FROM users WHERE username != 'root' AND uid LIKE
12'0'
13"""
14
15[[transform.osquery]]
16label = "Osquery - Retrieve Running Processes by User"
17query = "SELECT pid, username, name FROM processes p JOIN users u ON u.uid = p.uid ORDER BY username"
18
19[[transform.osquery]]
20label = "Osquery - Retrieve Information for a Specific User"
21query = "SELECT * FROM users WHERE username = {{user.name}}"
22
23[[transform.osquery]]
24label = "Osquery - Investigate the Account Authentication Status"
25query = "SELECT * FROM logged_in_users WHERE user = {{user.name}}"
26
27[[transform.osquery]]
28label = "Osquery - Retrieve Information for a Specific Group"
29query = "SELECT * FROM groups WHERE groupname = {{group.name}}"
30
31
32[rule]
33author = ["Elastic"]
34description = """
35Identifies the attempt to create a new backdoor user by setting the user's UID to 0. Attackers may alter a user's UID to
360 to establish persistence on a system.
37"""
38from = "now-9m"
39index = ["logs-endpoint.events.*", "endgame-*", "auditbeat-*", "logs-auditd_manager.auditd-*"]
40language = "eql"
41license = "Elastic License v2"
42name = "Potential Linux Backdoor User Account Creation"
43note = """## Triage and analysis
44
45### Investigating Potential Linux Backdoor User Account Creation
46
47The `usermod` command is used to modify user account attributes and settings in Linux-based operating systems.
48
49Attackers may create new accounts with a UID of 0 to maintain root access to target systems without leveraging the root user account.
50
51This rule identifies the usage of the `usermod` command to set a user's UID to 0, indicating that the user becomes a root account.
52
53> **Note**:
54> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
55> This investigation guide uses [placeholder fields](https://www.elastic.co/guide/en/security/current/osquery-placeholder-fields.html) to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
56
57#### Possible investigation steps
58- Investigate the user account that got assigned a uid of 0, and analyze its corresponding attributes.
59 - $osquery_0
60- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
61 - $osquery_1
62- Identify the user account that performed the action, analyze it, and check whether it should perform this kind of action.
63 - $osquery_2
64- Investigate whether the user is currently logged in and active.
65 - $osquery_3
66- Identify if the account was added to privileged groups or assigned special privileges after creation.
67 - $osquery_4
68- Investigate other alerts associated with the user/host during the past 48 hours.
69
70### False positive analysis
71
72- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
73
74### Response and remediation
75
76- Initiate the incident response process based on the outcome of the triage.
77- Isolate the involved host to prevent further post-compromise behavior.
78- If the triage identified malware, search the environment for additional compromised hosts.
79 - Implement temporary network rules, procedures, and segmentation to contain the malware.
80 - Stop suspicious processes.
81 - Immediately block the identified indicators of compromise (IoCs).
82 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
83- Remove and block malicious artifacts identified during triage.
84- Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
85- Delete the created account.
86- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
87- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
88- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
89"""
90references = ["https://www.elastic.co/security-labs/primer-on-persistence-mechanisms"]
91risk_score = 47
92rule_id = "494ebba4-ecb7-4be4-8c6f-654c686549ad"
93setup = """## Setup
94
95This rule requires data coming in from Elastic Defend.
96
97### Elastic Defend Integration Setup
98Elastic 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.
99
100#### Prerequisite Requirements:
101- Fleet is required for Elastic Defend.
102- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
103
104#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
105- Go to the Kibana home page and click "Add integrations".
106- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
107- Click "Add Elastic Defend".
108- Configure the integration name and optionally add a description.
109- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
110- 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).
111- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
112- 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.
113For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
114- Click "Save and Continue".
115- 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.
116For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
117"""
118severity = "medium"
119tags = [
120 "Domain: Endpoint",
121 "OS: Linux",
122 "Use Case: Threat Detection",
123 "Tactic: Persistence",
124 "Data Source: Elastic Endgame",
125 "Resources: Investigation Guide",
126 "Data Source: Elastic Defend",
127 "Data Source: Auditd Manager",
128]
129timestamp_override = "event.ingested"
130type = "eql"
131
132query = '''
133process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event", "executed", "process_started")
134 and process.name == "usermod" and process.args : "-u" and process.args : "0" and process.args : "-o"
135'''
136
137
138[[rule.threat]]
139framework = "MITRE ATT&CK"
140[[rule.threat.technique]]
141id = "T1136"
142name = "Create Account"
143reference = "https://attack.mitre.org/techniques/T1136/"
144[[rule.threat.technique.subtechnique]]
145id = "T1136.001"
146name = "Local Account"
147reference = "https://attack.mitre.org/techniques/T1136/001/"
148
149
150
151[rule.threat.tactic]
152id = "TA0003"
153name = "Persistence"
154reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating Potential Linux Backdoor User Account Creation
The usermod
command is used to modify user account attributes and settings in Linux-based operating systems.
Attackers may create new accounts with a UID of 0 to maintain root access to target systems without leveraging the root user account.
This rule identifies the usage of the usermod
command to set a user's UID to 0, indicating that the user becomes a root account.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide. This investigation guide uses placeholder fields to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
Possible investigation steps
- Investigate the user account that got assigned a uid of 0, and analyze its corresponding attributes.
- $osquery_0
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
- $osquery_1
- Identify the user account that performed the action, analyze it, and check whether it should perform this kind of action.
- $osquery_2
- Investigate whether the user is currently logged in and active.
- $osquery_3
- Identify if the account was added to privileged groups or assigned special privileges after creation.
- $osquery_4
- Investigate other alerts associated with the user/host during the past 48 hours.
False positive analysis
- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
- Delete the created account.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Process Spawned from Message-of-the-Day (MOTD)
- High Number of Process Terminations
- Potential Remote Code Execution via Web Server
- Executable Bit Set for Potential Persistence Script
- Message-of-the-Day (MOTD) File Creation