Skip to content

Commit 4ffed36

Browse files
Aegrahtradebot-elastic
authored andcommitted
[Rule Tuning] Misc. Linux Community Tunings (#5160)
* [Rule Tuning] Misc. Linux Community Tunings * ++ * Fix query syntax in execution_unusual_path_invocation rule * Refactor process.parent conditions for clarity (cherry picked from commit be3af09)
1 parent 1e65442 commit 4ffed36

8 files changed

+94
-52
lines changed

rules/linux/defense_evasion_attempt_to_disable_syslog_service.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2020/04/27"
33
integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/29"
66

77
[rule]
88
author = ["Elastic"]
@@ -109,32 +109,32 @@ tags = [
109109
]
110110
timestamp_override = "event.ingested"
111111
type = "eql"
112-
113112
query = '''
114113
process where host.os.type == "linux" and event.action in ("exec", "exec_event", "start", "ProcessRollup2") and
115114
( (process.name == "service" and process.args == "stop") or
116115
(process.name == "chkconfig" and process.args == "off") or
117116
(process.name == "systemctl" and process.args in ("disable", "stop", "kill"))
118117
) and process.args in ("syslog", "rsyslog", "syslog-ng", "syslog.service", "rsyslog.service", "syslog-ng.service") and
119-
not process.parent.name == "rsyslog-rotate"
118+
not (
119+
process.parent.name == "rsyslog-rotate" or
120+
process.args == "HUP"
121+
)
120122
'''
121123

122-
123124
[[rule.threat]]
124125
framework = "MITRE ATT&CK"
126+
125127
[[rule.threat.technique]]
126128
id = "T1562"
127129
name = "Impair Defenses"
128130
reference = "https://attack.mitre.org/techniques/T1562/"
131+
129132
[[rule.threat.technique.subtechnique]]
130133
id = "T1562.001"
131134
name = "Disable or Modify Tools"
132135
reference = "https://attack.mitre.org/techniques/T1562/001/"
133136

134-
135-
136137
[rule.threat.tactic]
137138
id = "TA0005"
138139
name = "Defense Evasion"
139140
reference = "https://attack.mitre.org/tactics/TA0005/"
140-

rules/linux/defense_evasion_dynamic_linker_file_creation.toml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
creation_date = "2024/08/08"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2025/02/04"
5+
updated_date = "2025/09/29"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Detects the creation or modification of files related to the dynamic linker on Linux systems. The dynamic linker is a
11-
shared library that is used by the Linux kernel to load and execute programs. Attackers may attempt to hijack the
12-
execution flow of a program by modifying the dynamic linker configuration files.
10+
Detects the creation or modification of files related to the configuration of the dynamic linker on Linux systems.
11+
The dynamic linker is a shared library that is used by the Linux kernel to load and execute programs. Attackers may
12+
attempt to hijack the execution flow of a program by modifying the dynamic linker configuration files. This technique
13+
is often observed by userland rootkits that leverage shared objects to maintain persistence on a compromised host.
1314
"""
1415
from = "now-9m"
1516
index = ["logs-endpoint.events.file*"]
@@ -66,22 +67,27 @@ not (
6667
"/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
6768
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
6869
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
69-
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
70+
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/usr/bin/pamac-daemon",
7071
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python",
71-
"/usr/lib/snapd/snap-update-ns", "/usr/bin/vmware-config-tools.pl"
72+
"/usr/lib/snapd/snap-update-ns", "/usr/bin/vmware-config-tools.pl", "./usr/bin/podman", "/bin/nvidia-cdi-hook",
73+
"/usr/lib/dracut/dracut-install", "./usr/bin/nvidia-cdi-hook", "/.envbuilder/bin/envbuilder", "/usr/bin/buildah",
74+
"/usr/sbin/dnf", "/usr/bin/pamac", "/sbin/pacman", "/usr/bin/crio", "/usr/sbin/yum-cron"
7275
) or
7376
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
7477
file.Ext.original.extension == "dpkg-new" or
7578
process.executable : (
76-
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*", "/opt/dynatrace/oneagent/*"
79+
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*", "/opt/dynatrace/oneagent/*",
80+
"/usr/libexec/platform-python*"
7781
) or
7882
process.executable == null or
7983
process.name in (
8084
"java", "executor", "ssm-agent-worker", "packagekitd", "crio", "dockerd-entrypoint.sh",
81-
"docker-init", "BootTimeChecker"
85+
"docker-init", "BootTimeChecker", "dockerd (deleted)", "dockerd"
8286
) or
8387
(process.name == "sed" and file.name : "sed*") or
84-
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
88+
(process.name == "perl" and file.name : "e2scrub_all.tmp*") or
89+
(process.name == "init" and file.name == "ld.wsl.conf") or
90+
(process.name == "sshd" and file.extension == "dpkg-new")
8591
)
8692
'''
8793
note = """## Triage and analysis

rules/linux/defense_evasion_kill_command_executed.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -90,7 +90,10 @@ timestamp_override = "event.ingested"
9090
type = "new_terms"
9191
query = '''
9292
event.category:process and host.os.type:linux and event.type:start and event.action:exec and
93-
process.name:(kill or pkill or killall)
93+
process.name:(kill or pkill or killall) and not (
94+
process.args:("-HUP" or "-SIGUSR1" or "-USR2" or "-WINCH" or "-USR1") or
95+
process.parent.command_line:"runc init"
96+
)
9497
'''
9598

9699
[[rule.threat]]

rules/linux/defense_evasion_ld_so_creation.toml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
creation_date = "2024/12/16"
33
integration = ["endpoint", "sentinel_one_cloud_funnel"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/29"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
This rule detects the creation of the dynamic linker (ld.so) file. The dynamic linker is used to load shared libraries
10+
This rule detects the creation of the dynamic linker (ld.so). The dynamic linker is used to load shared libraries
1111
needed by an executable. Attackers may attempt to replace the dynamic linker with a malicious version to execute
1212
arbitrary code.
1313
"""
@@ -52,7 +52,7 @@ The dynamic linker, ld.so, is crucial in Linux environments for loading shared l
5252
- Review system logs and the process creation history to identify the source of the unauthorized ld.so creation and any associated malicious activity.
5353
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if other systems are affected.
5454
- Implement additional monitoring and alerting for similar suspicious activities, such as unauthorized file creations in critical system directories, to enhance future detection capabilities."""
55-
risk_score = 21
55+
risk_score = 47
5656
rule_id = "06d555e4-c8ce-4d90-90e1-ec7f66df5a6a"
5757
setup = """## Setup
5858
@@ -79,7 +79,7 @@ For more details on Elastic Agent configuration settings, refer to the [helper g
7979
- 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.
8080
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
8181
"""
82-
severity = "low"
82+
severity = "medium"
8383
tags = [
8484
"Domain: Endpoint",
8585
"OS: Linux",
@@ -94,58 +94,68 @@ tags = [
9494
]
9595
timestamp_override = "event.ingested"
9696
type = "eql"
97-
9897
query = '''
9998
file where host.os.type == "linux" and event.type == "creation" and process.executable != null and
10099
file.path like~ ("/lib/ld-linux*.so*", "/lib64/ld-linux*.so*", "/usr/lib/ld-linux*.so*", "/usr/lib64/ld-linux*.so*") and
101-
not process.name in ("dockerd", "yum", "dnf", "microdnf", "pacman")
100+
not process.executable in (
101+
"/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
102+
"/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
103+
"/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
104+
"/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
105+
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
106+
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
107+
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
108+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python",
109+
"/usr/lib/snapd/snap-update-ns", "./usr/bin/podman", "/usr/bin/crio", "/usr/bin/buildah", "/bin/dnf5",
110+
"/usr/bin/dnf5", "/usr/bin/pamac"
111+
)
102112
'''
103113

104-
105114
[[rule.threat]]
106115
framework = "MITRE ATT&CK"
116+
107117
[[rule.threat.technique]]
108118
id = "T1218"
109119
name = "System Binary Proxy Execution"
110120
reference = "https://attack.mitre.org/techniques/T1218/"
111121

112-
113122
[rule.threat.tactic]
114123
id = "TA0005"
115124
name = "Defense Evasion"
116125
reference = "https://attack.mitre.org/tactics/TA0005/"
126+
117127
[[rule.threat]]
118128
framework = "MITRE ATT&CK"
129+
119130
[[rule.threat.technique]]
120131
id = "T1059"
121132
name = "Command and Scripting Interpreter"
122133
reference = "https://attack.mitre.org/techniques/T1059/"
134+
123135
[[rule.threat.technique.subtechnique]]
124136
id = "T1059.004"
125137
name = "Unix Shell"
126138
reference = "https://attack.mitre.org/techniques/T1059/004/"
127139

128-
129-
130140
[rule.threat.tactic]
131141
id = "TA0002"
132142
name = "Execution"
133143
reference = "https://attack.mitre.org/tactics/TA0002/"
144+
134145
[[rule.threat]]
135146
framework = "MITRE ATT&CK"
147+
136148
[[rule.threat.technique]]
137149
id = "T1574"
138150
name = "Hijack Execution Flow"
139151
reference = "https://attack.mitre.org/techniques/T1574/"
152+
140153
[[rule.threat.technique.subtechnique]]
141154
id = "T1574.006"
142155
name = "Dynamic Linker Hijacking"
143156
reference = "https://attack.mitre.org/techniques/T1574/006/"
144157

145-
146-
147158
[rule.threat.tactic]
148159
id = "TA0003"
149160
name = "Persistence"
150161
reference = "https://attack.mitre.org/tactics/TA0003/"
151-

rules/linux/execution_unusual_path_invocation_from_command_line.toml

Lines changed: 10 additions & 2 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 = "2025/01/24"
5+
updated_date = "2025/09/29"
66

77
[rule]
88
author = ["Elastic"]
@@ -59,7 +59,15 @@ type = "new_terms"
5959
query = '''
6060
event.category:process and host.os.type:linux and event.type:start and event.action:exec and
6161
process.name:(bash or csh or dash or fish or ksh or sh or tcsh or zsh) and process.args:-c and
62-
process.command_line:(*PATH=* and not sh*/run/motd.dynamic.new)
62+
process.command_line:*PATH=* and
63+
not (
64+
process.command_line:(*_PATH=* or *PYTHONPATH=* or sh*/run/motd.dynamic.new) or
65+
process.parent.executable:(
66+
"/opt/puppetlabs/puppet/bin/puppet" or /var/lib/docker/overlay2/* or /vz/root/*/dovecot or
67+
"/usr/libexec/dovecot/auth" or /home/*/.local/share/containers/* or /vz/root/*/dovecot/auth
68+
) or
69+
process.parent.command_line:"runc init"
70+
)
6371
'''
6472
note = """## Triage and analysis
6573

rules/linux/lateral_movement_unusual_remote_file_creation.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -53,7 +53,7 @@ Remote file creation tools like SCP, FTP, and SFTP are essential for transferrin
5353
- Implement stricter access controls and authentication mechanisms for remote file transfer services to prevent unauthorized use.
5454
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems have been compromised.
5555
"""
56-
risk_score = 47
56+
risk_score = 21
5757
rule_id = "ed3fedc3-dd10-45a5-a485-34a8b48cea46"
5858
setup = """## Setup
5959
@@ -92,7 +92,7 @@ Auditbeat is a lightweight shipper that you can install on your servers to audit
9292
- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
9393
- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
9494
"""
95-
severity = "medium"
95+
severity = "low"
9696
tags = [
9797
"Domain: Endpoint",
9898
"OS: Linux",
@@ -106,9 +106,16 @@ type = "new_terms"
106106
query = '''
107107
event.category:file and host.os.type:linux and event.action:creation and
108108
process.name:(scp or ftp or sftp or vsftpd or sftp-server or sync) and
109-
not file.path:(/dev/ptmx or /run/* or /var/run/*)
109+
not (
110+
file.path:(
111+
/dev/ptmx or /run/* or /var/run/* or /home/*/.ansible/*AnsiballZ_*.py or /home/*/.ansible/tmp/ansible-tmp* or
112+
/root/.ansible/*AnsiballZ_*.py or /tmp/ansible-chief/ansible-tmp*AnsiballZ_*.py or
113+
/tmp/newroot/home/*/.ansible/tmp/ansible-tmp*AnsiballZ_*.py or /tmp/.ansible/tmp/ansible-tmp*AnsiballZ_*.py or
114+
/tmp/ansible-tmp-*/AnsiballZ_*.py or /tmp/.ansible/ansible-tmp-*AnsiballZ_*.py
115+
) or
116+
file.extension:(filepart or yaml or new or rpm or deb)
117+
)
110118
'''
111-
112119
[[rule.threat]]
113120
framework = "MITRE ATT&CK"
114121

rules/linux/persistence_cron_job_creation.toml

Lines changed: 7 additions & 5 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 = "2025/02/03"
5+
updated_date = "2025/09/29"
66

77
[transform]
88
[[transform.osquery]]
@@ -48,7 +48,6 @@ query = "SELECT * FROM users WHERE username = {{user.name}}"
4848
label = "Osquery - Investigate the Account Authentication Status"
4949
query = "SELECT * FROM logged_in_users WHERE user = {{user.name}}"
5050

51-
5251
[rule]
5352
author = ["Elastic"]
5453
description = """
@@ -194,21 +193,24 @@ event.action in ("rename", "creation") and file.path : (
194193
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
195194
"/bin/pamac-daemon", "/usr/local/bin/dockerd", "/opt/elasticbeanstalk/bin/platform-engine",
196195
"/opt/puppetlabs/puppet/bin/ruby", "/usr/libexec/platform-python", "/opt/imunify360/venv/bin/python3",
197-
"/opt/eset/efs/lib/utild", "/usr/sbin/anacron", "/usr/bin/podman", "/kaniko/kaniko-executor"
196+
"/opt/eset/efs/lib/utild", "/usr/sbin/anacron", "/usr/bin/podman", "/kaniko/kaniko-executor",
197+
"/usr/bin/pvedaemon", "./usr/bin/podman", "/usr/lib/systemd/systemd"
198198
) or
199199
file.path like ("/var/spool/cron/crontabs/tmp.*", "/etc/cron.d/jumpcloud-updater") or
200200
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
201201
file.Ext.original.extension == "dpkg-new" or
202202
process.executable : (
203-
"/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/libexec/platform-python*"
203+
"/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/libexec/platform-python*",
204+
"/var/lib/waagent/Microsoft*"
204205
) or
205206
process.executable == null or
206207
process.name in (
207208
"crond", "executor", "puppet", "droplet-agent.postinst", "cf-agent", "schedd", "imunify-notifier", "perl",
208209
"jumpcloud-agent", "crio", "dnf_install", "utild"
209210
) or
210211
(process.name == "sed" and file.name : "sed*") or
211-
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
212+
(process.name == "perl" and file.name : "e2scrub_all.tmp*") or
213+
(process.name in ("vi", "vim") and file.name like "*~")
212214
)
213215
'''
214216

0 commit comments

Comments
 (0)