Skip to content

Commit 213660f

Browse files
Aegrahgithub-actions[bot]
authored andcommitted
[Rule Tuning] Misc. DR Rule Tuning - Part 2 (#3905)
* [Rule Tuning] Misc. DR Rule Tuning - Part 2 * ++ * Update privilege_escalation_suspicious_uid_guid_elevation.toml * Update rules/linux/persistence_systemd_service_creation.toml --------- Co-authored-by: Jonhnathan <[email protected]> (cherry picked from commit a71bbe0)
1 parent 9df6400 commit 213660f

12 files changed

+92
-49
lines changed

rules/linux/persistence_pluggable_authentication_module_creation.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -55,7 +55,7 @@ process.executable != null and (
5555
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
5656
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
5757
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/sbin/pam-auth-update",
58-
"/usr/lib/systemd/systemd", "/usr/libexec/packagekitd", "/usr/bin/bsdtar"
58+
"/usr/lib/systemd/systemd", "/usr/libexec/packagekitd", "/usr/bin/bsdtar", "/sbin/pam-auth-update"
5959
) or
6060
file.path : (
6161
"/tmp/snap.rootfs_*/pam_*.so", "/tmp/newroot/lib/*/pam_*.so", "/tmp/newroot/usr/lib64/security/pam_*.so"

rules/linux/persistence_rc_script_creation.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -152,7 +152,7 @@ file.path in ("/etc/rc.local", "/etc/rc.common") and not (
152152
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
153153
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
154154
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
155-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd"
155+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python"
156156
) or
157157
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
158158
file.Ext.original.extension == "dpkg-new" or

rules/linux/persistence_shell_configuration_modification.toml

Lines changed: 8 additions & 3 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/07/11"
5+
updated_date = "2024/07/18"
66

77
[rule]
88
author = ["Elastic"]
@@ -77,12 +77,17 @@ file where host.os.type == "linux" and event.action in ("rename", "creation") an
7777
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
7878
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
7979
"/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/sbin/adduser", "/usr/sbin/useradd", "/usr/local/bin/dockerd"
80+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/sbin/adduser", "/usr/sbin/useradd", "/usr/local/bin/dockerd",
81+
"/usr/sbin/gdm", "/usr/bin/unzip", "/usr/bin/gnome-shell", "/sbin/mkhomedir_helper", "/usr/sbin/sshd",
82+
"/opt/puppetlabs/puppet/bin/ruby", "/usr/bin/xfce4-session", "/usr/libexec/oddjob/mkhomedir", "/sbin/useradd",
83+
"/usr/lib/systemd/systemd", "/usr/sbin/crond", "/usr/bin/pamac-daemon", "/usr/sbin/mkhomedir_helper",
84+
"/opt/pbis/sbin/lwsmd", "/usr/sbin/oddjobd"
8185
) or
8286
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
8387
file.Ext.original.extension == "dpkg-new" or
8488
process.executable : (
85-
"/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*"
89+
"/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*",
90+
"/usr/libexec/platform-python*"
8691
) or
8792
process.executable == null or
8893
(process.name == "sed" and file.name : "sed*") or

rules/linux/persistence_ssh_netcon.toml

Lines changed: 2 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/06/06"
5+
updated_date = "2024/07/18"
66

77
[rule]
88
author = ["Elastic"]
@@ -41,7 +41,7 @@ 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-
)
44+
) and not process.executable in ("/bin/yum", "/usr/bin/yum")
4545
] by process.parent.entity_id
4646
'''
4747

rules/linux/persistence_systemd_scheduled_timer_created.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -169,7 +169,9 @@ file where host.os.type == "linux" and event.action in ("rename", "creation") an
169169
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
170170
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
171171
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
172-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd"
172+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/bin/crio", "/usr/sbin/crond",
173+
"/opt/puppetlabs/puppet/bin/ruby", "/usr/libexec/platform-python", "/kaniko/kaniko-executor",
174+
"/usr/local/bin/dockerd", "/usr/bin/podman", "/bin/install", "/proc/self/exe"
173175
) or
174176
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
175177
file.Ext.original.extension == "dpkg-new" or

rules/linux/persistence_systemd_service_creation.toml

Lines changed: 6 additions & 2 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/06/19"
5+
updated_date = "2024/07/18"
66

77
[transform]
88
[[transform.osquery]]
@@ -198,7 +198,11 @@ file where host.os.type == "linux" and event.action in ("rename", "creation") an
198198
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
199199
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
200200
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
201-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd"
201+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/bin/crio", "/usr/sbin/crond",
202+
"/opt/puppetlabs/puppet/bin/ruby", "/usr/libexec/platform-python", "/kaniko/kaniko-executor",
203+
"/usr/local/bin/dockerd", "/usr/bin/podman", "/bin/install", "/proc/self/exe", "/usr/lib/systemd/systemd",
204+
"/usr/sbin/sshd", "/usr/bin/gitlab-runner", "/opt/gitlab/embedded/bin/ruby", "/usr/sbin/gdm", "/usr/bin/install",
205+
"/usr/local/manageengine/uems_agent/bin/dcregister"
202206
) or
203207
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
204208
file.Ext.original.extension == "dpkg-new" or

rules/linux/persistence_udev_rule_creation.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -57,7 +57,7 @@ timestamp_override = "event.ingested"
5757
type = "eql"
5858
query = '''
5959
file where host.os.type == "linux" and event.action in ("rename", "creation") and
60-
process.executable != null and
60+
process.executable != null and file.extension == "rules" and
6161
file.path : (
6262
"/lib/udev/*", "/etc/udev/rules.d/*", "/usr/lib/udev/rules.d/*", "/run/udev/rules.d/*", "/usr/local/lib/udev/rules.d/*"
6363
) and not (
@@ -69,9 +69,10 @@ file.path : (
6969
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
7070
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
7171
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
72-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/netplan/generate"
72+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/netplan/generate",
73+
"/lib/systemd/system-generators/netplan", "/lib/systemd/systemd", "/usr/bin/containerd", "/usr/sbin/sshd",
74+
"/kaniko/executor"
7375
) or
74-
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
7576
file.Ext.original.extension == "dpkg-new" or
7677
process.executable : (
7778
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*"

rules/linux/persistence_xdg_autostart_netcon.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -81,7 +81,19 @@ sequence by host.id, process.entity_id with maxspan=1s
8181
process.args == "-c" and process.args : "export GIO_LAUNCHED_DESKTOP_FILE_PID=$$;*")
8282
)
8383
]
84-
[network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted"]
84+
[network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and not (
85+
destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
86+
destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
87+
"192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
88+
"192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10",
89+
"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",
90+
"FF00::/8", "172.31.0.0/16"
91+
) or
92+
process.executable in (
93+
"/usr/lib64/firefox/firefox", "/usr/lib/firefox/firefox", "/opt/forticlient/fortitraylauncher"
94+
)
95+
)
96+
]
8597
'''
8698

8799
[[rule.threat]]

rules/linux/privilege_escalation_netcon_via_sudo_binary.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -15,8 +15,8 @@ from = "now-9m"
1515
index = ["logs-endpoint.events.*", "endgame-*"]
1616
language = "eql"
1717
license = "Elastic License v2"
18-
name = "Suspicious Network Connection via Sudo Binary"
19-
risk_score = 47
18+
name = "Network Connection via Sudo Binary"
19+
risk_score = 21
2020
rule_id = "30e1e9f2-eb9c-439f-aff6-1e3068e99384"
2121
setup = """## Setup
2222
@@ -44,7 +44,7 @@ For more details on Elastic Agent configuration settings, refer to the [helper g
4444
- 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.
4545
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
4646
"""
47-
severity = "medium"
47+
severity = "low"
4848
tags = [
4949
"Domain: Endpoint",
5050
"OS: Linux",
@@ -55,38 +55,43 @@ tags = [
5555
]
5656
timestamp_override = "event.ingested"
5757
type = "eql"
58-
5958
query = '''
6059
network where host.os.type == "linux" and event.type == "start" and
61-
event.action in ("connection_attempted", "ipv4_connection_attempt_event") and process.name == "sudo"
60+
event.action in ("connection_attempted", "ipv4_connection_attempt_event") and process.name == "sudo" and not (
61+
destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
62+
destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
63+
"192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
64+
"192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10",
65+
"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",
66+
"FF00::/8", "172.31.0.0/16"
67+
)
68+
)
6269
'''
6370

64-
6571
[[rule.threat]]
6672
framework = "MITRE ATT&CK"
73+
6774
[[rule.threat.technique]]
6875
id = "T1055"
6976
name = "Process Injection"
7077
reference = "https://attack.mitre.org/techniques/T1055/"
78+
7179
[[rule.threat.technique.subtechnique]]
7280
id = "T1055.008"
7381
name = "Ptrace System Calls"
7482
reference = "https://attack.mitre.org/techniques/T1055/008/"
7583

76-
7784
[[rule.threat.technique]]
7885
id = "T1548"
7986
name = "Abuse Elevation Control Mechanism"
8087
reference = "https://attack.mitre.org/techniques/T1548/"
88+
8189
[[rule.threat.technique.subtechnique]]
8290
id = "T1548.003"
8391
name = "Sudo and Sudo Caching"
8492
reference = "https://attack.mitre.org/techniques/T1548/003/"
8593

86-
87-
8894
[rule.threat.tactic]
8995
id = "TA0004"
9096
name = "Privilege Escalation"
9197
reference = "https://attack.mitre.org/tactics/TA0004/"
92-

rules/linux/privilege_escalation_potential_wildcard_shell_spawn.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -61,35 +61,37 @@ sequence by host.id with maxspan=1s
6161
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
6262
(process.name == "tar" and process.args : "--checkpoint=*" and process.args : "--checkpoint-action=*") or
6363
(process.name == "rsync" and process.args : "-e*") or
64-
(process.name == "zip" and process.args == "--unzip-command") )] by process.entity_id
64+
(process.name == "zip" and process.args == "--unzip-command")
65+
) and not process.executable : "/tmp/newroot/*"
66+
] by process.entity_id
6567
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
6668
process.parent.name : ("tar", "rsync", "zip") and
67-
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")] by process.parent.entity_id
69+
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")
70+
] by process.parent.entity_id
6871
'''
6972

70-
7173
[[rule.threat]]
7274
framework = "MITRE ATT&CK"
75+
7376
[[rule.threat.technique]]
7477
id = "T1068"
7578
name = "Exploitation for Privilege Escalation"
7679
reference = "https://attack.mitre.org/techniques/T1068/"
7780

78-
7981
[rule.threat.tactic]
8082
id = "TA0004"
8183
name = "Privilege Escalation"
8284
reference = "https://attack.mitre.org/tactics/TA0004/"
85+
8386
[[rule.threat]]
8487
framework = "MITRE ATT&CK"
88+
8589
[[rule.threat.technique]]
8690
id = "T1059"
8791
name = "Command and Scripting Interpreter"
8892
reference = "https://attack.mitre.org/techniques/T1059/"
8993

90-
9194
[rule.threat.tactic]
9295
id = "TA0002"
9396
name = "Execution"
9497
reference = "https://attack.mitre.org/tactics/TA0002/"
95-

rules/linux/privilege_escalation_suspicious_uid_guid_elevation.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["endpoint"]
44
maturity = "production"
55
min_stack_comments = "Linux effective and permitted process capability data sources were added in version 8.11.0"
66
min_stack_version = "8.11.0"
7-
updated_date = "2024/03/08"
7+
updated_date = "2024/07/18"
88

99
[rule]
1010
author = ["Elastic"]
@@ -60,7 +60,17 @@ query = '''
6060
sequence by host.id, process.entity_id with maxspan=1s
6161
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name != null and
6262
(process.thread.capabilities.effective : "CAP_SET?ID" or process.thread.capabilities.permitted : "CAP_SET?ID") and
63-
user.id != "0"]
63+
user.id != "0" and not (
64+
process.parent.executable : ("/tmp/newroot/*", "/opt/carbonblack*") or
65+
process.parent.executable in (
66+
"/opt/SolarWinds/Agent/bin/Plugins/JobEngine/SolarWinds.Agent.JobEngine.Plugin", "/usr/bin/vmware-toolbox-cmd",
67+
"/usr/bin/dbus-daemon", "/usr/bin/update-notifier", "/usr/share/language-tools/language-options"
68+
) or
69+
process.executable : ("/opt/dynatrace/*", "/tmp/newroot/*") or
70+
process.executable in (
71+
"/bin/fgrep", "/usr/bin/sudo", "/usr/bin/pkexec", "/usr/lib/cockpit/cockpit-session", "/usr/sbin/suexec"
72+
)
73+
)]
6474
[process where host.os.type == "linux" and event.action == "uid_change" and event.type == "change" and
6575
(process.thread.capabilities.effective : "CAP_SET?ID" or process.thread.capabilities.permitted : "CAP_SET?ID")
6676
and user.id == "0"]
@@ -88,4 +98,3 @@ reference = "https://attack.mitre.org/techniques/T1548/001/"
8898
id = "TA0004"
8999
name = "Privilege Escalation"
90100
reference = "https://attack.mitre.org/tactics/TA0004/"
91-

0 commit comments

Comments
 (0)