From 90e9e157d939d295f7ff43c43e845209f6517e75 Mon Sep 17 00:00:00 2001 From: Ruben Groenewoud Date: Mon, 30 Jun 2025 14:20:53 +0200 Subject: [PATCH 1/3] [New Rule] Linux User or Group Deletion --- ...efense_evasion_user_or_group_deletion.toml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 rules/linux/defense_evasion_user_or_group_deletion.toml diff --git a/rules/linux/defense_evasion_user_or_group_deletion.toml b/rules/linux/defense_evasion_user_or_group_deletion.toml new file mode 100644 index 00000000000..cdab23f1cdc --- /dev/null +++ b/rules/linux/defense_evasion_user_or_group_deletion.toml @@ -0,0 +1,64 @@ +[metadata] +creation_date = "2025/06/30" +integration = ["system"] +maturity = "production" +updated_date = "2025/06/30" + +[rule] +author = ["Elastic"] +description = """ +This rule detects the deletion of user or group accounts on Linux systems. Adversaries may use these +commands to remove accounts to cover their tracks or disrupt operations. +""" +from = "now-9m" +index = ["filebeat-*", "logs-system.auth-*"] +language = "eql" +license = "Elastic License v2" +name = "Linux User or Group Deletion" +risk_score = 21 +rule_id = "8f8004e1-0783-485f-a3da-aca4362f74a7" +setup = """## Setup + +This rule requires data coming in from Filebeat. + +### Filebeat Setup +Filebeat 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. + +#### The following steps should be executed in order to add the Filebeat on a Linux System: +- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages. +- 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). +- 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). +- 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). +- 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). +- 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). + +#### Rule Specific Setup Note +- This rule requires the “Filebeat System Module” to be enabled. +- The system module collects and parses logs created by the system logging service of common Unix/Linux based distributions. +- 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). +""" +severity = "low" +tags = [ + "Domain: Endpoint", + "OS: Linux", + "Use Case: Threat Detection", + "Tactic: Defense Evasion", +] +timestamp_override = "event.ingested" +type = "eql" +query = ''' +iam where host.os.type == "linux" and event.type in ("group", "user") and event.type == "deletion" and event.outcome == "success" +''' + +[[rule.threat]] +framework = "MITRE ATT&CK" + +[[rule.threat.technique]] +id = "T1070" +name = "Indicator Removal" +reference = "https://attack.mitre.org/techniques/T1070/" + +[rule.threat.tactic] +id = "TA0005" +name = "Defense Evasion" +reference = "https://attack.mitre.org/tactics/TA0005/" From 892f689b829207a9c04e558fe17727940a16eb6b Mon Sep 17 00:00:00 2001 From: Ruben Groenewoud Date: Mon, 30 Jun 2025 14:26:23 +0200 Subject: [PATCH 2/3] Added broader scope for user/group creation --- rules/linux/persistence_linux_group_creation.toml | 12 ++++-------- .../persistence_linux_user_account_creation.toml | 11 ++++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/rules/linux/persistence_linux_group_creation.toml b/rules/linux/persistence_linux_group_creation.toml index f2f16eec49c..55ddb17a10d 100644 --- a/rules/linux/persistence_linux_group_creation.toml +++ b/rules/linux/persistence_linux_group_creation.toml @@ -2,7 +2,7 @@ creation_date = "2023/02/13" integration = ["system"] maturity = "production" -updated_date = "2025/02/03" +updated_date = "2025/06/30" [transform] [[transform.osquery]] @@ -110,28 +110,24 @@ tags = [ ] timestamp_override = "event.ingested" type = "eql" - query = ''' -iam where host.os.type == "linux" and (event.type == "group" and event.type == "creation") and -process.name in ("groupadd", "addgroup") and group.name != null +iam where host.os.type == "linux" and event.type == "group" and event.type == "creation" ''' - [[rule.threat]] framework = "MITRE ATT&CK" + [[rule.threat.technique]] id = "T1136" name = "Create Account" reference = "https://attack.mitre.org/techniques/T1136/" + [[rule.threat.technique.subtechnique]] id = "T1136.001" name = "Local Account" reference = "https://attack.mitre.org/techniques/T1136/001/" - - [rule.threat.tactic] id = "TA0003" name = "Persistence" reference = "https://attack.mitre.org/tactics/TA0003/" - diff --git a/rules/linux/persistence_linux_user_account_creation.toml b/rules/linux/persistence_linux_user_account_creation.toml index 4079c03faa7..a0a9e576aba 100644 --- a/rules/linux/persistence_linux_user_account_creation.toml +++ b/rules/linux/persistence_linux_user_account_creation.toml @@ -2,7 +2,7 @@ creation_date = "2023/02/13" integration = ["system"] maturity = "production" -updated_date = "2025/02/03" +updated_date = "2025/06/30" [transform] [[transform.osquery]] @@ -109,26 +109,23 @@ tags = [ ] timestamp_override = "event.ingested" type = "eql" - query = ''' -iam where host.os.type == "linux" and (event.type == "user" and event.type == "creation") and -process.name in ("useradd", "adduser") and user.name != null +iam where host.os.type == "linux" and event.type == "user" and event.type == "creation" ''' - [[rule.threat]] framework = "MITRE ATT&CK" + [[rule.threat.technique]] id = "T1136" name = "Create Account" reference = "https://attack.mitre.org/techniques/T1136/" + [[rule.threat.technique.subtechnique]] id = "T1136.001" name = "Local Account" reference = "https://attack.mitre.org/techniques/T1136/001/" - - [rule.threat.tactic] id = "TA0003" name = "Persistence" From fe368b7fea9ad73abe33e4298835b1e456292b1c Mon Sep 17 00:00:00 2001 From: Ruben Groenewoud Date: Mon, 30 Jun 2025 14:28:05 +0200 Subject: [PATCH 3/3] ++ --- rules/linux/persistence_linux_group_creation.toml | 2 +- rules/linux/persistence_linux_user_account_creation.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/linux/persistence_linux_group_creation.toml b/rules/linux/persistence_linux_group_creation.toml index 55ddb17a10d..1e244794354 100644 --- a/rules/linux/persistence_linux_group_creation.toml +++ b/rules/linux/persistence_linux_group_creation.toml @@ -111,7 +111,7 @@ tags = [ timestamp_override = "event.ingested" type = "eql" query = ''' -iam where host.os.type == "linux" and event.type == "group" and event.type == "creation" +iam where host.os.type == "linux" and event.type == "group" and event.type == "creation" and event.outcome == "success" ''' [[rule.threat]] diff --git a/rules/linux/persistence_linux_user_account_creation.toml b/rules/linux/persistence_linux_user_account_creation.toml index a0a9e576aba..7acc486bf8b 100644 --- a/rules/linux/persistence_linux_user_account_creation.toml +++ b/rules/linux/persistence_linux_user_account_creation.toml @@ -110,7 +110,7 @@ tags = [ timestamp_override = "event.ingested" type = "eql" query = ''' -iam where host.os.type == "linux" and event.type == "user" and event.type == "creation" +iam where host.os.type == "linux" and event.type == "user" and event.type == "creation" and event.outcome == "success" ''' [[rule.threat]]