Detection: 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.

  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        "php*",
 17        "tomcat*"
 18    )
 19    `linux_shells`
 20)
 21OR
 22(
 23    Processes.parent_process_name IN (
 24        "apache*.exe",
 25        "beasvc.exe",
 26        "caddy.exe",
 27        "coldfusion.exe",
 28        "frankenphp.exe",
 29        "http*.exe",
 30        "iisexpress.exe",
 31        "java.exe",
 32        "javaw.exe",
 33        "jbosssvc.exe",
 34        "jrun.exe",
 35        "lighttpd.exe",
 36        "lsphp*.exe",
 37        "MSExchangeHMWorker.exe",
 38        "nginx*.exe",
 39        "openresty.exe",
 40        "php*.exe",
 41        "roadrunner.exe",
 42        "tomcat*.exe",
 43        "traefik.exe",
 44        "UMWorkerProcess.exe",
 45        "w3wp.exe",
 46        "wildfly-service.exe",
 47        "ws_TomcatService.exe"
 48    )
 49    `windows_shells`
 50)
 51NOT Processes.parent_process_name IN ("phpstorm*")
 52
 53by Processes.action Processes.dest Processes.original_file_name Processes.parent_process
 54   Processes.parent_process_exec Processes.parent_process_guid Processes.parent_process_id
 55   Processes.parent_process_name Processes.parent_process_path Processes.process Processes.process_exec
 56   Processes.process_guid Processes.process_hash Processes.process_id Processes.process_integrity_level
 57   Processes.process_name Processes.process_path Processes.user Processes.user_id Processes.vendor_product
 58
 59
 60| `drop_dm_object_name(Processes)`
 61
 62
 63| where (
 64    NOT match(parent_process_name, "(?i)^javaw?(\.exe)?$")
 65    OR match(parent_process, "(?i)(org\.apache\.catalina\.startup\.Bootstrap
 66|-Dcatalina\.base=
 67|org\.eclipse\.jetty\.start\.Main
 68|-Djetty\.home=
 69|org\.jboss\.modules\.Main
 70|-Djboss\.home\.dir=
 71|weblogic\.Server
 72|-Dweblogic\.Name=
 73|weblogic-launcher\.jar
 74|com\.ibm\.ws\.runtime\.WsServer
 75|com\.ibm\.ws\.kernel\.boot\.cmdline\.Bootstrap
 76|com\.sun\.enterprise\.glassfish\.bootstrap\.ASMain
 77|com\.caucho\.server\.resin\.Resin)")
 78    OR match(parent_process, "(?i)(org\.springframework\.boot\.loader\.
 79|quarkus-run\.jar
 80|io\.quarkus\.runner\.GeneratedMain
 81|io\.micronaut\.runtime\.Micronaut
 82|io\.dropwizard\.cli\.ServerCommand
 83|play\.core\.server\.ProdServerStart
 84|io\.helidon\.microprofile\.server\.Main
 85|io\.helidon\.webserver
 86|io\.vertx\.core\.Launcher)")
 87    OR match(parent_process, "(?i)(org\.keycloak
 88|org\.apereo\.cas
 89|org\.elasticsearch\.bootstrap\.Elasticsearch
 90|com\.atlassian\.jira\.startup\.Launcher
 91|BitbucketServerLauncher
 92|com\.google\.gerrit\.pgm\.Daemon
 93|-Dsolr\.solr\.home=
 94|jenkins\.war)")
 95)
 96
 97
 98| where NOT (
 99    match(parent_process_name, "(?i)^php")
100    AND match(
101        lower(trim(process)),
102        "^(cmd\.exe /s /c \"stty 2> nul\"
103|c:\\\\windows\\\\system32\\\\cmd\.exe /s /c \"mode con\"
104|sh -c \"stty -a \
105| grep columns\"
106|sh -c nproc
107|sh -c \"stty -g\"
108|sh -c \"tput (cols
109|lines)\")$"
110    )
111)
112
113
114| where NOT (
115    (
116        match(parent_process_path, "(?i).*\\\\ArcGIS\\\\Portal\\\\framework\\\\runtime\\\\jre\\\\bin\\\\javaw\.exe$")
117        AND process_name="cmd.exe"
118        AND match(process, "(?i)^cmd\.exe /c \" whoami \"$")
119    )
120    OR
121    (
122        match(parent_process_path, "(?i)^C:\\\\Program Files\\\\CCSI\\\\Instance_[0-9]+\\\\Apache\\\\bin\\\\httpd\.exe$")
123        AND process_name="cmd.exe"
124        AND match(process, "(?i)^cmd\.exe /s /c \"\"C:\\\\Program Files\\\\CCSI\\\\Instance_[0-9]+\\\\(ObixHMAC
125|TraceGen
126|UAAnalyzer)\.exe\"")
127        AND NOT match(process, "[&
128|<>]")
129    )
130)
131
132
133| `security_content_ctime(firstTime)`
134
135| `security_content_ctime(lastTime)`
136
137| `web_or_application_server_spawning_a_shell_filter`

Data Source

Name Platform Sourcetype Source
Sysmon for Linux EventID 1 Linux icon Linux 'sysmon:linux' 'Syslog:Linux-Sysmon/Operational'
Sysmon EventID 1 Windows icon Windows '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
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

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$] was identified on endpoint [$dest$], potentially indicative of exploitation. dest system 50

Threat Objects

Field Type
process_name process_name
parent_process_name parent_process_name
process process

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: 8