Skip to content

Commit 2ec2b44

Browse files
Aegrahgithub-actions[bot]
authored andcommitted
[Rule Tuning] Q2 Linux DR Tuning - Part 3 (#4164)
* [Rule Tuning] Q2 Linux DR Tuning - Part 3 * Update execution_suspicious_executable_running_system_commands.toml (cherry picked from commit 39fc23c)
1 parent 4fa4c3b commit 2ec2b44

11 files changed

+101
-79
lines changed

rules/linux/execution_abnormal_process_id_file_created.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -109,40 +109,51 @@ tags = [
109109
]
110110
timestamp_override = "event.ingested"
111111
type = "new_terms"
112-
113112
query = '''
114113
host.os.type:linux and event.category:file and event.action:(creation or file_create_event) and
115-
user.id:0 and file.extension:(pid or lock or reboot) and file.path:(/var/run/* or /run/*) and (
114+
file.extension:(pid or lock or reboot) and file.path:(/var/run/* or /run/*) and (
116115
(process.name : (
117116
bash or dash or sh or tcsh or csh or zsh or ksh or fish or ash or touch or nano or vim or vi or editor or mv or cp)
118117
) or (
119118
process.executable : (
120119
./* or /tmp/* or /var/tmp/* or /dev/shm/* or /var/run/* or /boot/* or /srv/* or /run/*
121120
))
122-
) and not process.name : (go or git or containerd* or snap-confine or cron or crond or sshd or unattended-upgrade or
123-
vzctl or ifup or rpcbind or runc or gitlab-runner-helper or elastic-agent or metricbeat) and
124-
not file.name : (jem.*.pid)
121+
) and not (
122+
process.executable : (
123+
/tmp/newroot/* or /run/containerd/* or /run/k3s/containerd/* or /run/k0s/container* or /snap/* or /vz/* or
124+
/var/lib/docker/* or /etc/*/universal-hooks/pkgs/mysql-community-server/* or /var/lib/snapd/* or /etc/rubrik/* or
125+
/run/udev/data/*
126+
) or
127+
process.name : (
128+
go or git or containerd* or snap-confine or cron or crond or sshd or unattended-upgrade or vzctl or ifup or
129+
rpcbind or runc or gitlab-runner-helper or elastic-agent or metricbeat or redis-server or
130+
s6-ipcserver-socketbinder or xinetd
131+
) or
132+
file.name : (
133+
jem.*.pid or lynis.pid or redis.pid or yum.pid or MFS.pid or jenkins.pid or nvmupdate.pid or openlitespeed.pid or
134+
rhnsd.pid
135+
) or
136+
file.path : (/run/containerd/* or /var/run/docker/containerd/* or /var/run/jem*.pid)
137+
)
125138
'''
126139

127-
128140
[[rule.threat]]
129141
framework = "MITRE ATT&CK"
142+
130143
[[rule.threat.technique]]
131144
id = "T1106"
132145
name = "Native API"
133146
reference = "https://attack.mitre.org/techniques/T1106/"
134147

135-
136148
[rule.threat.tactic]
137149
id = "TA0002"
138150
name = "Execution"
139151
reference = "https://attack.mitre.org/tactics/TA0002/"
140152

141153
[rule.new_terms]
142154
field = "new_terms_fields"
143-
value = ["host.id", "process.executable", "file.path"]
155+
value = ["process.executable", "file.name"]
156+
144157
[[rule.new_terms.history_window_start]]
145158
field = "history_window_start"
146159
value = "now-14d"
147-
148-

rules/linux/execution_cupsd_foomatic_rip_lp_user_execution.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -111,8 +111,13 @@ type = "eql"
111111
query = '''
112112
process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and user.name == "lp" and
113113
process.parent.name in ("cupsd", "foomatic-rip", "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
114-
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
115-
not process.command_line like ("*/tmp/foomatic-*", "*-sDEVICE=ps2write*")
114+
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and not (
115+
process.command_line like (
116+
"*/tmp/foomatic-*", "*-sDEVICE=ps2write*", "*printf*", "/bin/sh -e -c cat", "/bin/bash -c cat",
117+
"/bin/bash -e -c cat"
118+
) or
119+
process.args like "gs*"
120+
)
116121
'''
117122

118123
[[rule.threat]]

rules/linux/execution_cupsd_foomatic_rip_shell_execution.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -110,8 +110,13 @@ type = "eql"
110110
query = '''
111111
process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
112112
process.parent.name == "foomatic-rip" and
113-
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
114-
not process.command_line like ("*/tmp/foomatic-*", "*-sDEVICE=ps2write*")
113+
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and not (
114+
process.command_line like (
115+
"*/tmp/foomatic-*", "*-sDEVICE=ps2write*", "*printf*", "/bin/sh -e -c cat", "/bin/bash -c cat",
116+
"/bin/bash -e -c cat"
117+
) or
118+
process.args like "gs*"
119+
)
115120
'''
116121

117122
[[rule.threat]]

rules/linux/execution_cupsd_foomatic_rip_suspicious_child_execution.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -132,7 +132,7 @@ process.parent.name in ("foomatic-rip", "cupsd") and process.command_line like (
132132
133133
// misc. suspicious command lines
134134
"*/etc/ld.so*", "*/dev/shm/*", "*/var/tmp*", "*echo*", "*>>*", "*|*"
135-
)
135+
) and not process.args like "gs*"
136136
'''
137137

138138
[[rule.threat]]

rules/linux/execution_curl_cve_2023_38545_heap_overflow.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -75,28 +75,27 @@ tags = [
7575
]
7676
timestamp_override = "event.ingested"
7777
type = "eql"
78-
7978
query = '''
8079
process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name == "curl"
8180
and (
82-
process.args : ("--socks5-hostname", "--proxy", "--preproxy", "socks5*") or
83-
process.env_vars: ("http_proxy=socks5h://*", "HTTPS_PROXY=socks5h://*", "ALL_PROXY=socks5h://*")
84-
) and length(process.command_line) > 255 and
85-
not process.parent.name in ("cf-agent", "agent-run", "agent-check", "rudder", "agent-inventory", "cf-execd") and
86-
not process.args == "/opt/rudder/bin/curl"
81+
process.args like ("--socks5-hostname", "--proxy", "--preproxy", "socks5*") or
82+
process.env_vars like ("http_proxy=socks5h://*", "HTTPS_PROXY=socks5h://*", "ALL_PROXY=socks5h://*")
83+
) and length(process.command_line) > 255 and not (
84+
process.parent.name in ("cf-agent", "agent-run", "agent-check", "rudder", "agent-inventory", "cf-execd") or
85+
process.args like "/opt/rudder/*" or
86+
process.parent.executable like ("/vz/root/*", "/var/rudder/*")
87+
)
8788
'''
8889

89-
9090
[[rule.threat]]
9191
framework = "MITRE ATT&CK"
92+
9293
[[rule.threat.technique]]
9394
id = "T1203"
9495
name = "Exploitation for Client Execution"
9596
reference = "https://attack.mitre.org/techniques/T1203/"
9697

97-
9898
[rule.threat.tactic]
9999
id = "TA0002"
100100
name = "Execution"
101101
reference = "https://attack.mitre.org/tactics/TA0002/"
102-

rules/linux/execution_file_execution_followed_by_deletion.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -52,36 +52,37 @@ tags = [
5252
"Data Source: Elastic Defend",
5353
]
5454
type = "eql"
55-
5655
query = '''
5756
sequence by host.id, user.id with maxspan=1m
5857
[file where host.os.type == "linux" and event.action == "creation" and
5958
process.name in ("curl", "wget", "fetch", "ftp", "sftp", "scp", "rsync", "ld") and
6059
file.path : ("/dev/shm/*", "/run/shm/*", "/tmp/*", "/var/tmp/*",
6160
"/run/*", "/var/run/*", "/var/www/*", "/proc/*/fd/*")] by file.name
6261
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
63-
process.parent.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")] by process.name
62+
process.parent.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
63+
not process.parent.executable like (
64+
"/tmp/VeeamApp*", "/tmp/rajh/spack-stage/*", "plz-out/bin/vault/bridge/test/e2e/base/bridge-dev",
65+
"/usr/bin/ranlib", "/usr/bin/ar", "plz-out/bin/vault/bridge/test/e2e/base/local-k8s"
66+
)] by process.name
6467
[file where host.os.type == "linux" and event.action == "deletion" and not process.name in ("rm", "ld") and
6568
file.path : ("/dev/shm/*", "/run/shm/*", "/tmp/*", "/var/tmp/*",
6669
"/run/*", "/var/run/*", "/var/www/*", "/proc/*/fd/*")] by file.name
6770
'''
6871

69-
7072
[[rule.threat]]
7173
framework = "MITRE ATT&CK"
74+
7275
[[rule.threat.technique]]
7376
id = "T1059"
7477
name = "Command and Scripting Interpreter"
7578
reference = "https://attack.mitre.org/techniques/T1059/"
79+
7680
[[rule.threat.technique.subtechnique]]
7781
id = "T1059.004"
7882
name = "Unix Shell"
7983
reference = "https://attack.mitre.org/techniques/T1059/004/"
8084

81-
82-
8385
[rule.threat.tactic]
8486
id = "TA0002"
8587
name = "Execution"
8688
reference = "https://attack.mitre.org/tactics/TA0002/"
87-

rules/linux/execution_netcon_from_rwx_mem_region_binary.toml

Lines changed: 7 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", "endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -53,43 +53,42 @@ tags = [
5353
]
5454
timestamp_override = "event.ingested"
5555
type = "eql"
56-
5756
query = '''
5857
sample by host.id, process.pid, process.name
5958
/* auditd.data.a2 == "7" translates to RWX memory region protection (PROT_READ | PROT_WRITE | PROT_EXEC) */
60-
[process where host.os.type == "linux" and auditd.data.syscall == "mprotect" and auditd.data.a2 == "7"]
59+
[process where host.os.type == "linux" and auditd.data.syscall == "mprotect" and auditd.data.a2 == "7" and
60+
not process.name == "httpd"]
6161
[network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and
6262
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
6363
'''
6464

65-
6665
[[rule.threat]]
6766
framework = "MITRE ATT&CK"
67+
6868
[[rule.threat.technique]]
6969
id = "T1059"
7070
name = "Command and Scripting Interpreter"
7171
reference = "https://attack.mitre.org/techniques/T1059/"
72+
7273
[[rule.threat.technique.subtechnique]]
7374
id = "T1059.004"
7475
name = "Unix Shell"
7576
reference = "https://attack.mitre.org/techniques/T1059/004/"
7677

77-
78-
7978
[rule.threat.tactic]
8079
id = "TA0002"
8180
name = "Execution"
8281
reference = "https://attack.mitre.org/tactics/TA0002/"
82+
8383
[[rule.threat]]
8484
framework = "MITRE ATT&CK"
85+
8586
[[rule.threat.technique]]
8687
id = "T1071"
8788
name = "Application Layer Protocol"
8889
reference = "https://attack.mitre.org/techniques/T1071/"
8990

90-
9191
[rule.threat.tactic]
9292
id = "TA0011"
9393
name = "Command and Control"
9494
reference = "https://attack.mitre.org/tactics/TA0011/"
95-

rules/linux/execution_network_event_post_compilation.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -52,45 +52,45 @@ tags = [
5252
"Data Source: Elastic Defend",
5353
]
5454
type = "eql"
55-
5655
query = '''
5756
sequence by host.id with maxspan=1m
5857
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
5958
process.name in ("gcc", "g++", "cc")] by process.args
6059
[file where host.os.type == "linux" and event.action == "creation" and process.name == "ld"] by file.name
6160
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec"] by process.name
62-
[network where host.os.type == "linux" and event.action == "connection_attempted" and destination.ip != null and
63-
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")] by process.name
61+
[network where host.os.type == "linux" and event.action == "connection_attempted" and destination.ip != null and not (
62+
cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1") or
63+
process.name in ("simpleX", "conftest", "ssh", "python", "ispnull", "pvtui")
64+
)] by process.name
6465
'''
6566

66-
6767
[[rule.threat]]
6868
framework = "MITRE ATT&CK"
69+
6970
[[rule.threat.technique]]
7071
id = "T1059"
7172
name = "Command and Scripting Interpreter"
7273
reference = "https://attack.mitre.org/techniques/T1059/"
74+
7375
[[rule.threat.technique.subtechnique]]
7476
id = "T1059.004"
7577
name = "Unix Shell"
7678
reference = "https://attack.mitre.org/techniques/T1059/004/"
7779

78-
79-
8080
[rule.threat.tactic]
8181
id = "TA0002"
8282
name = "Execution"
8383
reference = "https://attack.mitre.org/tactics/TA0002/"
84+
8485
[[rule.threat]]
8586
framework = "MITRE ATT&CK"
87+
8688
[[rule.threat.technique]]
8789
id = "T1071"
8890
name = "Application Layer Protocol"
8991
reference = "https://attack.mitre.org/techniques/T1071/"
9092

91-
9293
[rule.threat.tactic]
9394
id = "TA0011"
9495
name = "Command and Control"
9596
reference = "https://attack.mitre.org/tactics/TA0011/"
96-

0 commit comments

Comments
 (0)