| ID | Technique | Tactic |
|---|---|---|
| T1133 | External Remote Services | Initial Access |
| T1190 | Exploit Public-Facing Application | Persistence |
Detection: Web or Application Server Spawning a Shell
Description
This analytic identifies a Linux or Windows shell started by a web or application server process, including Java, PHP, Ruby workers running Puma workers, as well as Ghostscript image-rendering processes. It uses process creation telemetry and the parent-child relationship to identify unexpected command execution from a service. A shell launched by a rendering worker may follow activity in an upload or preview workflow; a matching process event is a behavioral signal and does not identify a specific vulnerability. Review the parent service, child command line, and nearby application activity to determine whether the action was authorized.
Search
1
2| tstats `security_content_summariesonly`
3 count min(_time) as firstTime
4 max(_time) as lastTime
5
6from datamodel=Endpoint.Processes where
7
8(
9 Processes.parent_process_name IN (
10 "apache*",
11 "caddy",
12 "httpd",
13 "java",
14 "lighttpd",
15 "nginx",
16 "gs",
17 "ghostscript",
18 "php*",
19 "ruby*",
20 "tomcat*"
21 )
22 `linux_shells`
23)
24OR
25(
26 Processes.parent_process_name IN (
27 "apache*.exe",
28 "beasvc.exe",
29 "caddy.exe",
30 "coldfusion.exe",
31 "frankenphp.exe",
32 "gswin32.exe",
33 "gswin32c.exe",
34 "gswin64.exe",
35 "gswin64c.exe",
36 "http*.exe",
37 "iisexpress.exe",
38 "java.exe",
39 "javaw.exe",
40 "jbosssvc.exe",
41 "jrun.exe",
42 "lighttpd.exe",
43 "lsphp*.exe",
44 "MSExchangeHMWorker.exe",
45 "nginx*.exe",
46 "openresty.exe",
47 "php*.exe",
48 "roadrunner.exe",
49 "ruby.exe",
50 "rubyw.exe",
51 "tomcat*.exe",
52 "traefik.exe",
53 "UMWorkerProcess.exe",
54 "w3wp.exe",
55 "wildfly-service.exe",
56 "ws_TomcatService.exe"
57 )
58 `windows_shells`
59)
60
61NOT Processes.parent_process_name IN ("phpstorm*")
62
63NOT (
64 Processes.parent_process_name="w3wp.exe"
65 Processes.parent_process_path="C:\\Windows\\System32\\inetsrv\\w3wp.exe"
66 Processes.parent_process="*mobileframe server (64-bit)*"
67 Processes.process_name="cmd.exe"
68 Processes.process IN (
69 "*/c ren *",
70 "*eemsp_test*",
71 "*getworkorderpart_*"
72 )
73)
74
75NOT (
76 Processes.process_current_directory = "/opt/nessus_agent/*"
77 Processes.process_path = "/bin/sh"
78)
79
80NOT (
81 Processes.process_current_directory = "/home/*/jenkins/*"
82 Processes.process_path IN ("/bin/sh", "/bin/bash", "/usr/bin/bash")
83)
84
85NOT (
86 Processes.parent_process_path = "*\\ArcGis\\Portal\\framework\\runtime\\jre\\bin\\*"
87 Processes.parent_process_name = "javaw.exe"
88 Processes.process_name = "cmd.exe"
89 Processes.process = "*whoami*"
90)
91
92NOT (
93 Processes.parent_process_path = "C:\\Program Files\\CCSI\\Instance_*"
94 Processes.parent_process_name = "httpd.exe"
95 Processes.process_name = "cmd.exe"
96 Processes.process = "* /s /c *"
97 Processes.process IN (
98 "*ObixHMAC.exe*",
99 "*TraceGen.exe*",
100 "*UAAnalyzer.exe*"
101 )
102)
103
104by Processes.action Processes.dest Processes.original_file_name Processes.parent_process
105 Processes.parent_process_exec Processes.parent_process_guid Processes.parent_process_id
106 Processes.parent_process_name Processes.parent_process_path Processes.process Processes.process_exec
107 Processes.process_guid Processes.process_hash Processes.process_id Processes.process_integrity_level
108 Processes.process_name Processes.process_path Processes.process_current_directory Processes.user Processes.user_id Processes.vendor_product
109
110
111| `drop_dm_object_name(Processes)`
112
113
114| where NOT (
115 parent_process_name="ruby"
116 AND match(parent_process_path, "(?i)^/home/[^/]+/[.]rvm/rubies/ruby-[^/]+/bin/ruby$")
117 AND match(parent_process, "(?i)/rspec tests/")
118 AND match(process_current_directory, "(?i)^/home/[^/]+/jenkins/workspace/.+$")
119 AND process="sh"
120)
121
122| where (
123 NOT match(parent_process_name, "(?i)^javaw?(\.exe)?$")
124 OR match(parent_process, "(?i)(org\.apache\.catalina\.startup\.Bootstrap
125|-Dcatalina\.base=
126|org\.eclipse\.jetty\.start\.Main
127|-Djetty\.home=
128|org\.jboss\.modules\.Main
129|-Djboss\.home\.dir=
130|weblogic\.Server
131|-Dweblogic\.Name=
132|weblogic-launcher\.jar
133|com\.ibm\.ws\.runtime\.WsServer
134|com\.ibm\.ws\.kernel\.boot\.cmdline\.Bootstrap
135|com\.sun\.enterprise\.glassfish\.bootstrap\.ASMain
136|com\.caucho\.server\.resin\.Resin)")
137 OR match(parent_process, "(?i)(org\.springframework\.boot\.loader\.
138|quarkus-run\.jar
139|io\.quarkus\.runner\.GeneratedMain
140|io\.micronaut\.runtime\.Micronaut
141|io\.dropwizard\.cli\.ServerCommand
142|play\.core\.server\.ProdServerStart
143|io\.helidon\.microprofile\.server\.Main
144|io\.helidon\.webserver
145|io\.vertx\.core\.Launcher)")
146 OR match(parent_process, "(?i)(org\.keycloak
147|org\.apereo\.cas
148|org\.elasticsearch\.bootstrap\.Elasticsearch
149|com\.atlassian\.jira\.startup\.Launcher
150|BitbucketServerLauncher
151|com\.google\.gerrit\.pgm\.Daemon
152|-Dsolr\.solr\.home=
153|jenkins\.war)")
154)
155
156
157| where (
158 NOT match(parent_process_name, "(?i)ruby")
159 OR match(coalesce(parent_process,""), "(?i)\b(rails
160|rack
161|rackup
162|puma
163|passenger
164|unicorn
165|thin
166|webrick
167|falcon
168|sidekiq
169|sinatra
170|hanami
171|agoo
172|iodine)\b")
173)
174
175
176| where NOT (
177 match(parent_process_name, "(?i)^php")
178 AND match(
179 lower(trim(process)),
180 "^(cmd\.exe /s /c \"stty 2> nul\"
181|c:\\\\windows\\\\system32\\\\cmd\.exe /s /c \"mode con\"
182|sh -c \"stty -a \
183| grep columns\"
184|sh -c nproc
185|sh -c \"stty -g\"
186|sh -c \"tput (cols
187|lines)\")$"
188 )
189)
190
191
192| `security_content_ctime(firstTime)`
193
194| `security_content_ctime(lastTime)`
195
196| `web_or_application_server_spawning_a_shell_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Sysmon for Linux EventID 1 | 'sysmon:linux' |
'Syslog:Linux-Sysmon/Operational' |
|
| Sysmon EventID 1 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
Macros Used
| Name | Value |
|---|---|
| security_content_summariesonly | summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config`` |
| web_or_application_server_spawning_a_shell_filter | search * |
web_or_application_server_spawning_a_shell_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
CVE
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Finding (Notable) | Yes |
| Rule Title | %name% |
| Rule Description | %description% |
| Notable Event Fields | user, dest |
| Creates Intermediate Finding (Risk Event) | No |
Implementation
The detection is based on data that originates from Endpoint Detection and Response (EDR) agents.
These agents are designed to provide security-related telemetry from the endpoints where the agent is installed.
To implement this search, you must ingest logs that contain the process GUID, process name, and parent process.
Additionally, you must ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product.
The logs must also be mapped to the Processes node of the Endpoint data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
Known False Positives
Filtering may be required on internal developer build systems or classify assets as web facing and restrict the analytic based on asset type.
Associated Analytic Story
Finding
| Title | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| An instance of [$parent_process_name$] spawning [$process_name$] with CommandLine [$process$] was identified on endpoint [$dest$], potentially indicative of exploitation. | dest | system | 50 |
Threat Objects
| Field | Type |
|---|---|
| process | process |
| parent_process_name | parent_process_name |
| process_name | process_name |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | Syslog:Linux-Sysmon/Operational |
sysmon:linux |
| Integration | ✅ Passing | Dataset | Syslog:Linux-Sysmon/Operational |
sysmon:linux |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub |
Version: 9