Skip to content

Commit 611e073

Browse files
Aegrahgithub-actions[bot]
authored andcommitted
[Rule Tuning] Q2 Linux DR Tuning - Part 5 (#4166)
* [Rule Tuning] Q2 Linux DR Tuning - Part 5 * Update persistence_suspicious_ssh_execution_xzbackdoor.toml * Update persistence_rpm_package_installation_from_unusual_parent.toml (cherry picked from commit b309bcb)
1 parent 944c32d commit 611e073

12 files changed

+89
-86
lines changed

rules/linux/persistence_setuid_setgid_capability_set.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/09/05"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/10/17"
66

77
[transform]
88
[[transform.osquery]]
@@ -141,35 +141,36 @@ tags = [
141141
]
142142
timestamp_override = "event.ingested"
143143
type = "eql"
144-
145144
query = '''
146145
process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event") and
147-
process.name == "setcap" and process.args : "cap_set?id+ep" and not process.parent.name in ("jem", "vzctl")
146+
process.name == "setcap" and process.args : "cap_set?id+ep" and not (
147+
process.parent.name in ("jem", "vzctl") or
148+
process.args like "/usr/bin/new?idmap"
149+
)
148150
'''
149151

150-
151152
[[rule.threat]]
152153
framework = "MITRE ATT&CK"
153154

154155
[rule.threat.tactic]
155156
id = "TA0003"
156157
name = "Persistence"
157158
reference = "https://attack.mitre.org/tactics/TA0003/"
159+
158160
[[rule.threat]]
159161
framework = "MITRE ATT&CK"
162+
160163
[[rule.threat.technique]]
161164
id = "T1548"
162165
name = "Abuse Elevation Control Mechanism"
163166
reference = "https://attack.mitre.org/techniques/T1548/"
167+
164168
[[rule.threat.technique.subtechnique]]
165169
id = "T1548.001"
166170
name = "Setuid and Setgid"
167171
reference = "https://attack.mitre.org/techniques/T1548/001/"
168172

169-
170-
171173
[rule.threat.tactic]
172174
id = "TA0004"
173175
name = "Privilege Escalation"
174176
reference = "https://attack.mitre.org/tactics/TA0004/"
175-

rules/linux/persistence_user_password_change.toml renamed to rules/linux/persistence_shadow_file_modification.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/07/05"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -56,35 +56,33 @@ tags = [
5656
]
5757
timestamp_override = "event.ingested"
5858
type = "eql"
59-
6059
query = '''
6160
file where host.os.type == "linux" and event.type == "change" and event.action == "rename" and
6261
file.path == "/etc/shadow" and file.Ext.original.path != null
6362
'''
6463

65-
6664
[[rule.threat]]
6765
framework = "MITRE ATT&CK"
66+
6867
[[rule.threat.technique]]
6968
id = "T1098"
7069
name = "Account Manipulation"
7170
reference = "https://attack.mitre.org/techniques/T1098/"
7271

73-
7472
[rule.threat.tactic]
7573
id = "TA0003"
7674
name = "Persistence"
7775
reference = "https://attack.mitre.org/tactics/TA0003/"
76+
7877
[[rule.threat]]
7978
framework = "MITRE ATT&CK"
79+
8080
[[rule.threat.technique]]
8181
id = "T1098"
8282
name = "Account Manipulation"
8383
reference = "https://attack.mitre.org/techniques/T1098/"
8484

85-
8685
[rule.threat.tactic]
8786
id = "TA0004"
8887
name = "Privilege Escalation"
8988
reference = "https://attack.mitre.org/tactics/TA0004/"
90-

rules/linux/persistence_shared_object_creation.toml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/06/09"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/10/17"
66

77
[transform]
88
[[transform.osquery]]
@@ -163,36 +163,39 @@ type = "new_terms"
163163
query = '''
164164
host.os.type:linux and event.action:(creation or file_create_event or file_rename_event or rename) and
165165
file.path:(/dev/shm/* or /usr/lib/*) and file.extension:so and process.name:* and not (
166-
process.name:("dockerd" or "dpkg" or "rpm" or "snapd" or "yum" or "vmis-launcher" or "pacman" or
167-
"apt-get" or "dnf" or "podman" or "platform-python") or
168-
(process.name:vmware-install.pl and file.path:/usr/lib/vmware-tools/*)
166+
process.name:(
167+
"dockerd" or "dpkg" or "rpm" or "snapd" or "yum" or "vmis-launcher" or "pacman" or "apt-get" or "dnf" or "podman" or
168+
platform-python* or "dnf-automatic" or "unattended-upgrade" or "apk" or "snap-update-ns" or "install" or "exe" or
169+
"systemd" or "root" or "sshd" or "pip" or "jlink" or python* or "update-alternatives" or pip* or
170+
"installer.bin.inst" or "uninstall-bin" or "linux_agent.inst"
171+
) or
172+
(process.name:vmware-install.pl and file.path:/usr/lib/vmware-tools/*) or
173+
process.executable : (/dev/fd/* or "/" or "/kaniko/executor" or "/usr/bin/buildah")
169174
)
170175
'''
171176

172-
173177
[[rule.threat]]
174178
framework = "MITRE ATT&CK"
179+
175180
[[rule.threat.technique]]
176181
id = "T1574"
177182
name = "Hijack Execution Flow"
178183
reference = "https://attack.mitre.org/techniques/T1574/"
184+
179185
[[rule.threat.technique.subtechnique]]
180186
id = "T1574.006"
181187
name = "Dynamic Linker Hijacking"
182188
reference = "https://attack.mitre.org/techniques/T1574/006/"
183189

184-
185-
186190
[rule.threat.tactic]
187191
id = "TA0003"
188192
name = "Persistence"
189193
reference = "https://attack.mitre.org/tactics/TA0003/"
190194

191195
[rule.new_terms]
192196
field = "new_terms_fields"
193-
value = ["host.id", "file.path", "process.executable"]
197+
value = ["file.path", "process.executable"]
198+
194199
[[rule.new_terms.history_window_start]]
195200
field = "history_window_start"
196201
value = "now-10d"
197-
198-

rules/linux/persistence_shell_configuration_modification.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/04/30"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -59,7 +59,6 @@ tags = [
5959
]
6060
timestamp_override = "event.ingested"
6161
type = "eql"
62-
6362
query = '''
6463
file where host.os.type == "linux" and event.action in ("rename", "creation") and file.path : (
6564
// system-wide configurations
@@ -94,27 +93,26 @@ file where host.os.type == "linux" and event.action in ("rename", "creation") an
9493
"/usr/libexec/platform-python*"
9594
) or
9695
process.executable == null or
96+
process.name in ("adclient", "mkhomedir_helper", "teleport", "mkhomedir", "adduser", "desktopDaemon") or
9797
(process.name == "sed" and file.name : "sed*") or
9898
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
9999
)
100100
'''
101101

102-
103102
[[rule.threat]]
104103
framework = "MITRE ATT&CK"
104+
105105
[[rule.threat.technique]]
106106
id = "T1546"
107107
name = "Event Triggered Execution"
108108
reference = "https://attack.mitre.org/techniques/T1546/"
109+
109110
[[rule.threat.technique.subtechnique]]
110111
id = "T1546.004"
111112
name = "Unix Shell Configuration Modification"
112113
reference = "https://attack.mitre.org/techniques/T1546/004/"
113114

114-
115-
116115
[rule.threat.tactic]
117116
id = "TA0003"
118117
name = "Persistence"
119118
reference = "https://attack.mitre.org/tactics/TA0003/"
120-

rules/linux/persistence_ssh_netcon.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/06/06"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/07/18"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -41,7 +41,10 @@ sequence by host.id with maxspan=1s
4141
"192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1", "FE80::/10",
4242
"FF00::/8", "172.31.0.0/16"
4343
)
44-
) and not process.executable in ("/bin/yum", "/usr/bin/yum")
44+
) and not (
45+
process.executable in ("/bin/yum", "/usr/bin/yum") or
46+
process.name in ("login_duo", "ssh", "sshd", "sshd-session")
47+
)
4548
] by process.parent.entity_id
4649
'''
4750

rules/linux/persistence_suspicious_ssh_execution_xzbackdoor.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/04/01"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -40,63 +40,65 @@ sequence by host.id, user.id with maxspan=1s
4040
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name == "sshd" and
4141
process.args == "-D" and process.args == "-R"] by process.pid, process.entity_id
4242
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.parent.name == "sshd" and
43-
process.executable != null and
44-
not process.executable in ("/usr/sbin/sshd", "/usr/sbin/unix_chkpwd", "/usr/bin/google_authorized_keys", "/usr/bin/fipscheck") and
45-
process.command_line != "sh -c /usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic.new"] by process.parent.pid, process.parent.entity_id
43+
process.executable != null and not (
44+
process.executable in ("/usr/sbin/sshd", "/usr/sbin/unix_chkpwd", "/usr/bin/google_authorized_keys", "/usr/bin/fipscheck") or
45+
process.args like ("rsync*", "systemctl*", "/usr/sbin/unix_chkpwd", "/usr/bin/google_authorized_keys", "/usr/sbin/aad_certhandler*") or
46+
process.command_line like "sh -c /usr/bin/env -i PATH=*"
47+
)] by process.parent.pid, process.parent.entity_id
4648
[process where host.os.type == "linux" and event.action == "end" and process.name == "sshd" and process.exit_code != 0] by process.pid, process.entity_id
4749
[network where host.os.type == "linux" and event.type == "end" and event.action == "disconnect_received" and process.name == "sshd"] by process.pid, process.entity_id
4850
'''
4951

50-
5152
[[rule.threat]]
5253
framework = "MITRE ATT&CK"
54+
5355
[[rule.threat.technique]]
5456
id = "T1543"
5557
name = "Create or Modify System Process"
5658
reference = "https://attack.mitre.org/techniques/T1543/"
5759

58-
5960
[rule.threat.tactic]
6061
id = "TA0003"
6162
name = "Persistence"
6263
reference = "https://attack.mitre.org/tactics/TA0003/"
64+
6365
[[rule.threat]]
6466
framework = "MITRE ATT&CK"
67+
6568
[[rule.threat.technique]]
6669
id = "T1556"
6770
name = "Modify Authentication Process"
6871
reference = "https://attack.mitre.org/techniques/T1556/"
6972

70-
7173
[rule.threat.tactic]
7274
id = "TA0006"
7375
name = "Credential Access"
7476
reference = "https://attack.mitre.org/tactics/TA0006/"
77+
7578
[[rule.threat]]
7679
framework = "MITRE ATT&CK"
80+
7781
[[rule.threat.technique]]
7882
id = "T1021"
7983
name = "Remote Services"
8084
reference = "https://attack.mitre.org/techniques/T1021/"
85+
8186
[[rule.threat.technique.subtechnique]]
8287
id = "T1021.004"
8388
name = "SSH"
8489
reference = "https://attack.mitre.org/techniques/T1021/004/"
8590

86-
8791
[[rule.threat.technique]]
8892
id = "T1563"
8993
name = "Remote Service Session Hijacking"
9094
reference = "https://attack.mitre.org/techniques/T1563/"
95+
9196
[[rule.threat.technique.subtechnique]]
9297
id = "T1563.001"
9398
name = "SSH Hijacking"
9499
reference = "https://attack.mitre.org/techniques/T1563/001/"
95100

96-
97-
98101
[rule.threat.tactic]
99102
id = "TA0008"
100103
name = "Lateral Movement"
101104
reference = "https://attack.mitre.org/tactics/TA0008/"
102-

rules/linux/persistence_systemd_generator_creation.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/06/19"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -60,7 +60,6 @@ tags = [
6060
]
6161
timestamp_override = "event.ingested"
6262
type = "eql"
63-
6463
query = '''
6564
file where host.os.type == "linux" and event.action in ("rename", "creation") and file.path : (
6665
"/run/systemd/system-generators/*", "/etc/systemd/system-generators/*",
@@ -75,49 +74,48 @@ file where host.os.type == "linux" and event.action in ("rename", "creation") an
7574
"/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
7675
"/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
7776
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
78-
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
77+
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client", "/usr/sbin/sshd",
7978
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
80-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd"
79+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python"
8180
) or
8281
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
8382
file.Ext.original.extension == "dpkg-new" or
8483
process.executable == null
8584
)
8685
'''
8786

88-
8987
[[rule.threat]]
9088
framework = "MITRE ATT&CK"
89+
9190
[[rule.threat.technique]]
9291
id = "T1543"
9392
name = "Create or Modify System Process"
9493
reference = "https://attack.mitre.org/techniques/T1543/"
94+
9595
[[rule.threat.technique.subtechnique]]
9696
id = "T1543.002"
9797
name = "Systemd Service"
9898
reference = "https://attack.mitre.org/techniques/T1543/002/"
9999

100-
101-
102100
[rule.threat.tactic]
103101
id = "TA0003"
104102
name = "Persistence"
105103
reference = "https://attack.mitre.org/tactics/TA0003/"
104+
106105
[[rule.threat]]
107106
framework = "MITRE ATT&CK"
107+
108108
[[rule.threat.technique]]
109109
id = "T1543"
110110
name = "Create or Modify System Process"
111111
reference = "https://attack.mitre.org/techniques/T1543/"
112+
112113
[[rule.threat.technique.subtechnique]]
113114
id = "T1543.002"
114115
name = "Systemd Service"
115116
reference = "https://attack.mitre.org/techniques/T1543/002/"
116117

117-
118-
119118
[rule.threat.tactic]
120119
id = "TA0004"
121120
name = "Privilege Escalation"
122121
reference = "https://attack.mitre.org/tactics/TA0004/"
123-

0 commit comments

Comments
 (0)