Unusual Process Spawned from Web Server Parent

This rule detects unusual processes spawned from a web server parent process by identifying low frequency counts of process spawning activity. Unusual process spawning activity may indicate an attacker attempting to establish persistence, execute malicious commands, or establish command and control channels on the host system. ESQL rules have limited fields available in its alert documents. Make sure to review the original documents to aid in the investigation of this alert.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/03/04"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2025/12/23"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects unusual processes spawned from a web server parent process by identifying low frequency counts of
 11process spawning activity. Unusual process spawning activity may indicate an attacker attempting to establish
 12persistence, execute malicious commands, or establish command and control channels on the host system. ESQL rules have
 13limited fields available in its alert documents. Make sure to review the original documents to aid in the investigation
 14of this alert.
 15"""
 16from = "now-61m"
 17interval = "1h"
 18language = "esql"
 19license = "Elastic License v2"
 20name = "Unusual Process Spawned from Web Server Parent"
 21note = """ ## Triage and analysis
 22
 23> **Disclaimer**:
 24> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 25
 26### Investigating Unusual Process Spawned from Web Server Parent
 27
 28Web servers like Apache, Nginx, and others are crucial for hosting applications and services. Adversaries exploit these servers by spawning unauthorized processes to maintain persistence or execute malicious commands. The detection rule identifies anomalies by monitoring low-frequency process spawns from web server parents, focusing on unusual user IDs, directories, and process counts, which may indicate potential threats.
 29
 30### Possible investigation steps
 31
 32- Review the process.executable and process.command_line fields to understand the nature of the process that was spawned and assess if it aligns with expected behavior for the web server environment.
 33- Examine the process.working_directory to determine if the directory is a legitimate location for web server operations or if it appears suspicious, such as being outside typical web server directories.
 34- Check the user.name and user.id fields to verify if the process was executed by a legitimate web server user or if it was initiated by an unexpected or unauthorized user account.
 35- Investigate the process.parent.executable to confirm whether the parent process is a known and trusted web server executable or if it has been tampered with or replaced.
 36- Correlate the event with other logs or alerts from the same agent.id to identify any additional suspicious activities or patterns that may indicate a broader compromise.
 37- Assess the host.os.type to ensure the alert pertains to a Linux system, as specified in the query, and verify if there are any known vulnerabilities or misconfigurations on the host that could have been exploited.
 38
 39### False positive analysis
 40
 41- Processes related to legitimate web server maintenance tasks may trigger alerts. Review scheduled tasks or cron jobs that align with the alert timing and consider excluding these specific processes if they are verified as non-threatening.
 42- Development environments often spawn processes that mimic attack patterns. Identify and exclude processes originating from known development directories or executed by development user accounts.
 43- Automated scripts or monitoring tools running under web server user accounts can be mistaken for malicious activity. Verify these scripts and add exceptions for their specific process names or working directories.
 44- Frequent updates or deployments in web applications can lead to unusual process spawns. Document these activities and exclude related processes if they consistently match the alert criteria during known update windows.
 45- Custom web server modules or plugins may execute processes that appear suspicious. Validate these modules and exclude their associated processes if they are part of normal operations.
 46
 47### Response and remediation
 48
 49- Immediately isolate the affected host from the network to prevent further malicious activity and potential lateral movement.
 50- Terminate any suspicious processes identified by the alert that are not part of legitimate web server operations.
 51- Conduct a thorough review of the process command lines and executables flagged by the alert to identify any malicious scripts or binaries. Remove or quarantine these files as necessary.
 52- Check for unauthorized changes in web server configurations or files within the working directories flagged by the alert. Restore any altered files from a known good backup.
 53- Review user accounts and permissions associated with the web server processes to ensure no unauthorized accounts or privilege escalations have occurred. Reset passwords and revoke unnecessary access.
 54- Monitor network traffic from the affected host for any signs of command and control communication, and block any identified malicious IP addresses or domains.
 55- Escalate the incident to the security operations center (SOC) or incident response team for further analysis and to determine if additional systems are compromised.
 56"""
 57risk_score = 21
 58rule_id = "976b2391-413f-4a94-acb4-7911f3803346"
 59setup = """## Setup
 60
 61This rule requires data coming in from Elastic Defend.
 62
 63### Elastic Defend Integration Setup
 64Elastic 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.
 65
 66#### Prerequisite Requirements:
 67- Fleet is required for Elastic Defend.
 68- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 69
 70#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 71- Go to the Kibana home page and click "Add integrations".
 72- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 73- Click "Add Elastic Defend".
 74- Configure the integration name and optionally add a description.
 75- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 76- 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).
 77- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 78- 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.
 79For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 80- Click "Save and Continue".
 81- 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.
 82For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 83"""
 84severity = "low"
 85tags = [
 86    "Domain: Endpoint",
 87    "OS: Linux",
 88    "Use Case: Threat Detection",
 89    "Tactic: Persistence",
 90    "Tactic: Execution",
 91    "Tactic: Command and Control",
 92    "Data Source: Elastic Defend",
 93    "Resources: Investigation Guide",
 94]
 95timestamp_override = "event.ingested"
 96type = "esql"
 97query = '''
 98from logs-endpoint.events.process-* metadata _id, _index, _version
 99| mv_expand event.action
100| where
101    host.os.type == "linux" and
102    event.type == "start" and
103    event.action == "exec" and (
104      (
105        process.parent.name in (
106            "apache", "nginx", "apache2", "httpd", "lighttpd", "caddy", "mongrel_rails", "gunicorn",
107            "uwsgi", "openresty", "cherokee", "h2o", "resin", "puma", "unicorn", "traefik", "tornado", "hypercorn",
108            "daphne", "twistd", "yaws", "webfsd", "httpd.worker", "flask", "rails", "mongrel", "php-cgi",
109            "php-fcgi", "php-cgi.cagefs", "catalina.sh", "hiawatha", "lswsctrl"
110        ) or
111        process.parent.name like "php-fpm*" or
112        user.name in ("apache", "www-data", "httpd", "nginx", "lighttpd", "tomcat", "tomcat8", "tomcat9") or
113        user.id in ("33", "498", "48") or
114        (process.parent.name == "java" and process.parent.working_directory like "/u0?/*") or
115        process.parent.working_directory like "/var/www/*"
116      )
117    ) and (
118        process.name in (
119          "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat", "openssl", "busybox",
120          "nc", "ncat", "netcat", "nc.openbsd", "nc.traditional", "nohup", "setsid", "mkfifo", "mknod",
121          "node", "socket"
122        ) or
123        process.name like "python*" or
124        process.name like "php*" or
125        process.name like "perl" or
126        process.name like "ruby*" or
127        process.name like "lua*" or
128        process.executable like "/tmp/*" or
129        process.executable like "/var/tmp/*" or
130        process.executable like "/dev/shm/*" or
131        process.executable like "/var/log/*" or
132        process.executable like "/sys/*" or
133        process.executable like "/media/*" or
134        process.executable like "/proc/*" or
135        process.executable like "/var/backups/*" or
136        process.executable like "/var/mail/*" or
137        process.executable like "/var/spool/*" or
138        process.executable like "/var/www/*" or
139        process.executable like "./*" or
140        process.name like ".*"
141    ) and    
142    not (
143        process.working_directory like "/home/*" or
144        process.working_directory == "/" or
145        process.working_directory like "/var/www/*.ch" or
146        process.parent.executable like "/vscode/vscode-server/*"
147    )
148
149| keep
150    @timestamp,
151    _id,
152    _index,
153    _version,
154    host.os.type,
155    event.type,
156    event.action,
157    process.parent.name,
158    user.name,
159    user.id,
160    process.working_directory,
161    process.parent.working_directory,
162    process.name,
163    process.executable,
164    process.command_line,
165    process.parent.executable,
166    agent.id,
167    host.name,
168    event.dataset,
169    data_stream.namespace
170
171| stats
172    Esql.event_count = count(),
173    Esql.agent_id_count_distinct = count_distinct(agent.id),
174    Esql.host_name_values = values(host.name),
175    Esql.agent_id_values = values(agent.id),
176    Esql.event_dataset_values = values(event.dataset),
177    Esql.data_stream_namespace_values = values(data_stream.namespace)
178
179    by process.executable, process.working_directory, process.parent.executable
180
181| where
182    Esql.agent_id_count_distinct == 1 and
183    Esql.event_count < 5
184| sort Esql.event_count asc
185'''
186
187[[rule.threat]]
188framework = "MITRE ATT&CK"
189
190[[rule.threat.technique]]
191id = "T1505"
192name = "Server Software Component"
193reference = "https://attack.mitre.org/techniques/T1505/"
194
195[[rule.threat.technique.subtechnique]]
196id = "T1505.003"
197name = "Web Shell"
198reference = "https://attack.mitre.org/techniques/T1505/003/"
199
200[rule.threat.tactic]
201id = "TA0003"
202name = "Persistence"
203reference = "https://attack.mitre.org/tactics/TA0003/"
204
205[[rule.threat]]
206framework = "MITRE ATT&CK"
207
208[[rule.threat.technique]]
209id = "T1059"
210name = "Command and Scripting Interpreter"
211reference = "https://attack.mitre.org/techniques/T1059/"
212
213[[rule.threat.technique.subtechnique]]
214id = "T1059.004"
215name = "Unix Shell"
216reference = "https://attack.mitre.org/techniques/T1059/004/"
217
218[rule.threat.tactic]
219id = "TA0002"
220name = "Execution"
221reference = "https://attack.mitre.org/tactics/TA0002/"
222
223[[rule.threat]]
224framework = "MITRE ATT&CK"
225
226[[rule.threat.technique]]
227id = "T1071"
228name = "Application Layer Protocol"
229reference = "https://attack.mitre.org/techniques/T1071/"
230
231[rule.threat.tactic]
232id = "TA0011"
233name = "Command and Control"
234reference = "https://attack.mitre.org/tactics/TA0011/"

Triage and analysis

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

Investigating Unusual Process Spawned from Web Server Parent

Web servers like Apache, Nginx, and others are crucial for hosting applications and services. Adversaries exploit these servers by spawning unauthorized processes to maintain persistence or execute malicious commands. The detection rule identifies anomalies by monitoring low-frequency process spawns from web server parents, focusing on unusual user IDs, directories, and process counts, which may indicate potential threats.

Possible investigation steps

  • Review the process.executable and process.command_line fields to understand the nature of the process that was spawned and assess if it aligns with expected behavior for the web server environment.
  • Examine the process.working_directory to determine if the directory is a legitimate location for web server operations or if it appears suspicious, such as being outside typical web server directories.
  • Check the user.name and user.id fields to verify if the process was executed by a legitimate web server user or if it was initiated by an unexpected or unauthorized user account.
  • Investigate the process.parent.executable to confirm whether the parent process is a known and trusted web server executable or if it has been tampered with or replaced.
  • Correlate the event with other logs or alerts from the same agent.id to identify any additional suspicious activities or patterns that may indicate a broader compromise.
  • Assess the host.os.type to ensure the alert pertains to a Linux system, as specified in the query, and verify if there are any known vulnerabilities or misconfigurations on the host that could have been exploited.

False positive analysis

  • Processes related to legitimate web server maintenance tasks may trigger alerts. Review scheduled tasks or cron jobs that align with the alert timing and consider excluding these specific processes if they are verified as non-threatening.
  • Development environments often spawn processes that mimic attack patterns. Identify and exclude processes originating from known development directories or executed by development user accounts.
  • Automated scripts or monitoring tools running under web server user accounts can be mistaken for malicious activity. Verify these scripts and add exceptions for their specific process names or working directories.
  • Frequent updates or deployments in web applications can lead to unusual process spawns. Document these activities and exclude related processes if they consistently match the alert criteria during known update windows.
  • Custom web server modules or plugins may execute processes that appear suspicious. Validate these modules and exclude their associated processes if they are part of normal operations.

Response and remediation

  • Immediately isolate the affected host from the network to prevent further malicious activity and potential lateral movement.
  • Terminate any suspicious processes identified by the alert that are not part of legitimate web server operations.
  • Conduct a thorough review of the process command lines and executables flagged by the alert to identify any malicious scripts or binaries. Remove or quarantine these files as necessary.
  • Check for unauthorized changes in web server configurations or files within the working directories flagged by the alert. Restore any altered files from a known good backup.
  • Review user accounts and permissions associated with the web server processes to ensure no unauthorized accounts or privilege escalations have occurred. Reset passwords and revoke unnecessary access.
  • Monitor network traffic from the affected host for any signs of command and control communication, and block any identified malicious IP addresses or domains.
  • Escalate the incident to the security operations center (SOC) or incident response team for further analysis and to determine if additional systems are compromised.

Related rules

to-top