LoFP LoFP / filtering may be required on internal developer build systems or classify assets as web facing and restrict the analytic based on asset type.

Techniques

Sample rules

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.

Detection logic


| 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`

Linux Auditd Web or Application Server Spawning a Shell

Description

The following analytic detects instances where Java, web server, or application server processes attempts to 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.

Detection logic

`linux_auditd`
type=SYSCALL
comm IN (
    "apache*",
    "bash",
    "caddy",
    "csh",
    "dash",
    "eshell",
    "fish",
    "httpd",
    "ion",
    "java",
    "ksh",
    "lighttpd",
    "nginx",
    "php*",
    "rbash",
    "sh",
    "tcsh",
    "tomcat*",
    "zsh"
)


| eval web_process=if(match(comm, "^(apache.*
|caddy
|httpd
|java
|lighttpd
|nginx
|php.*
|tomcat.*)$"),exe,null())

| eval shell_process=if(match(comm, "^(sh
|ksh
|zsh
|bash
|dash
|rbash
|fish
|csh
|tcsh
|ion
|eshell)$"),exe,null())


| eval web_process_name=if(match(comm, "^(apache.*
|caddy
|httpd
|java
|lighttpd
|nginx
|php.*
|tomcat.*)$"),comm,null())

| eval shell_process_name=if(match(comm, "^(sh
|ksh
|zsh
|bash
|dash
|rbash
|fish
|csh
|tcsh
|ion
|eshell)$"),comm,null())


| eval web_pid=if(match(comm, "^(apache.*
|caddy
|httpd
|java
|lighttpd
|nginx
|php.*
|tomcat.*)$"),pid,null())

| eval shell_ppid=if(match(comm, "^(sh
|ksh
|zsh
|bash
|dash
|rbash
|fish
|csh
|tcsh
|ion
|eshell)$"),ppid,null())

| eval shell_pid=if(match(comm, "^(sh
|ksh
|zsh
|bash
|dash
|rbash
|fish
|csh
|tcsh
|ion
|eshell)$"),pid,null())

| eval parent_pid=coalesce(web_pid, shell_ppid)


| stats count min(_time) as firstTime last(_time) as lastTime
    values(web_process_name) as parent_process_name
    values(web_process) as parent_process
    values(shell_pid) as pid
    values(shell_process_name) as process_name
    values(shell_process) as process
    by host parent_pid


| rename host as dest


| where isnotnull(parent_process) AND isnotnull(process)

| `security_content_ctime(firstTime)`

| `security_content_ctime(lastTime)`

| `linux_auditd_web_or_application_server_spawning_a_shell_filter`