Potential PHP2Shell Exploitation Attempt
editPotential PHP2Shell Exploitation Attempt
editThis rule detects a distinctive PHP out-of-memory fatal error associated with PHP2Shell exploitation attempts. The combination of an allowed-memory-size exhaustion and the location "Unknown on line 0" is produced before normal application execution and is an indicator of attempts to exploit PHP memory-safety vulnerabilities, including CVE-2026-109618 and CVE-2026-109619. The rule can detect unsuccessful as well as successful attempts and does not, by itself, confirm remote code execution.
Rule type: query
Rule indices:
- logs-apache.error-*
- logs-apache_tomcat.*
- logs-nginx.error-*
Severity: medium
Risk score: 47
Runs every: 5m
Searches indices from: now-9m (Date Math format, see also Additional look-back time)
Maximum alerts per execution: 100
References:
Tags:
- Domain: Web
- Use Case: Threat Detection
- Use Case: Vulnerability
- Tactic: Initial Access
- Data Source: Nginx
- Data Source: Apache
- Data Source: Apache Tomcat
- Resources: Investigation Guide
- Threat: Vulnerability Exploit
- Rule Type: Query
- Service: Nginx
- Service: Apache Tomcat
- Service: Apache HTTP Server
- Vuln: CVE-2026-109618
- Vuln: CVE-2026-109619
Version: 1
Rule authors:
- Elastic
Rule license: Elastic License v2
Investigation guide
editTriage and analysis
Investigating Potential PHP2Shell Exploitation Attempt
PHP2Shell chains PHP memory-safety flaws that are triggered while PHP processes fatal out-of-memory conditions. The
combination of PHP Fatal error, Allowed memory size, bytes exhausted, and Unknown on line 0 is substantially more
specific than a generic PHP fatal error. The alert represents an exploitation attempt; use corroborating web and endpoint
telemetry to determine whether code execution or process-memory disclosure succeeded.
Possible investigation steps
-
Identify
host.id,host.name,event.dataset,log.file.path, and the completemessageorevent.originalvalue. -
Treat
source.ipas the immediate client observed by the web server. If a proxy, CDN, load balancer, or container bridge is present, recover the original client from trusted proxy or edge logs rather than assumingsource.ipis the attacker. -
Review web access and error events around the alert for multipart requests, upload-progress session fields, repeated HTTP
500 responses, unusual or malformed
PHPSESSIDcookies, worker churn, and repeated memory-limit errors. - Correlate the alert with process telemetry for shells, interpreters, downloaders, or other unusual children of Apache, Nginx, IIS, PHP-CGI, or PHP-FPM workers. Review outbound network connections and recent file modifications on the host.
- Establish the installed PHP version and determine whether it includes the PHP security updates published on October 21,2026. PHP2Shell affects PHP itself and does not require a vulnerability in the hosted application.
False positive analysis
-
A genuine application memory leak or deliberately constrained
memory_limitcan cause memory exhaustion, but the completeUnknown on line 0signature is unusual. Compare the event with historical fatal errors on the same host. - Confirm whether an approved security assessment was active and whether its source and timing match the alert.
Response and remediation
- If the server runs an affected PHP release, remove it from public traffic or isolate it until PHP is updated.
- Preserve web, PHP, process, network, and file telemetry before restarting workers or rebuilding the host.
- If follow-on execution or memory disclosure is suspected, rotate credentials and secrets accessible to the PHP worker, rebuild from a trusted image, and hunt for the same activity across other PHP servers.
Rule query
editevent.dataset:("apache.error" or "nginx.error" or "apache_tomcat.catalina" or "apache_tomcat.localhost") and
message:("PHP Fatal error" and "Allowed memory size" and "bytes exhausted" and "Unknown on line 0")
Framework: MITRE ATT&CKTM
-
Tactic:
- Name: Initial Access
- ID: TA0001
- Reference URL: https://attack.mitre.org/tactics/TA0001/
-
Technique:
- Name: Exploit Public-Facing Application
- ID: T1190
- Reference URL: https://attack.mitre.org/techniques/T1190/