Web or Application Server Spawning a Shell
Description
The following analytic detects instances where Java, web server, or application server processes spawn a Linux shell, which may indicate exploitation attempts. This detection leverages Endpoint Detection and Response (EDR) telemetry, focusing on process names and parent-child process relationships. This activity may indicate a compromised service leading to unauthorized shell access. If confirmed malicious, attackers could execute commands, escalate privileges, or maintain persistent access.
Query · spl
| tstats `security_content_summariesonly`
count min(_time) as firstTime
max(_time) as lastTime
from datamodel=Endpoint.Processes where
(
Processes.parent_process_name IN (
"apache*",
"caddy",
"httpd",
"java",
"lighttpd",
"nginx",
"php*",
"tomcat*"
)
`linux_shells`
)
OR
(
Processes.parent_process_name IN (
"apache*.exe",
"beasvc.exe",
"caddy.exe",
"coldfusion.exe",
"frankenphp.exe",
"http*.exe",
"iisexpress.exe",
"java.exe",
"javaw.exe",
"jbosssvc.exe",
"jrun.exe",
"lighttpd.exe",
"lsphp*.exe",
"MSExchangeHMWorker.exe",
"nginx*.exe",
"openresty.exe",
"php*.exe",
"roadrunner.exe",
"tomcat*.exe",
"traefik.exe",
"UMWorkerProcess.exe",
"w3wp.exe",
"wildfly-service.exe",
"ws_TomcatService.exe"
)
`windows_shells`
)
NOT Processes.parent_process_name IN ("phpstorm*")
by Processes.action Processes.dest Processes.original_file_name Processes.parent_process
Processes.parent_process_exec Processes.parent_process_guid Processes.parent_process_id
Processes.parent_process_name Processes.parent_process_path Processes.process Processes.process_exec
Processes.process_guid Processes.process_hash Processes.process_id Processes.process_integrity_level
Processes.process_name Processes.process_path Processes.user Processes.user_id Processes.vendor_product
| `drop_dm_object_name(Processes)`
| where (
NOT match(parent_process_name, "(?i)^javaw?(\.exe)?$")
OR match(parent_process, "(?i)(org\.apache\.catalina\.startup\.Bootstrap|-Dcatalina\.base=|org\.eclipse\.jetty\.start\.Main|-Djetty\.home=|org\.jboss\.modules\.Main|-Djboss\.home\.dir=|weblogic\.Server|-Dweblogic\.Name=|weblogic-launcher\.jar|com\.ibm\.ws\.runtime\.WsServer|com\.ibm\.ws\.kernel\.boot\.cmdline\.Bootstrap|com\.sun\.enterprise\.glassfish\.bootstrap\.ASMain|com\.caucho\.server\.resin\.Resin)")
OR match(parent_process, "(?i)(org\.springframework\.boot\.loader\.|quarkus-run\.jar|io\.quarkus\.runner\.GeneratedMain|io\.micronaut\.runtime\.Micronaut|io\.dropwizard\.cli\.ServerCommand|play\.core\.server\.ProdServerStart|io\.helidon\.microprofile\.server\.Main|io\.helidon\.webserver|io\.vertx\.core\.Launcher)")
OR match(parent_process, "(?i)(org\.keycloak|org\.apereo\.cas|org\.elasticsearch\.bootstrap\.Elasticsearch|com\.atlassian\.jira\.startup\.Launcher|BitbucketServerLauncher|com\.google\.gerrit\.pgm\.Daemon|-Dsolr\.solr\.home=|jenkins\.war)")
)
| where NOT (
match(parent_process_name, "(?i)^php")
AND match(
lower(trim(process)),
"^(cmd\.exe /s /c \"stty 2> nul\"|c:\\\\windows\\\\system32\\\\cmd\.exe /s /c \"mode con\"|sh -c \"stty -a \| grep columns\"|sh -c nproc|sh -c \"stty -g\"|sh -c \"tput (cols|lines)\")$"
)
)
| where NOT (
(
match(parent_process_path, "(?i).*\\\\ArcGIS\\\\Portal\\\\framework\\\\runtime\\\\jre\\\\bin\\\\javaw\.exe$")
AND process_name="cmd.exe"
AND match(process, "(?i)^cmd\.exe /c \" whoami \"$")
)
OR
(
match(parent_process_path, "(?i)^C:\\\\Program Files\\\\CCSI\\\\Instance_[0-9]+\\\\Apache\\\\bin\\\\httpd\.exe$")
AND process_name="cmd.exe"
AND match(process, "(?i)^cmd\.exe /s /c \"\"C:\\\\Program Files\\\\CCSI\\\\Instance_[0-9]+\\\\(ObixHMAC|TraceGen|UAAnalyzer)\.exe\"")
AND NOT match(process, "[&|<>]")
)
)
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `web_or_application_server_spawning_a_shell_filter`
Implementation guide
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.
Analyst notes
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.