/en/articles/phpaftershell-the-critical-php-session-flaw-that-cloudflares-waf-blocks-but-doesnt-fix
phpAfterShell: the critical PHP session flaw that Cloudflare's WAF blocks but doesn't fix

On November 19, 2026, PHP released versions 8.2.36, 8.3.37, 8.4.28, 8.5.13 and 8.6.0 with fixes for 17 security advisories, seven of them critical. The most eye-catching one has a name of its own: phpAfterShell (CVE-2026-126714), a flaw in the file-based session handler, the one PHP uses by default, that can end in remote code execution with a 9.2 out of 10 rating on CVSS 4.0. A day later, Cloudflare explained that its WAF already blocks the known phpAfterShell attack patterns on all its plans, including the free one. If you have a PHP site behind Cloudflare, that buys you time. It doesn't save you from updating, and Cloudflare itself says so in the same post.
What phpAfterShell is
PHP stores sessions in files. When an application calls session_start(), PHP reads that file and turns it into the $_SESSION array. When the request ends, it writes the updated version to the same file.
According to the official PHP advisory, the problem is in that write: the vulnerable implementation did not empty the file before each write. If the process is interrupted after replacing only part of it, the file ends up with the start of the new session glued to the tail of the old one. On the next read, that mix is interpreted as a valid session, but with a different meaning: bytes that used to be plain text can become a serialized PHP object. PHP sums it up like this: an attacker who can influence the session contents and interrupt the write can make PHP deserialize "attacker-controlled objects."
The advisory says the faulty code has existed since PHP 4.1.0 and that the problem is not limited to the file upload progress feature.

What an attacker needs
Here is the nuance that separates panic from urgency. PHP lists three conditions to get to code execution:
- Influence the session data. The advisory mentions two paths: session upload progress, which writes information about an upload in progress into the session and which a remote client can shape with multipart requests, and applications that store long user-controlled text in the session.
- Interrupt the write at a useful point. depthfirst, the company that says it discovered the flaw, documents that it achieved this by getting the system to kill the process for running out of memory mid-write.
- A chain of deserialization gadgets in the application. depthfirst claims it got around this requirement by chaining a second memory corruption bug in a native PHP class, which it has not disclosed. Cloudflare clarifies that the sources it reviewed don't make it possible to know whether that second bug was fixed in this round.
depthfirst adds a detail that should worry anyone with upload progress turned on: PHP can write the session while processing a multipart request before your script runs its first line. The application doesn't even need an upload form.
The fix, according to PHP, truncates the file to zero before writing and aborts if it can't. An interrupted write can still lose the session, but it no longer leaves behind the old tail that makes the attack possible. Session handlers that don't use files don't have this specific defect, although PHP asks you to separately review how they handle interrupted updates.
The other six critical flaws
Cloudflare's Zero Wire page counts 17 advisories: seven critical, four high and six medium. PHP warned in its advance notice that the critical ones require non-default or uncommon configurations. The ones most likely to affect you:
| CVE | Component | When it affects you |
|---|---|---|
| CVE-2026-129289 | PHP-FPM | The front end reuses FastCGI connections (nginx with fastcgi_keep_conn on, Apache with enablereuse=on, HAProxy) and a route opens php://input without reading it completely |
| CVE-2026-115560 | Session serializer | Upload progress enabled and applications, pools or tasks with different serializers sharing a session store |
| CVE-2026-129496 | Time zone cache | Non-thread-safe (NTS) builds that wrote a startup diagnostic to a PHP log file |
| CVE-2026-129481 | Session close | PHP 8.3 and later; PHP describes it as an incomplete fix for an October flaw |
| CVE-2026-129474 and CVE-2026-129182 | Fatal error backtraces | PHP 8.5, where those backtraces are on by default |
The PHP-FPM one deserves separate attention. According to its advisory, an unauthenticated attacker can sneak a second FastCGI request inside the body of the first and run PHP as the worker, with no memory corruption or race conditions. The same cleanup error affects the persistent lifecycle of LSAPI, the one used by LiteSpeed and OpenLiteSpeed, although there PHP only documents desynchronized requests and does not establish code execution. The fix for CVE-2026-115560, in addition, turns off upload progress by default; if any configuration explicitly turns it on, that line takes precedence over the new value.
What Cloudflare's WAF does and doesn't do
Cloudflare says the protection comes from a PHP remote code execution rule that it deployed as an emergency on October 21 because of php2shell. Since the two flaws share a technique (planting serialized data in the session and waiting for PHP to read it), the rule already detected part of the pattern before it became public. On November 19 it updated it to cover phpAfterShell. It's in the Free Managed Ruleset and in the paid Managed Ruleset, on by default and with the Block action. On the Free plan you don't have to do anything.
For paid plans it added three new rules: one for request smuggling in PHP-FPM and two for flaws in the SOAP extension (CVE-2026-15353 and CVE-2026-129506). Those ship in Log mode, because the patterns they look for also show up in legitimate traffic. Cloudflare recommends reviewing the matches in Security Events and switching them to Block once you confirm they don't break anything.
The most useful part of the post is the list of what the WAF can't see. phpAfterShell's deserialization happens inside PHP, when it reads the corrupted file, and all the WAF can block are the requests that plant the payload. It also doesn't see data that reaches the session from a database, a queue or an API, nor flaws that depend on server state (logs, diagnostics, worker lifecycle), nor traffic that doesn't go through Cloudflare.

What to do, in order
This comes from PHP's and Cloudflare's recommendations. I haven't tested it:
- Check the version that actually serves the web, not the CLI one: FPM, LSAPI, mod_php or whatever you use. Distributions often backport patches without changing the version number, so compare the full package against your distro's advisory.
- Update to 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0, rebuild container images and restart all workers. A service that still has old processes alive is still vulnerable even if the package says otherwise.
- In the meantime, turn off
session.upload_progress.enabledin php.ini, pools and virtual hosts, and limit the untrusted data you store in the session. PHP notes that doing it withini_set()from the application is too late. - Disable FastCGI connection reuse and don't expose PHP-FPM or LSAPI listeners to untrusted networks.
- On PHP 8.5, set
fatal_error_backtraces=0. Fix the startup warnings or send errors to syslog instead of a file. - PHP 8.1 and earlier are no longer supported. depthfirst says the official mitigation branches of 7.4, 8.0 and 8.1 are not affected by phpAfterShell, but PHP indicates that the FPM flaw has existed since 5.6.0.
As of November 19, none of the 17 vulnerabilities were in CISA's known exploited catalog and Cloudflare found no reports of real attacks. With the technical details now public, Cloudflare itself expects attempts to start soon.
My take: this is the second round in a month to pass through the same corner of PHP, sessions and upload progress, and depthfirst says it bluntly: the php2shell patch blocked the original exploit but left the underlying problem alive. If you turned off upload progress in October as a mitigation, you did the right thing. You still have to update: that measure closes one of the paths to phpAfterShell, not the file defect.
Sources
- Partially overwritten session files can lead to remote code execution, PHP advisory GHSA-fm2m-fjf5-v3cp
- PHP News Archive 2026: November 19 releases and advance notice
- PHP 8 ChangeLog
- PHP-FPM request smuggling through an unread HTTP request body, PHP advisory GHSA-qc49-hpvq-g2w6
- Session serializer mismatch can lead to remote code execution, PHP advisory GHSA-658j-r8rw-q6mx
- How Cloudflare WAF helps protect against phpAfterShell and other critical PHP flaws, Cloudflare (November 20, 2026)
- phpAfterShell and six other PHP critical flaws, Cloudflare Zero Wire
- phpAfterShell: From Interrupted Session Writes to Remote Code Execution, depthfirst