Vibeleaderboard
← All Intel
Intel / article

phpAfterShell: critical PHP session flaw and what Cloudflare's WAF covers

Source
blog.cloudflare.com
Author
Cloudflare
Date

Context

phpAfterShell is a flaw in the way PHP saves session data, and Cloudflare's own write-up says its firewall rules reduce exposure while sites patch but do not replace upgrading PHP. The security research company depthfirst disclosed it on November 19, 2026 as CVE-2026-126714, scored 9.2 out of 10 (critical) under CVSS 4.0, and PHP fixed it the same day in versions 8.2.36, 8.3.37, 8.4.28, 8.5.13 and 8.6.0. Those releases fix 16 other vulnerabilities, six of them also rated critical. A session is how a PHP site remembers a visitor between requests, and by default PHP keeps each one in a file on the .

The flaw turns an unfinished file write into trusted data. At the end of a request, PHP writes the updated session back over the same file. depthfirst's research found that this update is not atomic: if the PHP worker dies partway through, the file can hold the start of the new session followed by the tail of the old one. On the next request, PHP reads that mixed content as legitimate session state and deserializes it, rebuilding stored values, including objects, from text. If an attacker controlled the old data, PHP can end up creating objects of the attacker's choice. Even without objects, depthfirst notes, altered session values could replace identity or state before the checks it. Cloudflare reports that PHP's advisory names two ways to get controlled data into a session: upload progress tracking, a feature that records the status of a running file upload in the session, and applications that store large user-controlled strings there. PHP says code execution also needs an interruption at a useful point and suitable existing code in the application to abuse. depthfirst reports reaching code execution without relying on the application's own code by chaining a second, undisclosed memory-corruption bug, and Cloudflare says its sources do not establish whether that second bug is fixed in the new releases.

phpAfterShell grew out of the fix for php2shell, the critical PHP flaws disclosed in October. According to depthfirst, that patch stopped objects from becoming active while PHP recorded upload progress, but did not make the session file update safe when a worker died, so bytes left on disk could become active later when the application loaded the session. The two share a technique, planting serialized PHP data in session storage and waiting for PHP to deserialize it, which is why the Cloudflare rule written for php2shell in October already matched part of the new attack before disclosure.

Cloudflare updated that rule on November 19 to cover phpAfterShell. It is on by default and blocks matching requests on every plan, including Free. Paid plans also get three new rules, one for a PHP-FPM request smuggling flaw (CVE-2026-129289) and two for flaws in PHP's SOAP extension, but those start in Log mode, recording matches without blocking, because the same request patterns can appear in legitimate traffic. The company is explicit about what a firewall in front of a site cannot see. The final phpAfterShell step happens inside PHP when it reads the corrupted file, so the WAF can only block the requests that plant the data. Session data an application copies in from a database, a queue or another API may never pass through the WAF in recognizable form, four of the other critical flaws depend on server state such as error logs and have no dedicated rules, and traffic that bypasses Cloudflare is out of reach.

Affected versions are 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 the 8.6.0 release candidates, though whether a given server is exposed depends on each flaw's conditions. Cloudflare says the only complete fix is to upgrade PHP and restart every worker so it loads the new binary. Linux distributions often backport fixes without changing the PHP version number, so the full package version has to be checked against the distribution's advisory. As of November 19, none of the 17 vulnerabilities was listed in CISA's catalog of known exploited vulnerabilities, and Cloudflare found no source reporting exploitation in the wild.

Key takeaways · AI-distilled
  • phpAfterShell (CVE-2026-126714) fires when PHP's default file-based session write is interrupted: the file can keep the start of the new data plus the end of the old, and the next session_start() deserializes that mix, so attacker-controlled old data can become objects.
  • Per PHP, code execution needs attacker data in the session (session upload progress or large user-controlled strings), an interruption at a useful point, and a gadget chain. depthfirst says it got code execution without an app gadget by chaining a second, undisclosed memory bug.
  • Cloudflare says its WAF can block the requests that plant a payload, but not the deserialization inside PHP, session data copied in from databases, queues or upstream APIs, flaws driven by error logs and worker state, or traffic that never passes through Cloudflare.
  • Cloudflare's new rule for the PHP-FPM request smuggling flaw (CVE-2026-129289) ships in Log mode, not Block, because its patterns also show up in legitimate traffic. Among other conditions, that flaw needs a front end that reuses FastCGI connections.
  • After upgrading, Cloudflare says to restart every PHP worker and check that no php.ini, FPM pool or virtual host still sets session.upload_progress.enabled=1, because an explicit setting overrides the new default.
Terms in this piece · Glossary
  • Server — Software that receives requests, processes them and returns responses; the computer running it is its host.
  • Program — A set of instructions stored so that a computer can run it.
  • Authorization — The check that an authenticated identity is permitted to perform a particular operation on a particular resource.
  • Application — Software arranged so that a person can use it; in this course, the software around a model that accepts your request, prepares the context and shows the reply.
Read the source blog.cloudflare.com
More from Cloudflare
Recommended reads
Comments

Checking sign-in…

Loading comments…