Skip to content

Commit 08b3c16

Browse files
committed
[New Rule] Unusual Web Server Command Execution
1 parent f14a527 commit 08b3c16

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
[metadata]
2+
creation_date = "2025/12/02"
3+
integration = ["endpoint"]
4+
maturity = "production"
5+
updated_date = "2025/12/02"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule leverages the "new_terms" rule type to detect unusual command executions originating from web server processes on Linux systems.
11+
Attackers may exploit web servers to maintain persistence on a compromised system, often resulting in atypical command executions. As
12+
command execution from web server parent processes is common, the "new_terms" rule type approach helps to identify deviations from normal
13+
behavior.
14+
"""
15+
from = "now-9m"
16+
index = ["logs-endpoint.events.process*"]
17+
language = "kuery"
18+
license = "Elastic License v2"
19+
name = "Unusual Web Server Command Execution"
20+
risk_score = 47
21+
rule_id = "65f28c4d-cfc8-4847-9cca-f2fb1e319151"
22+
severity = "medium"
23+
tags = [
24+
"Domain: Endpoint",
25+
"OS: Linux",
26+
"Use Case: Threat Detection",
27+
"Tactic: Persistence",
28+
"Data Source: Elastic Defend",
29+
]
30+
timestamp_override = "event.ingested"
31+
type = "new_terms"
32+
query = '''
33+
event.category:process and host.os.type:linux and event.type:start and event.action:exec and (
34+
process.parent.name:(
35+
"apache" or "nginx" or "apache2" or "httpd" or "lighttpd" or "caddy" or "mongrel_rails" or "haproxy" or
36+
"gunicorn" or "uwsgi" or "openresty" or "cherokee" or "h2o" or "resin" or "puma" or "unicorn" or "traefik" or "uvicorn" or
37+
"tornado" or "hypercorn" or "daphne" or "twistd" or "yaws" or "webfsd" or "httpd.worker" or "flask" or "rails" or "mongrel" or
38+
php* or ruby* or perl* or python*
39+
) or
40+
user.name:("apache" or "www-data" or "httpd" or "nginx" or "lighttpd" or "tomcat" or "tomcat8" or "tomcat9") or
41+
user.id:("33" or "498" or "48" or "54321")
42+
) and process.working_directory:(
43+
/var/www/* or
44+
/usr/share/nginx/* or
45+
/srv/www/* or
46+
/srv/http/* or
47+
*/webapps/* or
48+
/home/*/public_html/* or
49+
/home/*/www/* or
50+
/opt/* or
51+
/u0*/*
52+
) and
53+
process.command_line:* and process.name:(bash or dash or sh or tcsh or csh or zsh or ksh or fish) and process.args:"-c" and
54+
not (
55+
(process.parent.name:java and process.parent.executable:/u0*/*) or
56+
(process.parent.name:python* and process.parent.executable:(/bin/python* or /usr/bin/python* or /usr/local/bin/python* or /tmp/*python* or /opt/oracle.ahf/python/*)) or
57+
(process.parent.name:ruby* and process.parent.executable:(/bin/ruby* or /usr/bin/ruby* or /usr/local/bin/ruby* or /tmp/*ruby* or /bin/ruby or /usr/bin/ruby or /usr/local/bin/ruby)) or
58+
(process.parent.name:perl* and process.parent.executable:(/bin/perl* or /usr/bin/perl* or /usr/local/bin/perl* or /tmp/*perl* or /bin/perl or /usr/bin/perl or /usr/local/bin/perl)) or
59+
(process.parent.name:php* and process.parent.executable:(/bin/php* or /usr/bin/php* or /usr/local/bin/php* or /tmp/*php* or /bin/php or /usr/bin/php or /usr/local/bin/php)) or
60+
(process.parent.name:node and process.parent.executable:(/home/*/.vscode-server/* or /users/*/.vscode-server/* or /bin/node or /usr/bin/node or /usr/local/bin/node or /opt/plesk/node/*/bin/node)) or
61+
process.working_directory:(/u0*/*/sysman/emd or /u0*/app/oracle/product/*/dbhome_* or /u0*/app/oracle/product/*/db_* or /var/www/*edoc*) or
62+
process.parent.executable:/tmp/* or
63+
process.args:/usr/local/bin/wkhtmltopdf*
64+
)
65+
'''
66+
67+
[[rule.threat]]
68+
framework = "MITRE ATT&CK"
69+
70+
[[rule.threat.technique]]
71+
id = "T1505"
72+
name = "Server Software Component"
73+
reference = "https://attack.mitre.org/techniques/T1505/"
74+
75+
[[rule.threat.technique.subtechnique]]
76+
id = "T1505.003"
77+
name = "Web Shell"
78+
reference = "https://attack.mitre.org/techniques/T1505/003/"
79+
80+
[rule.threat.tactic]
81+
id = "TA0003"
82+
name = "Persistence"
83+
reference = "https://attack.mitre.org/tactics/TA0003/"
84+
85+
[[rule.threat]]
86+
framework = "MITRE ATT&CK"
87+
88+
[[rule.threat.technique]]
89+
id = "T1059"
90+
name = "Command and Scripting Interpreter"
91+
reference = "https://attack.mitre.org/techniques/T1059/"
92+
93+
[[rule.threat.technique.subtechnique]]
94+
id = "T1059.004"
95+
name = "Unix Shell"
96+
reference = "https://attack.mitre.org/techniques/T1059/004/"
97+
98+
[rule.threat.tactic]
99+
id = "TA0002"
100+
name = "Execution"
101+
reference = "https://attack.mitre.org/tactics/TA0002/"
102+
103+
[[rule.threat]]
104+
framework = "MITRE ATT&CK"
105+
106+
[[rule.threat.technique]]
107+
id = "T1071"
108+
name = "Application Layer Protocol"
109+
reference = "https://attack.mitre.org/techniques/T1071/"
110+
111+
[rule.threat.tactic]
112+
id = "TA0011"
113+
name = "Command and Control"
114+
reference = "https://attack.mitre.org/tactics/TA0011/"
115+
116+
[rule.new_terms]
117+
field = "new_terms_fields"
118+
value = ["process.command_line"]
119+
120+
[[rule.new_terms.history_window_start]]
121+
field = "history_window_start"
122+
value = "now-14d"

0 commit comments

Comments
 (0)