Skip to content

Commit 76fdd54

Browse files
authored
[Rule Tuning] Misc. DR Rule Tuning (#3904)
* [Rule Tuning] Misc. DR Rule Tuning * Update execution_unknown_rwx_mem_region_binary_executed.toml * Update command_and_control_suspicious_network_activity_from_unknown_executable.toml * I love KQL validation
1 parent 322162f commit 76fdd54

10 files changed

+92
-69
lines changed

rules/linux/impact_potential_linux_ransomware_file_encryption.toml renamed to rules/_deprecated/impact_potential_linux_ransomware_file_encryption.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[metadata]
22
creation_date = "2023/03/20"
3+
deprecation_date = "2024/07/18"
34
integration = ["endpoint"]
4-
maturity = "production"
5-
updated_date = "2024/05/21"
5+
maturity = "deprecated"
6+
updated_date = "2024/07/18"
67

78
[rule]
89
author = ["Elastic"]

rules/linux/command_and_control_suspicious_network_activity_from_unknown_executable.toml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["endpoint"]
44
maturity = "production"
55
min_stack_comments = "Multiple field support in the New Terms rule type was added in Elastic 8.6"
66
min_stack_version = "8.6.0"
7-
updated_date = "2024/05/24"
7+
updated_date = "2024/07/18"
88

99
[transform]
1010
[[transform.osquery]]
@@ -181,46 +181,44 @@ timestamp_override = "event.ingested"
181181
type = "new_terms"
182182

183183
query = '''
184-
host.os.type:linux and event.category:network and event.action:(connection_attempted or ipv4_connection_attempt_event) and
184+
host.os.type:linux and event.category:network and event.action:(connection_attempted or ipv4_connection_attempt_event) and
185185
process.executable:(
186-
(/etc/crontab or /etc/rc.local or ./* or /boot/* or /dev/shm/* or /etc/cron.*/* or /etc/init.d/* or /etc/rc*.d/* or
187-
/etc/update-motd.d/* or /home/*/.* or /run/* or /srv/* or /tmp/* or /usr/lib/update-notifier/* or /var/tmp/* or
188-
/var/log/*
189-
) and not (/tmp/newroot/* or /tmp/snap.rootfs*)
190-
) and
191-
source.ip:(10.0.0.0/8 or 127.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and
186+
(/etc/crontab or /etc/rc.local or ./* or /boot/* or /dev/shm/* or /etc/cron.*/* or /etc/init.d/* or /etc/rc*.d/* or
187+
/etc/update-motd.d/* or /home/*/.* or /tmp/* or /usr/lib/update-notifier/* or /var/log/* or /var/tmp/*
188+
) and
189+
not (/tmp/newroot/* or /tmp/snap.rootfs*) and
190+
not /etc/cron.hourly/BitdefenderRedline) and
191+
source.ip:(10.0.0.0/8 or 127.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and
192192
not process.name:(
193-
apt or chrome or curl or dnf or dockerd or dpkg or firefox-bin or java or kite-update or kited or node or rpm or
194-
saml2aws or wget or yum or ansible* or aws* or php* or pip* or python* or steam* or terraform*
195-
) and
193+
apt or chrome or curl or dnf or dockerd or dpkg or firefox-bin or git-remote-https or java or kite-update or kited or node
194+
or rpm or saml2aws or selenium-manager or solana-validator or wget or yum or ansible* or aws* or php* or pip* or python*
195+
or steam* or terraform*
196+
) and
196197
not destination.ip:(
197-
10.0.0.0/8 or 100.64.0.0/10 or 127.0.0.0/8 or 169.254.0.0/16 or 172.16.0.0/12 or 192.0.0.0/24 or 192.0.0.0/29 or
198-
192.0.0.10/32 or 192.0.0.170/32 or 192.0.0.171/32 or 192.0.0.8/32 or 192.0.0.9/32 or 192.0.2.0/24 or
199-
192.168.0.0/16 or 192.175.48.0/24 or 192.31.196.0/24 or 192.52.193.0/24 or 192.88.99.0/24 or 198.18.0.0/15 or
200-
198.51.100.0/24 or 203.0.113.0/24 or 224.0.0.0/4 or 240.0.0.0/4 or "::1" or "FE80::/10" or "FF00::/8" or 0.0.0.0
198+
0.0.0.0 or 10.0.0.0/8 or 100.64.0.0/10 or 127.0.0.0/8 or 169.254.0.0/16 or 172.16.0.0/12 or 192.0.0.0/24 or 192.0.0.0/29 or
199+
192.0.0.10/32 or 192.0.0.170/32 or 192.0.0.171/32 or 192.0.0.8/32 or 192.0.0.9/32 or 192.0.2.0/24 or 192.168.0.0/16 or
200+
192.175.48.0/24 or 192.31.196.0/24 or 192.52.193.0/24 or 192.88.99.0/24 or 198.18.0.0/15 or 198.51.100.0/24 or 203.0.113.0/24
201+
or 224.0.0.0/4 or 240.0.0.0/4 or "::1" or "FE80::/10" or "FF00::/8"
201202
)
202203
'''
203204

204-
205205
[[rule.threat]]
206206
framework = "MITRE ATT&CK"
207+
207208
[[rule.threat.technique]]
208209
id = "T1071"
209210
name = "Application Layer Protocol"
210211
reference = "https://attack.mitre.org/techniques/T1071/"
211212

212-
213213
[rule.threat.tactic]
214214
id = "TA0011"
215215
name = "Command and Control"
216216
reference = "https://attack.mitre.org/tactics/TA0011/"
217217

218218
[rule.new_terms]
219219
field = "new_terms_fields"
220-
value = ["host.id", "process.executable"]
220+
value = ["process.executable"]
221221

222222
[[rule.new_terms.history_window_start]]
223223
field = "history_window_start"
224-
value = "now-14d"
225-
226-
224+
value = "now-20d"

rules/linux/defense_evasion_binary_copied_to_suspicious_directory.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -71,7 +71,9 @@ file.Ext.original.path : (
7171
"/usr/bin/update-alternatives", "/bin/update-alternatives", "/usr/sbin/update-alternatives",
7272
"/sbin/update-alternatives", "/usr/bin/pip3", "/bin/pip3", "/usr/local/bin/pip3", "/usr/local/bin/node",
7373
"/bin/node", "/usr/bin/node", "/sbin/apk", "/usr/sbin/apk", "/usr/local/sbin/apk", "/usr/bin/pip", "/bin/pip",
74-
"/usr/local/bin/pip"
74+
"/usr/local/bin/pip", "/usr/libexec/platform-python", "/usr/bin/platform-python", "/bin/platform-python",
75+
"/usr/lib/systemd/systemd", "/usr/sbin/sshd", "/sbin/sshd", "/usr/local/sbin/sshd", "/usr/sbin/crond", "/sbin/crond",
76+
"/usr/local/sbin/crond", "/usr/sbin/gdm",
7577
) or
7678
file.Ext.original.path : (
7779
"/bin/*.tmp", "/usr/bin/*.tmp", "/usr/local/bin/*.tmp", "/sbin/*.tmp", "/usr/sbin/*.tmp", "/usr/local/sbin/*.tmp"

rules/linux/execution_suspicious_executable_running_system_commands.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -58,41 +58,47 @@ timestamp_override = "event.ingested"
5858
type = "new_terms"
5959

6060
query = '''
61-
host.os.type:linux and event.category:process and event.action:(exec or exec_event or fork or fork_event) and
61+
host.os.type:linux and event.category:process and event.action:(exec or exec_event or fork or fork_event) and
6262
process.executable:(
63-
/bin/* or /usr/bin/* or /usr/share/* or /tmp/* or /var/tmp/* or /dev/shm/* or
64-
/etc/init.d/* or /etc/rc*.d/* or /etc/crontab or /etc/cron.*/* or /etc/update-motd.d/* or
65-
/usr/lib/update-notifier/* or /home/*/.* or /boot/* or /srv/* or /run/*)
66-
and process.args:(whoami or id or hostname or uptime or top or ifconfig or netstat or route or ps or pwd or ls) and
67-
not process.name:(sudo or which or whoami or id or hostname or uptime or top or netstat or ps or pwd or ls or apt or
68-
dpkg or yum or rpm or dnf or dockerd or docker or snapd or snap) and
69-
not process.parent.executable:(/bin/* or /usr/bin/* or /run/k3s/* or /etc/network/* or /opt/Elastic/*)
63+
(/etc/crontab or /bin/* or /boot/* or /dev/shm/* or /etc/cron.*/* or /etc/init.d/* or /etc/rc*.d/* or
64+
/etc/update-motd.d/* or /home/*/.* or /tmp/* or /usr/bin/* or /usr/lib/update-notifier/* or
65+
/usr/share/* or /var/tmp/*) and not /tmp/go-build*
66+
) and
67+
process.args:(hostname or id or ifconfig or ls or netstat or ps or pwd or route or top or uptime or whoami) and
68+
not process.name:(
69+
apt or dnf or docker or dockerd or dpkg or hostname or id or ls or netstat or ps or pwd or rpm or snap or snapd
70+
or sudo or top or uptime or which or whoami or yum
71+
) and
72+
not process.parent.executable:(
73+
/opt/cassandra/bin/cassandra or /opt/nessus/sbin/nessusd or /opt/nessus_agent/sbin/nessus-agent-module or
74+
/opt/puppetlabs/puppet/bin/puppet or /opt/puppetlabs/puppet/bin/ruby or /usr/libexec/platform-python or
75+
/usr/local/cloudamize/bin/CCAgent or /usr/sbin/sshd or /bin/* or /etc/network/* or /opt/Elastic/* or
76+
/run/k3s/* or /tmp/newroot/* or /usr/bin/*
77+
)
7078
'''
7179

72-
7380
[[rule.threat]]
7481
framework = "MITRE ATT&CK"
82+
7583
[[rule.threat.technique]]
7684
id = "T1059"
7785
name = "Command and Scripting Interpreter"
7886
reference = "https://attack.mitre.org/techniques/T1059/"
87+
7988
[[rule.threat.technique.subtechnique]]
8089
id = "T1059.004"
8190
name = "Unix Shell"
8291
reference = "https://attack.mitre.org/techniques/T1059/004/"
8392

84-
85-
8693
[rule.threat.tactic]
8794
id = "TA0002"
8895
name = "Execution"
8996
reference = "https://attack.mitre.org/tactics/TA0002/"
9097

9198
[rule.new_terms]
9299
field = "new_terms_fields"
93-
value = ["host.id", "user.id", "process.executable"]
100+
value = ["process.parent.executable"]
101+
94102
[[rule.new_terms.history_window_start]]
95103
field = "history_window_start"
96104
value = "now-14d"
97-
98-

rules/linux/execution_unknown_rwx_mem_region_binary_executed.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -50,33 +50,36 @@ timestamp_override = "event.ingested"
5050
type = "new_terms"
5151

5252
query = '''
53-
event.category:process and host.os.type:linux and auditd.data.syscall:mprotect and auditd.data.a2:7
53+
event.category:process and host.os.type:linux and auditd.data.syscall:mprotect and auditd.data.a2:7 and not (
54+
process.executable:(
55+
"/usr/share/kibana/node/bin/node" or "/usr/share/elasticsearch/jdk/bin/java" or "/usr/sbin/apache2"
56+
) or
57+
process.name:httpd
58+
)
5459
'''
5560

56-
5761
[[rule.threat]]
5862
framework = "MITRE ATT&CK"
63+
5964
[[rule.threat.technique]]
6065
id = "T1059"
6166
name = "Command and Scripting Interpreter"
6267
reference = "https://attack.mitre.org/techniques/T1059/"
68+
6369
[[rule.threat.technique.subtechnique]]
6470
id = "T1059.004"
6571
name = "Unix Shell"
6672
reference = "https://attack.mitre.org/techniques/T1059/004/"
6773

68-
69-
7074
[rule.threat.tactic]
7175
id = "TA0002"
7276
name = "Execution"
7377
reference = "https://attack.mitre.org/tactics/TA0002/"
7478

7579
[rule.new_terms]
7680
field = "new_terms_fields"
77-
value = ["host.id", "process.executable"]
81+
value = ["process.executable"]
82+
7883
[[rule.new_terms.history_window_start]]
7984
field = "history_window_start"
8085
value = "now-7d"
81-
82-

rules/linux/impact_potential_linux_ransomware_note_detected.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -54,18 +54,17 @@ tags = [
5454
"Data Source: Elastic Defend",
5555
]
5656
type = "eql"
57-
5857
query = '''
5958
sequence by process.entity_id, host.id with maxspan=1s
6059
[file where host.os.type == "linux" and event.type == "change" and event.action == "rename" and file.extension : "?*"
61-
and process.executable : ("./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/var/run/*", "/boot/*", "/srv/*", "/run/*") and
60+
and process.executable : ("./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/var/run/*", "/boot/*") and
6261
file.path : (
6362
"/home/*/Downloads/*", "/home/*/Documents/*", "/root/*", "/bin/*", "/usr/bin/*", "/var/log/*", "/var/lib/log/*",
6463
"/var/backup/*", "/var/www/*") and
6564
not process.name : (
6665
"dpkg", "yum", "dnf", "rpm", "dockerd", "go", "java", "pip*", "python*", "node", "containerd", "php", "p4d",
6766
"conda", "chrome", "imap", "cmake", "firefox", "semanage", "semodule", "ansible-galaxy", "fc-cache", "jammy", "git",
68-
"systemsettings", "vmis-launcher", "bundle", "kudu-tserver", "suldownloader"
67+
"systemsettings", "vmis-launcher", "bundle", "kudu-tserver", "suldownloader", "rustup-init"
6968
)
7069
] with runs=25
7170
[file where host.os.type == "linux" and event.action == "creation" and file.name : (
@@ -74,17 +73,15 @@ sequence by process.entity_id, host.id with maxspan=1s
7473
]
7574
'''
7675

77-
7876
[[rule.threat]]
7977
framework = "MITRE ATT&CK"
78+
8079
[[rule.threat.technique]]
8180
id = "T1486"
8281
name = "Data Encrypted for Impact"
8382
reference = "https://attack.mitre.org/techniques/T1486/"
8483

85-
8684
[rule.threat.tactic]
8785
id = "TA0040"
8886
name = "Impact"
8987
reference = "https://attack.mitre.org/tactics/TA0040/"
90-

rules/linux/persistence_apt_package_manager_netcon.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -65,7 +65,15 @@ sequence by host.id with maxspan=5s
6565
"bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish"
6666
)
6767
] by process.entity_id
68-
[network where host.os.type == "linux" and event.action == "connection_attempted" and event.type == "start"
68+
[network where host.os.type == "linux" and event.action == "connection_attempted" and event.type == "start" and not (
69+
destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
70+
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",
71+
"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",
72+
"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",
73+
"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",
74+
"FF00::/8", "172.31.0.0/16"
75+
)
76+
) and not process.executable == "/usr/bin/apt-listbugs"
6977
] by process.parent.entity_id
7078
'''
7179

rules/linux/persistence_cron_job_creation.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -190,13 +190,18 @@ event.action in ("rename", "creation") and file.path : (
190190
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
191191
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
192192
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
193-
"/bin/pamac-daemon", "/usr/local/bin/dockerd"
193+
"/bin/pamac-daemon", "/usr/local/bin/dockerd", "/opt/elasticbeanstalk/bin/platform-engine",
194+
"/opt/puppetlabs/puppet/bin/ruby", "/usr/libexec/platform-python", "/opt/imunify360/venv/bin/python3",
195+
"/opt/eset/efs/lib/utild", "/usr/sbin/anacron", "/usr/bin/podman", "/kaniko/kaniko-executor"
194196
) or
195197
file.path : "/var/spool/cron/crontabs/tmp.*" or
196198
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
197199
file.Ext.original.extension == "dpkg-new" or
198-
process.executable : ("/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*") or
200+
process.executable : (
201+
"/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/libexec/platform-python*"
202+
) or
199203
process.executable == null or
204+
process.name in ("crontab", "crond", "executor", "puppet", "droplet-agent.postinst", "cf-agent") or
200205
(process.name == "sed" and file.name : "sed*") or
201206
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
202207
)

rules/linux/persistence_kde_autostart_modification.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -221,7 +221,7 @@ file where host.os.type == "linux" and event.type != "deletion" and
221221
"/etc/xdg/autostart/*", "/usr/share/autostart/*"
222222
) and
223223
not process.name in ("yum", "dpkg", "install", "dnf", "teams", "yum-cron", "dnf-automatic", "docker", "dockerd",
224-
"rpm", "pacman", "podman", "nautilus", "remmina", "cinnamon-settings.py")
224+
"rpm", "pacman", "podman", "nautilus", "remmina", "cinnamon-settings.py", "executor")
225225
'''
226226

227227

0 commit comments

Comments
 (0)