Suspicious Child Execution via Web Server
Identifies suspicious child processes executed via a web server, which may suggest a vulnerability and remote shell access. Attackers may exploit a vulnerability in a web application to execute commands via a web server, or place a backdoor file that can be abused to gain code execution as a mechanism for persistence.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/03/04"
3integration = ["endpoint", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2025/12/22"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve Listening Ports"
10query = "SELECT pid, address, port, socket, protocol, path FROM listening_ports"
11
12[[transform.osquery]]
13label = "Osquery - Retrieve Open Sockets"
14query = "SELECT pid, family, remote_address, remote_port, socket, state FROM process_open_sockets"
15
16[[transform.osquery]]
17label = "Osquery - Retrieve Process Info"
18query = "SELECT name, cmdline, parent, path, uid FROM processes"
19
20[[transform.osquery]]
21label = "Osquery - Retrieve Process Info for Webapp User"
22query = "SELECT name, cmdline, parent, path, uid FROM processes WHERE uid = {{process.user.id}}"
23
24[[transform.osquery]]
25label = "Osquery - Retrieve Crontab Information"
26query = "SELECT * FROM crontab"
27
28[rule]
29author = ["Elastic"]
30description = """
31Identifies suspicious child processes executed via a web server, which may suggest a vulnerability and remote shell access.
32Attackers may exploit a vulnerability in a web application to execute commands via a web server, or place a backdoor
33file that can be abused to gain code execution as a mechanism for persistence.
34"""
35false_positives = [
36 """
37 Network monitoring or management products may have a web server component that runs shell commands as part of normal
38 behavior.
39 """,
40]
41from = "now-9m"
42index = ["endgame-*", "logs-endpoint.events.process*", "logs-sentinel_one_cloud_funnel.*"]
43language = "eql"
44license = "Elastic License v2"
45name = "Suspicious Child Execution via Web Server"
46note = """## Triage and analysis
47
48### Investigating Suspicious Child Execution via Web Server
49
50Adversaries may backdoor web servers with web shells to establish persistent access to systems. A web shell is a malicious script, often embedded into a compromised web server, that grants an attacker remote access and control over the server. This enables the execution of arbitrary commands, data exfiltration, and further exploitation of the target network.
51
52This rule detects a web server process spawning script and command line interface programs, potentially indicating attackers executing commands using the web shell.
53
54> **Note**:
55> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
56> This investigation guide uses [placeholder fields](https://www.elastic.co/guide/en/security/current/osquery-placeholder-fields.html) to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
57
58#### Possible investigation steps
59
60- Investigate abnormal behaviors by the subject process such as network connections, file modifications, and any other spawned child processes.
61 - Investigate listening ports and open sockets to look for potential reverse shells or data exfiltration.
62 - $osquery_0
63 - $osquery_1
64 - Investigate the process information for malicious or uncommon processes/process trees.
65 - $osquery_2
66 - Investigate the process tree spawned from the user that is used to run the web application service. A user that is running a web application should not spawn other child processes.
67 - $osquery_3
68- Examine the command line to determine which commands or scripts were executed.
69- Investigate other alerts associated with the user/host during the past 48 hours.
70- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
71 - Use a private sandboxed malware analysis system to perform analysis.
72 - Observe and collect information about the following activities:
73 - Attempts to contact external domains and addresses.
74 - Check if the domain is newly registered or unexpected.
75 - Check the reputation of the domain or IP address.
76 - File access, modification, and creation activities.
77 - Cron jobs, services and other persistence mechanisms.
78 - $osquery_4
79
80### False positive analysis
81
82- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
83
84### Response and remediation
85
86- Initiate the incident response process based on the outcome of the triage.
87- Isolate the involved host to prevent further post-compromise behavior.
88- If the triage identified malware, search the environment for additional compromised hosts.
89 - Implement temporary network rules, procedures, and segmentation to contain the malware.
90 - Stop suspicious processes.
91 - Immediately block the identified indicators of compromise (IoCs).
92 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
93- Remove and block malicious artifacts identified during triage.
94- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
95- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
96- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
97- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
98"""
99references = [
100 "https://pentestlab.blog/tag/web-shell/",
101 "https://www.elastic.co/security-labs/elastic-response-to-the-the-spring4shell-vulnerability-cve-2022-22965",
102]
103risk_score = 47
104rule_id = "f16fca20-4d6c-43f9-aec1-20b6de3b0aeb"
105setup = """## Setup
106
107This rule requires data coming in from Elastic Defend.
108
109### Elastic Defend Integration Setup
110Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
111
112#### Prerequisite Requirements:
113- Fleet is required for Elastic Defend.
114- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
115
116#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
117- Go to the Kibana home page and click "Add integrations".
118- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
119- Click "Add Elastic Defend".
120- Configure the integration name and optionally add a description.
121- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
122- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
123- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
124- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
125For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
126- Click "Save and Continue".
127- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
128For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
129"""
130severity = "medium"
131tags = [
132 "Domain: Endpoint",
133 "OS: Linux",
134 "Use Case: Threat Detection",
135 "Tactic: Persistence",
136 "Tactic: Initial Access",
137 "Data Source: Elastic Endgame",
138 "Use Case: Vulnerability",
139 "Resources: Investigation Guide",
140 "Data Source: Elastic Defend",
141 "Data Source: SentinelOne",
142]
143timestamp_override = "event.ingested"
144type = "eql"
145query = '''
146process where host.os.type == "linux" and event.type == "start" and process.parent.executable != null and (
147 process.parent.name like (
148 "apache", "nginx", "apache2", "httpd", "lighttpd", "caddy", "php-fpm*", "mongrel_rails", "haproxy",
149 "gunicorn", "uwsgi", "openresty", "cherokee", "h2o", "resin", "puma", "unicorn", "traefik", "uvicorn",
150 "tornado", "hypercorn", "daphne", "twistd", "yaws", "webfsd", "httpd.worker", "flask", "rails", "mongrel",
151 "php-cgi", "php-fcgi", "php-cgi.cagefs", "catalina.sh", "hiawatha", "lswsctrl"
152 ) or
153 user.name in ("apache", "www-data", "httpd", "nginx", "lighttpd", "tomcat", "tomcat8", "tomcat9") or
154 user.id in ("33", "498", "48") or
155 (process.name == "java" and ?process.working_directory like "/u0?/*")
156) and (
157 process.executable like (
158 "/tmp/*", "/var/tmp/*", "/dev/shm/*", "./*", "/run/*", "/var/run/*", "/boot/*", "/sys/*", "/lost+found/*",
159 "/proc/*", "/var/mail/*", "/var/www/*", "/home/*", "/root/*"
160 ) or
161 process.name like~ (
162 // Hidden processes
163 ".*",
164 // Suspicious file formats
165 "*.elf", "*.sh", "*.py", "*.rb", "*.pl", "*.lua*", "*.php*", ".js",
166 // Scheduled tasks
167 "systemd", "cron", "crond",
168 // Network utilities often used for reverse shells
169 "nc", "netcat", "ncat", "telnet", "socat", "openssl", "nc.openbsd", "ngrok", "nc.traditional",
170 // Cloud CLI
171 "az", "gcloud", "aws",
172 // Misc. tools
173 "whoami", "ifconfig", "ip", "ss", "top", "htop", "df", "du", "lsblk", "lsof", "tcpdump",
174 "strace", "ltrace", "curl", "wget", "dig", "nslookup", "host", "nmap", "arp", "traceroute"
175 )
176)
177'''
178
179[[rule.threat]]
180framework = "MITRE ATT&CK"
181
182[[rule.threat.technique]]
183id = "T1505"
184name = "Server Software Component"
185reference = "https://attack.mitre.org/techniques/T1505/"
186
187[[rule.threat.technique.subtechnique]]
188id = "T1505.003"
189name = "Web Shell"
190reference = "https://attack.mitre.org/techniques/T1505/003/"
191
192[rule.threat.tactic]
193id = "TA0003"
194name = "Persistence"
195reference = "https://attack.mitre.org/tactics/TA0003/"
196
197[[rule.threat]]
198framework = "MITRE ATT&CK"
199
200[[rule.threat.technique]]
201id = "T1190"
202name = "Exploit Public-Facing Application"
203reference = "https://attack.mitre.org/techniques/T1190/"
204
205[rule.threat.tactic]
206id = "TA0001"
207name = "Initial Access"
208reference = "https://attack.mitre.org/tactics/TA0001/"
Triage and analysis
Investigating Suspicious Child Execution via Web Server
Adversaries may backdoor web servers with web shells to establish persistent access to systems. A web shell is a malicious script, often embedded into a compromised web server, that grants an attacker remote access and control over the server. This enables the execution of arbitrary commands, data exfiltration, and further exploitation of the target network.
This rule detects a web server process spawning script and command line interface programs, potentially indicating attackers executing commands using the web shell.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide. This investigation guide uses placeholder fields to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
Possible investigation steps
- Investigate abnormal behaviors by the subject process such as network connections, file modifications, and any other spawned child processes.
- Investigate listening ports and open sockets to look for potential reverse shells or data exfiltration.
- $osquery_0
- $osquery_1
- Investigate the process information for malicious or uncommon processes/process trees.
- $osquery_2
- Investigate the process tree spawned from the user that is used to run the web application service. A user that is running a web application should not spawn other child processes.
- $osquery_3
- Investigate listening ports and open sockets to look for potential reverse shells or data exfiltration.
- Examine the command line to determine which commands or scripts were executed.
- Investigate other alerts associated with the user/host during the past 48 hours.
- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
- Use a private sandboxed malware analysis system to perform analysis.
- Observe and collect information about the following activities:
- Attempts to contact external domains and addresses.
- Check if the domain is newly registered or unexpected.
- Check the reputation of the domain or IP address.
- File access, modification, and creation activities.
- Cron jobs, services and other persistence mechanisms.
- $osquery_4
- Attempts to contact external domains and addresses.
- Observe and collect information about the following activities:
- Use a private sandboxed malware analysis system to perform analysis.
False positive analysis
- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Chkconfig Service Add
- D-Bus Service Created
- DNF Package Manager Plugin File Creation
- Dracut Module Creation
- Executable Bit Set for Potential Persistence Script