Linux Group Creation
Identifies attempts to create a new group. Attackers may create new groups to establish persistence on a system.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/02/13"
3integration = ["system"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve Information for a Specific Group"
10query = "SELECT * FROM groups WHERE groupname = {{group.name}}"
11
12[[transform.osquery]]
13label = "Osquery - Retrieve Information for a Specific User"
14query = "SELECT * FROM users WHERE username = {{user.name}}"
15
16[[transform.osquery]]
17label = "Osquery - Investigate the Account Authentication Status"
18query = "SELECT * FROM logged_in_users WHERE user = {{user.name}}"
19
20[[transform.osquery]]
21label = "Osquery - Retrieve Running Processes by User"
22query = "SELECT pid, username, name FROM processes p JOIN users u ON u.uid = p.uid ORDER BY username"
23
24
25[rule]
26author = ["Elastic"]
27description = "Identifies attempts to create a new group. Attackers may create new groups to establish persistence on a system.\n"
28from = "now-9m"
29index = ["filebeat-*", "logs-system.auth-*"]
30language = "eql"
31license = "Elastic License v2"
32name = "Linux Group Creation"
33note = """## Triage and analysis
34
35### Investigating Linux Group Creation
36
37The `groupadd` and `addgroup` commands are used to create new user groups in Linux-based operating systems.
38
39Attackers may create new groups to maintain access to victim systems or escalate privileges by assigning a compromised account to a privileged group.
40
41This rule identifies the usages of `groupadd` and `addgroup` to create new groups.
42
43> **Note**:
44> 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.
45> 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.
46
47#### Possible investigation steps
48
49- Investigate whether the group was created succesfully.
50 - $osquery_0
51- Identify if a user account was added to this group after creation.
52 - $osquery_1
53- Investigate whether the user is currently logged in and active.
54 - $osquery_2
55- Identify the user account that performed the action and whether it should perform this kind of action.
56- 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.
57 - $osquery_3
58- Investigate other alerts associated with the user/host during the past 48 hours.
59
60### False positive analysis
61
62- Group creation is a common administrative task, so there is a high chance of the activity being legitimate. Before investigating further, verify that this activity is not benign.
63
64### Response and remediation
65
66- Initiate the incident response process based on the outcome of the triage.
67- Isolate the involved host to prevent further post-compromise behavior.
68- If the triage identified malware, search the environment for additional compromised hosts.
69 - Implement temporary network rules, procedures, and segmentation to contain the malware.
70 - Stop suspicious processes.
71 - Immediately block the identified indicators of compromise (IoCs).
72 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
73- Remove and block malicious artifacts identified during triage.
74- Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
75- Delete the created group and, in case an account was added to this group, delete the account.
76- 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.
77- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
78- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
79"""
80references = ["https://www.elastic.co/security-labs/primer-on-persistence-mechanisms"]
81risk_score = 21
82rule_id = "a1c2589e-0c8c-4ca8-9eb6-f83c4bbdbe8f"
83setup = """## Setup
84
85This rule requires data coming in from Filebeat.
86
87### Filebeat Setup
88Filebeat is a lightweight shipper for forwarding and centralizing log data. Installed as an agent on your servers, Filebeat monitors the log files or locations that you specify, collects log events, and forwards them either to Elasticsearch or Logstash for indexing.
89
90#### The following steps should be executed in order to add the Filebeat on a Linux System:
91- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
92- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html).
93- To run Filebeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-docker.html).
94- To run Filebeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-kubernetes.html).
95- For quick start information for Filebeat refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/8.11/filebeat-installation-configuration.html).
96- For complete “Setup and Run Filebeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setting-up-and-running.html).
97
98#### Rule Specific Setup Note
99- This rule requires the “Filebeat System Module” to be enabled.
100- The system module collects and parses logs created by the system logging service of common Unix/Linux based distributions.
101- To run the system module of Filebeat on Linux follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-system.html).
102"""
103severity = "low"
104tags = [
105 "Domain: Endpoint",
106 "OS: Linux",
107 "Use Case: Threat Detection",
108 "Tactic: Persistence",
109 "Resources: Investigation Guide",
110]
111timestamp_override = "event.ingested"
112type = "eql"
113
114query = '''
115iam where host.os.type == "linux" and (event.type == "group" and event.type == "creation") and
116process.name in ("groupadd", "addgroup") and group.name != null
117'''
118
119
120[[rule.threat]]
121framework = "MITRE ATT&CK"
122[[rule.threat.technique]]
123id = "T1136"
124name = "Create Account"
125reference = "https://attack.mitre.org/techniques/T1136/"
126[[rule.threat.technique.subtechnique]]
127id = "T1136.001"
128name = "Local Account"
129reference = "https://attack.mitre.org/techniques/T1136/001/"
130
131
132
133[rule.threat.tactic]
134id = "TA0003"
135name = "Persistence"
136reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating Linux Group Creation
The groupadd
and addgroup
commands are used to create new user groups in Linux-based operating systems.
Attackers may create new groups to maintain access to victim systems or escalate privileges by assigning a compromised account to a privileged group.
This rule identifies the usages of groupadd
and addgroup
to create new groups.
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 whether the group was created succesfully.
- $osquery_0
- Identify if a user account was added to this group after creation.
- $osquery_1
- Investigate whether the user is currently logged in and active.
- $osquery_2
- Identify the user account that performed the action and whether it should perform this kind of action.
- 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_3
- Investigate other alerts associated with the user/host during the past 48 hours.
False positive analysis
- Group creation is a common administrative task, so there is a high chance of the activity being legitimate. Before investigating further, verify that this activity is not benign.
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 group and, in case an account was added to this group, delete the 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
- Linux User Account Creation
- Message-of-the-Day (MOTD) File Creation
- Potential Linux Backdoor User Account Creation
- rc.local/rc.common File Creation
- Anomalous Process For a Linux Population