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

Related rules

to-top