phpAfterShell: PHP 8.5.13, 8.4.28 and 8.3.37 fix 17 flaws
On 19 November 2026 PHP released 8.2.36, 8.3.37, 8.4.28 and 8.5.13 as security releases. They fix phpAfterShell (CVE-2026-126714, CVSS 9.2), where an interrupted write to a file-backed session can lead to deserialization of attacker-chosen objects, and 16 other flaws, six critical. Upgrade, restart every worker and check session.upload_progress.enabled.
PHP shipped security releases for every supported branch on 19 November 2026: 8.2.36, 8.3.37, 8.4.28 and 8.5.13. The headline fix is phpAfterShell, tracked as CVE-2026-126714 with a CVSS 4.0 score of 9.2, a race in the default files session handler that can end in remote code execution. Cloudflare's summary counts 16 more vulnerabilities fixed in the same releases, six of them critical, so if you run PHP anywhere this is a patch-now item even if you think phpAfterShell doesn't reach you.
This comes a month after the 21 October releases that fixed the php2shell bugs (CVE-2026-109618 and CVE-2026-109619). One of the new CVEs is an incomplete fix for one of those.
How phpAfterShell works
The PHP advisory is titled "Partially overwritten session files can lead to remote code execution". When a session changes, ps_files_write() writes the new serialized data over the existing file without clearing it first. The file lock does not make that write atomic. If the worker dies part way through, the file can end up holding the start of the new session followed by the tail of the old one.
Nothing bad happens at that moment. The damage comes on the next request for the same session ID, when session_start() deserializes the mixed content. An attacker who controlled both the old and new data can line up the serialized length fields so the leftover bytes parse as an extra session key holding an object of their choosing. With a usable gadget chain in the application, that becomes code execution as the PHP worker.
The depthfirst write-up, which named the bug, explains why this is reachable without authentication. With session.upload_progress.enabled on, PHP writes an upload progress entry into the session while it parses a multipart/form-data request, before your script runs. The attacker picks the session ID and supplies the progress token through a field named PHP_SESSION_UPLOAD_PROGRESS. To interrupt the write, depthfirst describes using held multipart requests to create memory pressure and get the worker OOM-killed, or deeply nested bracket field names to add parser time before the truncate call. It also reports that PHP execution timeouts did not interrupt the buffered write on its Linux test systems.
The conditions the PHP advisory lists:
session.save_handlerisfiles(the default). Other session storage backends are not affected by this specific defect.- The attacker can put controlled data into the session, through upload progress or because the app stores large user-controlled strings there.
- The attacker can interrupt a write at a useful point.
- The application has a usable deserialization gadget chain.
depthfirst says it reached code execution without an application gadget by chaining an undisclosed memory corruption bug in a PHP-native class. Details of that bug are withheld, and neither the advisory nor Cloudflare says whether the 19 November releases fix it.
The fix truncates the session file to zero before writing and aborts the write if truncation fails. An interrupted write can still lose session data, but the old suffix is no longer left behind. The advisory says the code has been there since PHP 4.1.0.
The other 16 fixes
Cloudflare lists the six other critical issues fixed in the same releases:
| CVE | Area | Issue | Conditions |
|---|---|---|---|
| CVE-2026-129289 | PHP-FPM | Request smuggling leading to code execution as the worker | FastCGI connection reuse, an unread php://input path, an existing script path |
| CVE-2026-115560 | Session serializer | Object injection from a serializer mismatch | Session upload progress enabled |
| CVE-2026-129496 | Timezone cache | Use-after-free, possible code execution | Non-thread-safe builds writing startup diagnostics to an error log file |
| CVE-2026-129481 | Session shutdown | Use-after-free, incomplete fix for CVE-2026-109619 | PHP 8.3 and later |
| CVE-2026-129474 | Fatal error backtraces | Use-after-free in magic method backtraces | PHP 8.5 and later |
| CVE-2026-129182 | Fatal error backtraces | Use-after-free | PHP 8.5 with specific path and Apache conditions |
The PHP-FPM smuggling bug deserves attention on its own, because it does not depend on sessions at all. Two SOAP extension flaws, CVE-2026-15353 and CVE-2026-129506, are also fixed. As of 19 November Cloudflare reported no sign of exploitation and none of the 17 in CISA's Known Exploited Vulnerabilities catalog.
Which versions are affected
| Branch | Affected | Fixed |
|---|---|---|
| PHP 8.5 | before 8.5.13 | 8.5.13 |
| PHP 8.4 | before 8.4.28 | 8.4.28 |
| PHP 8.3 | before 8.3.37 | 8.3.37 |
| PHP 8.2 | before 8.2.36 | 8.2.36 |
| PHP 8.6 | release candidates | 8.6.0 (per Cloudflare) |
| PHP 8.1 and older | end of life | no fix |
The 8.6 situation is easy to misread. The PHP 8.6 release went out the same day, and Cloudflare lists 8.6.0 as fixed, but the php.net 8.6.0 announcement does not mention security fixes. depthfirst's table shows 8.6.0 release candidates as vulnerable, so if you were testing an RC, move to the final release.
For 8.1 and older, depthfirst says the official 7.4, 8.0 and 8.1 end-of-life mitigation branches are not affected by phpAfterShell, because their upload progress callback returns without opening the session. PHP says the FPM bug dates back to 5.6.0, though, and releases older than 8.2 may be affected by the serializer mismatch bug. Treat anything before 8.2 as vulnerable with no upstream fix. PHP 8.2 itself reaches end of life on 31 December 2026, so this is likely one of its last patches.
What to do
1. Find every PHP runtime
Check the processes that serve requests, not just what a repository pins:
php -v
php-fpm -v
docker run --rm your-image:tag php -v
grep -rnE 'FROM .*php:' --include='Dockerfile*' .You can paste that output or your Dockerfiles into the PHP security version checker to see which versions need the update.
Linux distributions often backport fixes without changing the version number, so a distro PHP that reports an older version may already be fixed. Check the full package version against your vendor's advisory for these CVE IDs.
2. Upgrade and restart everything
Rebuild container images, upgrade packages, then restart the PHP-FPM master or Apache. Cloudflare's wording is blunt: "the only complete fix is to upgrade PHP and restart every worker." Then confirm the version that is actually answering requests, for example with a temporary phpversion() check behind authentication or your existing health endpoint.
3. Check upload progress settings
Cloudflare says to confirm no php.ini, FPM pool or virtual host sets session.upload_progress.enabled=1, because an explicit setting overrides the new default. Search your config, including pool files and .user.ini:
php -i | grep -E 'session\.(save_handler|upload_progress\.enabled|serialize_handler)'
grep -rn 'upload_progress' /etc/php* /usr/local/etc/php* 2>/dev/nullFew applications use session upload progress. If yours doesn't, set it off explicitly.
4. Reduce exposure if you can't patch today
From the PHP advisory and Cloudflare's post, none of which replaces upgrading:
- Set
session.upload_progress.enabled=0. - Store less untrusted data in sessions, especially large strings.
- Move sessions to a backend that replaces records atomically, such as Redis or a database handler.
- Disable FastCGI connection reuse between your web server and PHP-FPM.
- On PHP 8.5, set
fatal_error_backtraces=0. - Fix PHP startup warnings, or send errors to syslog instead of a file.
- Keep PHP-FPM listeners off untrusted networks.
Cloudflare's managed rule "PHP Remote Code Execution Attack #6" blocks known phpAfterShell patterns on all plans, including Free.
Open questions
- The PHP-native memory corruption bug in depthfirst's chain is undisclosed. Until it is, assume the gadget requirement offers less protection than it sounds.
- The php.net release announcements don't name the CVEs, and the PHP advisory lists patched versions for 8.2 to 8.5 only. Watch the advisory and the PHP changelog for updates.
- Images and platforms that bundle PHP, from WordPress hosts to CI base images, ship fixes on their own schedules.
Sources
- PHP security advisory GHSA-fm2m-fjf5-v3cp
- php.net release announcements
- depthfirst: phpAfterShell
- Cloudflare: How Cloudflare WAF helps protect against phpAfterShell
FAQ
Which PHP version fixes phpAfterShell?
PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13, all released on 19 November 2026. Cloudflare also lists PHP 8.6.0 as fixed, while 8.6.0 release candidates are affected. PHP 8.1 and older are end of life and get no fix.
Am I affected if I don't use session upload progress?
Possibly. The PHP advisory says the bug is not limited to upload progress: applications that store large user-controlled strings in file-based sessions can also be affected. The same releases also fix the PHP-FPM request smuggling bug and other flaws unrelated to sessions, so upgrade regardless.
Does storing sessions in Redis protect me?
From phpAfterShell itself, yes: the advisory says other session storage implementations are not affected by this file-write defect. It does not protect you from the other 16 vulnerabilities, such as CVE-2026-115560 in the session serializer or the PHP-FPM bug.
Is phpAfterShell being exploited?
As of 19 November 2026 Cloudflare reported no indication of exploitation, and none of the 17 CVEs was in CISA's Known Exploited Vulnerabilities catalog. A detailed write-up is public, so plan as if exploits will follow.
Written by the CodeBeast Team with AI assistance. Spotted a mistake? Email support@codebeast.ai.