PHP2Shell Detection and Incident Response: A Blue Team Guide

CT
CyberDefenders Team
Share this post:
CyberDefenders PHP2Shell Detection & Incident Response: A Blue Team Guide, with a terminal illustration on a blue background.

An HTTP 500 response doesn't necessarily mean a PHP2Shell attempt failed. A vulnerable PHP worker may execute attacker-controlled code before the application returns an error.

PHP2Shell covers two critical PHP runtime vulnerabilities, CVE-2026-109618 and CVE-2026-109619, that can lead to unauthenticated remote code execution. Investigating a suspected attack means looking beyond the HTTP response and checking PHP errors, web requests, and activity on the affected host.

What Is PHP2Shell?

The two vulnerabilities involve different memory-handling failures. A worker is the process that handles incoming web requests.

CVE-2026-109618: Out-of-Memory Corruption

A memory-allocation failure can interrupt PHP while request data is only partially initialized. Cleanup may then treat that incomplete state as valid, causing memory corruption and potentially allowing code execution within the same request. PHP maintainer advisory for CVE-2026-109618

CVE-2026-109619: Stale State Across Requests

PHP can retain references to request-owned memory after that memory has been released. A later request handled by the same worker may consume the stale state before normal initialization resets it, leading to a use-after-free and potentially code execution. PHP maintainer advisory for CVE-2026-109619

With CVE-2026-109619, the request that exposes the problem may not be the one that introduced the corrupted state. When reviewing logs, check earlier requests handled by the same PHP worker.

Both vulnerabilities affect PHP itself, rather than a particular application. Updating WordPress, a framework, or a plugin won't fix a vulnerable PHP runtime.

The risk is particularly serious for Apache servers using mod_php, where exploitation has been demonstrated before application code or authentication checks are executed. Other configurations, including PHP-FPM, also require patching, although the conditions for exploitation can differ.

Successful exploitation runs code with the permissions of the PHP worker. Depending on the environment, that may give an attacker access to application files, database credentials, or other resources available to the service account.

PHP's official security and update guidance

Which PHP Versions Are Affected by PHP2Shell?

First, check which PHP version is actually serving web requests. Running php -v only shows the command-line installation, which may differ from the version used by Apache or PHP-FPM.

The PHP project released fixes on October 21, 2026:

PHP branch Affected upstream releases in this branch First fixed release
PHP 8.2 Earlier than 8.2.35 8.2.35
PHP 8.3 Earlier than 8.3.36 8.3.36
PHP 8.4 Earlier than 8.4.27 8.4.27
PHP 8.5 Earlier than 8.5.12 8.5.12

Some Linux distributions provide backported security fixes without changing the upstream version number. Check the package vendor's security advisory before deciding whether a system remains vulnerable.

Older PHP branches need separate attention. PHP 8.1 and earlier are outside regular upstream support. Check for an applicable maintained vendor fix, or migrate to a supported branch with the security fixes. PHP also provided minimal source backports for 7.4, 8.0 and 8.1; these are not a resumption of normal support. Have the runtime owner verify the chosen package or build against PHP's update guidance.

Start with internet-facing applications, particularly those connected to sensitive data or privileged backend services.

For applications behind a load balancer, make sure every backend is checked. Verifying one server doesn't tell you whether the others have been patched.

Separate Follow-Up: CVE-2026-115560

PHP's 23 October notice describes a separate issue requiring a specific configuration: session.serialize_handler begins as php_binary or php_serialize, the application switches it to php using ini_set() before session_start(), and session upload progress remains enabled.

As of the source check above, PHP advises affected deployments to set session.upload_progress.enabled=0 while awaiting the regular bugfix release. Applications that never change the serialization handler at runtime do not meet this specific condition. Check the current PHP follow-up notice; the original two-CVE patch does not resolve this separate issue.

Observed PHP2Shell Exploitation

Security researchers have documented both exploitation attempts and successful code execution, although results have varied depending on the environment. The following reports show how exploitation activity developed around the public disclosure:

  • October 17: AWS observed early activity targeting PHP2Shell through its MadPot honeypot infrastructure. AWS could not confirm that those initial attempts would succeed against real-world systems.
  • October 21: PHP released security fixes for both vulnerabilities. Exploitation attempts increased following public disclosure.
  • October 24: Adel Karimi published correlated request, memory-disclosure and shell-execution evidence from single-worker Apache mod_php honeypots. This demonstrates successful exploitation in that configuration, not equivalent reliability across deployments.
  • October 26: CISA added both vulnerabilities to its Known Exploited Vulnerabilities catalog.
  • October 29: Unit 42 reported active exploitation against internet-exposed PAN-OS management interfaces and independently verified attacker tooling associated with a chain combining PHP2Shell and a Linux kernel privilege-escalation vulnerability. PHP2Shell alone should not be equated with root access.

Successful exploitation has been demonstrated, but the results aren't consistent across environments. In its October 27 report, Wiz described attempts that exhausted PHP memory without completing later stages of the attack. Differences in PHP builds, memory limits, and worker configurations can affect whether an attempt succeeds.

Unit 42 also reported more than 22.6 million potentially exposed instances in its telemetry. That number represents possible exposure, not confirmed compromises.

For systems exposed then, start the log review at least as far back as October 17, when AWS observed suspicious activity targeting PHP2Shell. Extend the investigation window if the available evidence points to earlier activity.

Sources: AWS Threat Intelligence | Honeypot research | Wiz research | Unit 42

Hunting for PHP2Shell Activity

Begin with web-server access and reverse-proxy logs, then check the corresponding PHP errors and endpoint activity. Look for unusual POST requests alongside unexpected behavior from PHP worker processes.

If you are starting with network evidence, correlate Suricata alerts with Zeek connection logs and Apache access logs. Compare request volume, request and response sizes, and multipart boundary values where those fields are recorded. Normalize timestamps to a common time zone and sort events before reconstructing the sequence. Unusual patterns are leads to investigate, not proof of exploitation.

Multipart and URL-encoded submissions are worth investigating, but neither is a reliable PHP2Shell signature on its own. Some attack paths reach PHP's request-processing logic before the application runs, so the attacker doesn't need to target a page with an upload form.

Searching PHP Error Logs

CrowdStrike's PHP2Shell research describes a memory-exhaustion pattern that can appear during request initialization:

Allowed memory size ... exhausted ... in Unknown on line 0

If you have exported PHP error logs, you can search for this pattern in a Bash shell on Linux:

grep -F 'Allowed memory size' php-error.log |
  grep -F 'exhausted' |
  grep -F 'Unknown on line 0'

Replace php-error.log with the path to your exported plain-text log.

False Positives and Detection Limitations

This command searches for log entries containing all three phrases on the same line; matching is case-sensitive. Treat the results as leads rather than confirmed exploitation. Legitimate memory failures can produce similar errors, while other attack paths may leave no matching entry at all.

If logs are missing or incomplete, document that limitation before drawing conclusions.

Does an HTTP 500 Response Mean the Attack Failed?

Neither an HTTP 500 nor an HTTP 200 response tells you whether exploitation succeeded. Check what happened inside the PHP worker before the response was sent.

The same applies to WAF alerts. Confirm whether the request was blocked before reaching the server or whether only the response was stopped. If malicious code already executed, blocking the response won't undo it.

Connecting Web Requests to Host Activity

After identifying a suspicious request, trace it to the backend and PHP worker that handled it. Then examine what that process did on the host. A possible sequence might look like this:

  1. A web server receives an unusual POST request and returns HTTP 500.
  2. The PHP error log records a memory-exhaustion error associated with the request.
  3. Endpoint telemetry shows the same PHP worker launching an unexpected shell process.
  4. The shell creates a file or establishes an outbound network connection.

This example illustrates one possible investigation path, not a confirmed case or a universal PHP2Shell signature. Use request IDs, worker PIDs, process start times, and command lines to verify the connections between events. Keep in mind that process IDs can be reused, so timing and PID matches alone aren't always sufficient.

Also compare the activity with the application's normal behavior.

Some applications legitimately start external programs for image processing, document conversion, or maintenance. A shell launched by a web worker is worth examining, but the process relationship alone doesn't automatically make it malicious.

Check command lines, the service account, new files and network destinations. Where available, use file integrity monitoring records to compare web-root and configuration changes with approved deployments.

Keep in mind that an attacker doesn't always need to launch a separate shell. Code executing inside the PHP process may be able to access application data or credentials directly.

Confirmed unauthorized code execution establishes compromise. Investigate its scope immediately, but keep attribution to PHP2Shell provisional until the request and host evidence support that entry point. Other web vulnerabilities can produce similar behavior.

Responding to a PHP2Shell Compromise

When evidence suggests successful exploitation, involve the incident response lead and application owner. Use your organization's runbook; our incident response steps guide explains the broader identification, containment and recovery process.

Contain the Workload and Preserve Evidence

Contain the affected workload according to your incident response procedures. That may mean removing a backend from the load balancer, restricting network access, or isolating the server.

Before restarting services, preserve relevant evidence where practical. This should include web requests, PHP errors, process information, suspicious files, and network activity.

Don't delay urgent containment just to collect more logs, particularly if the attacker is still active.

Once the immediate threat is contained, investigate what the PHP service account could access.

Pay particular attention to application configuration files, database credentials, mounted storage, cloud credentials, and any newly introduced persistence mechanisms.

If credentials may have been exposed, rotate them from a trusted environment.

If you can't establish that the affected system is clean, rebuilding it from a trusted image may be safer than attempting to remove individual malicious files.

Does Patching PHP Resolve an Existing Compromise?

No. Updating PHP fixes the vulnerable runtime; it does not remove persistence or undo credential theft. Remediation must address both the vulnerable software and any established compromise.

Install the corrected PHP runtime or an applicable vendor backport, then restart or replace all affected PHP workers.

For containerized applications, deploy the updated image and verify that old containers are no longer serving requests.

After updating, confirm that the application still works as expected, including authentication, uploads, and other features that depend on PHP configuration.

Disabling session upload progress is a temporary measure for certain affected configurations. It doesn't replace the PHP2Shell security updates.

PHP2Shell Investigation Checklist

Before closing the work, record:

  • Exposure: affected backends, service owners, serving PHP versions and evidence of the applicable fixes.
  • Evidence: suspicious requests, worker and endpoint correlations, and missing logs or identifiers.
  • Impact: confirmed execution, data access, file changes or outbound activity; distinguish facts from unresolved questions.
  • Remediation: patched runtimes, restarted or replaced workers, the separate session advisory check, and application-function tests.
  • Ownership: named owners and review dates for credential rotation, forensic analysis and other unresolved actions.

Don't close the case just because the PHP update has been deployed. Verify that all affected workers are running the patched version, document what the investigation found, and record any uncertainty caused by missing logs or endpoint evidence.

Put the investigation into practice

Practice with the PHP2Shell Lab

Practice network forensics in GlassHeap - PHP2Shell 1 . Correlate Suricata alerts, Zeek logs, Apache access logs, and packet captures using Wireshark/tshark and PowerShell to reconstruct the attack and distinguish malicious activity from incident-response traffic.

Start the PHP2Shell Lab
Tags:Threat HuntingSOC analystsincident responseThreat Detection