Security

Cloudflare WAF updates protect against phpAfterShell and six other critical PHP flaws

Cloudflare patches its web application firewall to block phpAfterShell attacks and three additional PHP security flaws; patching PHP remains essential.

4 min readSource: Cloudflare Blog

Curated by Kandala Guruprasad. Drafted with AI and checked against the source.

Cloudflare WAF updates protect against phpAfterShell and six other critical PHP flaws

TL;DR

  • On November 19, depthfirst disclosed phpAfterShell, a critical PHP vulnerability (CVSS 9.2) in the default session handler that enables remote code execution.
  • Cloudflare updated its WAF to detect phpAfterShell attacks across all plans, including Free tier.
  • Three new WAF rules protect against related PHP flaws: request smuggling in PHP-FPM (CVE-2026-129289) and two SOAP extension vulnerabilities (CVE-2026-15353 and CVE-2026-129506).
  • WAF protection is defense in depth, not a substitute for patching.
Vulnerability
phpAfterShell - PHP session
CVSS Score
9.2 (Critical)
Fixed in PHP
8.2.36, 8.3.37, 8.4.28, 8.5.13

What happened

Security researcher depthfirst disclosed phpAfterShell (CVE-2026-126714), a critical vulnerability in PHP's default file-based session handler that permits remote code execution. The PHP project released patches on November 19, 2026, covering versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0. These releases address 16 security vulnerabilities in total, with six rated critical under CVSS 4.0. As of the disclosure date, no evidence of exploitation in the wild or inclusion in CISA's Known Exploited Vulnerabilities catalog has been reported.

How phpAfterShell works

PHP stores session data in files by default. When an application calls session_start(), PHP reads and deserializes the session file contents into the $_SESSION array. At the end of the request, updated session data is written back to the same file. The vulnerability is triggered when this write operation is interrupted, leaving the session file containing the start of new data followed by the end of old data. On the next request, session_start() deserializes this corrupted mixture. If an attacker controls the old data, PHP may deserialize objects of the attacker's choice.

An attacker typically gains the ability to place controlled data in a session through two methods: PHP's session upload progress feature, which writes file upload information into the session and can be manipulated by a remote client, or applications that store large user-controlled strings directly in the session. Exploitation also requires interruption at a precise point during the write operation and either a suitable deserialization gadget chain within the application or, according to depthfirst, chaining with an undisclosed memory-corruption bug in a PHP-native class. Sources do not confirm whether that second bug is addressed in the November 19 releases.

Six additional critical PHP flaws fixed

The same PHP releases patch six more critical vulnerabilities, each requiring specific server configurations to be exploitable. CVE-2026-129289 permits request smuggling in PHP-FPM when a front end reuses backend FastCGI connections (such as nginx with fastcgi_keep_conn enabled or Apache mod_proxy_fcgi with enablereuse on), an application path that opens php://input without reading it fully, and knowledge of an existing PHP script path. CVE-2026-115560 is an object injection flaw in the session serializer, now expanded in scope to applications or pools sharing a session store while using different serializers. CVE-2026-129496 is a use-after-free in the timezone cache affecting non-thread-safe builds with startup diagnostics in the error log. CVE-2026-129481 is a use-after-free in session shutdown described as an incomplete fix for an earlier flaw; it affects PHP 8.3 and later. CVE-2026-129474 and CVE-2026-129182 are use-after-free flaws in fatal error backtraces; the first requires PHP 8.5 or later with backtraces enabled by default, while the second requires specific path-level settings and certain Apache or front-end configurations.

Cloudflare WAF updates

Cloudflare updated its WAF to detect phpAfterShell attacks, including for customers on the Free plan. The rule relies on detection logic added on November 19 to an existing PHP remote code execution rule first deployed in October 2026 for php2shell vulnerabilities. Because phpAfterShell shares an attack technique with php2shell—planting serialized PHP data in session storage for deserialization—the existing rule already partially matched phpAfterShell patterns before the vulnerability was publicly disclosed.

On paid plans (Pro, Business, and Enterprise), Cloudflare added three new rules for the related PHP flaws: one covering PHP-FPM request smuggling (CVE-2026-129289) and two for SOAP extension vulnerabilities (CVE-2026-15353 and CVE-2026-129506). These new rules are enabled by default but set to Log mode rather than Block because the request patterns they detect can appear in legitimate traffic. Customers should review matches in Security Events and change the action to Block once they confirm the rules do not interfere with normal operations.

What the WAF cannot protect

WAF protection is a supplementary layer, not a replacement for upgrading PHP. Several limitations mean that patching and restarting workers remains essential. The WAF cannot block the deserialization step itself—phpAfterShell's final execution happens inside PHP when it reads a corrupted session file, though the WAF can block requests that plant the payload. Session data originating from other sources such as databases, queues, or upstream APIs may never traverse the WAF in recognizable form. Some flaws including CVE-2026-129496, CVE-2026-129481, CVE-2026-129474, and CVE-2026-129182 depend on server state like error logs and worker lifecycle and lack dedicated WAF rules; configuration changes and patching are required. Traffic bypassing Cloudflare, such as internal service communication and directly exposed PHP-FPM listeners, cannot be protected by the WAF.

Affected versions and next steps

Vulnerable versions include PHP 8.2 prior to 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. PHP 8.1 and earlier are end-of-life; depthfirst reports that official 7.4, 8.0, and 8.1 branches are unaffected by phpAfterShell, though PHP indicates CVE-2026-129289 dates to PHP 5.6.0 and older releases may be vulnerable to CVE-2026-115560. Linux distributions often backport fixes without updating the version number, so administrators should check the full package version against their distribution's advisory. Upgrading PHP and restarting all workers is the only complete fix. Cloudflare continues monitoring for new exploitation techniques and attack variations and will update detection rules accordingly.

Source

Cloudflare Bloghttps://blog.cloudflare.com/phpaftershell-waf-protection/

AI-assisted, verified against the source. This post was drafted with AI from the primary source linked above and checked automatically against it. For anything you depend on, read the original.

  • #php
  • #security
  • #waf
  • #vulnerabilities
  • #cloudflare

More in Security