Security & privacy

Critical PHP flaws enable remote code execution via session handler

A new critical vulnerability in PHP's session handler allows remote code execution. Cloudflare has updated its WAF rules to block attacks while developers patch.

Illustration of a broken session file leaking malicious code
Illustration generated for this article

On November 19, 2026, security researchers disclosed phpAfterShell, a critical vulnerability in PHP that allows attackers to execute arbitrary code on vulnerable servers. The flaw, tracked as CVE-2026-126714, affects the default file-based session handler and carries a CVSS 4.0 score of 9.2. The PHP project released patched versions the same day, and Cloudflare immediately updated its Web Application Firewall (WAF) to detect and block known attack patterns for all customers, including those on the Free plan.

What happened

The vulnerability was disclosed by the security research company depthfirst, with credit given to reporters Leo Lin and Asahi. It targets the way PHP manages session data. By default, PHP stores session information in files on the server. When a request ends, PHP writes the updated session data back to this file. If this write operation is interrupted, the file can contain a mix of old and new data. On the next request, PHP attempts to deserialize this corrupted content. If an attacker has previously planted controlled data in the session, they can force PHP to deserialize objects of their choosing, leading to remote code execution.

Alongside phpAfterShell, the November 19 releases fixed 16 other security issues, six of which are also rated critical. These include a request smuggling flaw in PHP-FPM (CVE-2026-129289) and two vulnerabilities in the SOAP extension (CVE-2026-15353 and CVE-2026-129506). Other critical flaws involve use-after-free errors in timezone caching and fatal error backtraces. While phpAfterShell is the most prominent due to its high severity and broad impact potential, the combination of these flaws represents a significant risk for any environment running unpatched PHP versions.

Cloudflare responded by updating its existing PHP remote code execution rule, which was originally deployed in October 2026 for previous php2shell vulnerabilities. Because phpAfterShell shares similar attack techniques, the existing rule already detected parts of the exploit chain. The update on November 19 refined the detection logic to specifically cover phpAfterShell. Additionally, three new rules were added to the Cloudflare Managed Ruleset for paid plans to address the PHP-FPM and SOAP flaws. These new rules are set to Log by default to avoid disrupting legitimate traffic, allowing administrators to review matches before switching to Block.

How it works

The core mechanism of phpAfterShell relies on race conditions during session file writes. An attacker first needs a way to place controlled data into the session storage. This can be achieved through PHP’s session upload progress feature, which writes file upload metadata into the session, or by applications that store large user-controlled strings in the session. Once the data is in place, the attacker triggers an interruption during the write phase. This results in a corrupted session file containing a fragment of the attacker's serialized payload.

When the next request calls session_start(), PHP reads and deserializes this mixed content. If the application contains a suitable deserialization gadget chain, or if the attacker can leverage a secondary memory-corruption bug as reported by depthfirst, the deserialization process executes the attacker's code. The exploit does not require authentication, but it does depend on specific server configurations and the ability to influence session data. The other critical flaws operate differently; for example, the PHP-FPM vulnerability requires a front-end server that reuses backend FastCGI connections and an application path that opens php://input without reading it completely.

Key details

  • Vulnerability ID: CVE-2026-126714 (phpAfterShell), plus six other critical CVEs including CVE-2026-129289.
  • Affected Versions: PHP 8.2 before 8.2.36, 8.3 before 8.3.37, 8.4 before 8.4.28, 8.5 before 8.5.13, and 8.6.0 release candidates.
  • Patch Availability: Fixed in PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0, released on November 19, 2026.
  • WAF Protection: Cloudflare WAF blocks phpAfterShell patterns by default on all plans, including Free. New rules for PHP-FPM and SOAP flaws are in Log mode for paid plans.
  • Exploitation Status: No evidence of exploitation in the wild as of November 19, 2026, and none listed in CISA's Known Exploited Vulnerabilities catalog.
  • Mitigation Limits: WAF rules block incoming malicious requests but cannot prevent exploitation if the payload is injected via internal services or databases.

Why it matters

For software engineers and technical leads, this disclosure highlights the fragility of default PHP configurations. Many applications rely on session handling without realizing that features like session upload progress can become attack vectors. The fact that phpAfterShell can lead to remote code execution without a dedicated application gadget chain, according to some reports, makes it particularly dangerous. It means that even well-written applications might be vulnerable if they run on an unpatched PHP version with default settings.

Furthermore, the presence of multiple critical flaws in a single release underscores the importance of rapid patching cycles. While WAF rules provide a crucial safety net, they are not a complete solution. They cannot see traffic that bypasses the proxy, such as internal service-to-service communication, nor can they protect against flaws triggered by server state rather than direct HTTP requests. Teams must treat WAF protection as a temporary shield while prioritizing the upgrade of PHP runtimes across all environments, including container images and legacy systems.

What you can do

  • Upgrade PHP immediately: Move to versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, or 8.6.0. Rebuild container images and restart all PHP-FPM or Apache workers to ensure the new binary is loaded.
  • Verify WAF rules: Ensure the Cloudflare Managed Ruleset is active. For paid plans, confirm that the PHP Remote Code Execution Attack #6 rule is set to Block. Review the new Log-mode rules for PHP-FPM and SOAP flaws and switch them to Block after verifying no false positives.
  • Disable session upload progress: If you cannot patch immediately, set session.upload_progress.enabled=0 in your php.ini to remove one of the primary vectors for injecting controlled session data.
  • Limit session data: Avoid storing large, untrusted user-controlled strings in sessions. Reduce the surface area for potential corruption.
  • Configure FastCGI securely: Turn off FastCGI connection reuse in your web server configuration to mitigate the request smuggling vulnerability (CVE-2026-129289).
  • Monitor with attack scores: If using Business or Enterprise plans, enable WAF attack score to detect second-stage payloads like shell commands or webshell traffic that may follow an initial compromise.
  • #php
  • #security
  • #waf
  • #vulnerability
  • #cloudflare

Tools from the Bytechap store

Keep reading

All stories