A PHP session file has no marker that says a write finished. That small gap is the whole of phpAfterShell: kill a PHP worker at the right moment while it rewrites a session, and the next request can read back a file that is half new data and half old, with old bytes reinterpreted as live PHP objects.
In short: phpAfterShell (CVE-2026-126714) is a critical flaw in PHP’s default file-based session handler that can lead to remote code execution when an attacker can shape session data, interrupt a write and reach a gadget chain. PHP fixed it on 19 November 2026 in 8.2.36, 8.3.37, 8.4.28 and 8.5.13, and switching off upload progress only narrows the path to it.
- What is phpAfterShell?
- Why does phpAfterShell matter now?
- How does phpAfterShell work?
- How hard is phpAfterShell to exploit?
- Who is affected by phpAfterShell?
- What else did the 19 November PHP release fix?
- How do you detect phpAfterShell attempts?
- How do you fix phpAfterShell?
- phpAfterShell vs PHP2Shell: how do they compare?
- What is still unknown?
- The bottom line
- Sources
What is phpAfterShell?
phpAfterShell is a vulnerability in ext/session, the part of PHP that stores the $_SESSION array between requests. PHP’s maintainers published it as advisory GHSA-fm2m-fjf5-v3cp with a CVSS 4.0 score of 9.2 (Critical). The weaknesses listed are CWE-367, a time-of-check to time-of-use race, and CWE-662, improper synchronisation.
The security company depthfirst reported it privately in late October 2026 and named it. Its write-up is by researcher Yuhang Wu, and its landing page says the bug was found by its AI models working alongside its researchers. The PHP advisory credits the reporter account zplinn, with the maintainer account iluuu1994 developing the fix.
What is a PHP session handler?
A session handler is the code that saves and loads session data. The default is files, which writes each session to a file on disk. Other handlers store sessions in Redis, Memcached or a database. phpAfterShell affects only the files handler, but because it is the default, it covers a very large share of PHP sites.
What is PHP deserialization?
Serialization turns PHP values into a string; deserialization turns the string back into values, including objects. When PHP creates an object this way it can run “magic methods” such as __wakeup or __destruct. A gadget chain is a sequence of such methods, already present in the application or its libraries, that an attacker can string together to reach something dangerous like running a command.
Why does phpAfterShell matter now?
It is the third critical PHP session bug in a month. On 21 October 2026 PHP shipped fixes for PHP2Shell, two critical bugs tracked as CVE-2026-109618 and CVE-2026-109619. CISA added both to its Known Exploited Vulnerabilities (KEV) catalog on 26 October, five days later.
On 23 October PHP posted an informational advisory about session upload progress and told admins to set session.upload_progress.enabled=0 until the next release. That issue became CVE-2026-115560.
depthfirst says phpAfterShell came from a closer look at the PHP2Shell patch. According to its write-up and The Hacker News, the October fix restricted which classes could load during the upload-progress step but did not change how the session file is written. The researchers summed it up this way, as quoted by The Hacker News: “The original exploit stopped working, but the underlying problem was still there.”
How does phpAfterShell work?
The advisory and depthfirst describe the mechanism in enough detail to understand it without a working exploit. This is the conceptual version.
The write is not atomic
When PHP updates a session, ps_files_write() writes the new serialized data into the existing file. Before the fix it did not empty the file first on every write. If the process stops after replacing only part of the file, what remains is a prefix of the new session followed by the tail of the old one.
PHP’s advisory notes that the session file lock does not help. It stops other requests from touching the file during the write, but it cannot make an interrupted write atomic.
Old string bytes become objects
The session decoder reads the mixed file as one record. Carefully arranged old and new data can make it parse differently from either original. Bytes that used to sit inside an ordinary string can become serialized object data. depthfirst says a crafted length field is what lets the leftover bytes be read as a new record.
The next session_start() then creates those objects and runs their deserialization methods.
Two ways to shape the data
The advisory names two input paths:
- Session upload progress. During a multipart upload, PHP stores progress data in the session. depthfirst points out that this callback runs before the target script, so the upload endpoint does not need to call
session_start()itself. - Large user-controlled strings. Any application that saves big user-supplied values in the session gives the attacker the same lever, upload progress or not.
Interrupting the write
The attacker also has to make the worker die mid-write. PHP’s advisory says that in threaded builds, a hard memory-limit failure in another thread can terminate the process at that point. depthfirst used memory pressure and an out-of-memory kill in its tests.
How hard is phpAfterShell to exploit?
Harder than the 9.2 score suggests on its own. The CVSS vector itself marks “attack requirements: present”, and PHP’s advisory lists three conditions for code execution: influence over the session data, an interruption at a useful point, and a suitable gadget chain in the application.
Timing is fragile
depthfirst describes two variants. In variant A, which interrupts during the write itself, “the promoted object appeared on attempt 11” in a fresh HTTP run. In variant B, which interrupts between writing and truncating, a run reached the target state in ten attempts after one timing adjustment.
The company is open that this did not come easily. Its timing controller only worked after several failed models and kernel probes, and it notes that a fixed delay worked on one machine and failed on another.
The chain needed a second bug
The most important caveat: depthfirst’s end-to-end code execution chained phpAfterShell with a separate memory-corruption bug in a built-in PHP class. That second bug is withheld for coordinated disclosure, and both The Hacker News and Cloudflare say it is not established whether it is fixed in the 19 November releases.
Without that bug, an attacker needs a gadget chain in the target application or its libraries. Many PHP applications ship popular libraries that have known chains, so this is a real but not universal requirement.
Who is affected by phpAfterShell?
| Branch | Vulnerable | Fixed in |
|---|---|---|
| PHP 8.2 | before 8.2.36 | 8.2.36 |
| PHP 8.3 | 8.3.0 to 8.3.36 | 8.3.37 |
| PHP 8.4 | 8.4.0 to 8.4.27 | 8.4.28 |
| PHP 8.5 | 8.5.0 to 8.5.12 | 8.5.13 |
| PHP 8.6 | release candidates | 8.6.0 |
PHP says the affected code has been present since PHP 4.1.0, based on code inspection. depthfirst says the official end-of-life mitigation branches for 7.4, 8.0 and 8.1 disable upload progress in the callback and are not affected. NetSPI takes a more cautious line and says older unsupported releases may also be affected. Treat any unpatched old build as exposed.
The October PHP2Shell releases (8.2.35, 8.3.36, 8.4.27 and 8.5.12) do not contain this fix.
How to check your exposure
depthfirst’s own test has two questions. Is the PHP version that serves web requests older than the fixed release for its branch? Are sessions stored with the default files handler? If both answers are yes, it considers you affected.
Three practical points from Red Hat and NetSPI:
- Check the effective settings for each PHP-FPM pool, virtual host and application override. Red Hat warns that “changing only the CLI configuration is insufficient.”
- Confirm that web workers run the new binary, not just the
phpcommand line tool. A quick way is aphpinfo()page served through the same pool, removed afterwards. - Linux distributions often backport fixes without changing the version number, so compare full package versions against your distribution’s advisory.
Red Hat lists RHEL 7, 8, 9 and 10 as affected, along with products and UBI-based containers built on them. Its bulletin, last updated 24 November, says fixes are being expedited.
What else did the 19 November PHP release fix?
phpAfterShell was one of 17 advisories PHP published that day, covering 18 CVEs by NetSPI’s count. Seven were critical, all at 9.2. PHP had warned on 18 November that the critical issues need “non-default configuration or uncommon setups.”
| CVE | Component | Condition that matters |
|---|---|---|
| CVE-2026-126714 | Session files handler | Default files handler |
| CVE-2026-115560 | Session serializer | Upload progress on, mixed serializers on one store |
| CVE-2026-129289 | PHP-FPM | Front end reuses FastCGI connections |
| CVE-2026-129496 | Timezone cache | Startup diagnostic written to a log file |
| CVE-2026-129481 | Session shutdown | PHP 8.3 and later |
| CVE-2026-129474 | Exception backtraces | PHP 8.5 |
| CVE-2026-129182 | Fatal error backtraces | PHP 8.5, specific settings |
CVE-2026-115560: the serializer mismatch
PHP’s php session format separates a key from its value with a | character; php_binary and php_serialize store keys differently. If upload progress writes data in one format and another process reads it as php, an attacker-supplied | inside a key can push bytes into the deserializer. PHP’s advisory says the report showed command execution with Guzzle and Monolog gadgets. The fix turns upload progress off by default and blocks runtime changes to the serializer while it is on.
CVE-2026-129289: PHP-FPM request smuggling
This one may matter more to many admins than phpAfterShell. When a front end such as nginx with fastcgi_keep_conn on or Apache with enablereuse=on keeps the FastCGI connection open, unread request-body bytes can be parsed as a second, forged FastCGI request. PHP’s advisory says that lets an unauthenticated attacker run PHP code through PHP_ADMIN_VALUE settings. Default nginx and Apache setups that close the connection after each request are not affected. If you run PHP behind nginx, our nginx2root breakdown covers the front-end side of the same stack.
How do you detect phpAfterShell attempts?
None of the sources publishes indicators of compromise or an ATT&CK mapping for phpAfterShell. The closest technique is T1190, Exploit Public-Facing Application. Detection therefore relies on behaviour.
What to look for
- Worker crashes. The attack depends on killing a PHP worker mid-write. Repeated out-of-memory kills,
memory_limitfatal errors or cgroup OOM events for PHP-FPM or Apache are worth investigating, especially in bursts from one client. - Large multipart uploads with progress fields. Requests that carry a
PHP_SESSION_UPLOAD_PROGRESSfield to endpoints that never take uploads stand out. - Session errors. Session decode failures or corrupted session warnings in PHP logs. NetSPI also recommends reviewing logs for fatal errors and unusual worker crashes.
- Child processes of PHP workers. A shell,
curlorwgetspawned byphp-fpmor an Apache worker is a strong signal for any PHP code execution bug. - Session file anomalies. Session files that contain class names your application never stores in sessions.
WAF coverage
Cloudflare updated an existing managed rule on 19 November to cover phpAfterShell alongside the PHP2Shell CVEs and CVE-2026-115560. It is set to block by default on all plans. A separate PHP-FPM rule for CVE-2026-129289 shipped for paid plans with a default action of log. A WAF can only see the HTTP side of the attack, so treat it as a delay, not a fix.
How do you fix phpAfterShell?
- Upgrade PHP to 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0, or to your distribution’s patched package. The fix empties the session file before every write and aborts if that fails.
- Restart every PHP process. Restart the PHP-FPM master or Apache so all workers load the new binary, then rebuild and redeploy containers.
- Check for explicit upload progress settings. The new releases turn
session.upload_progress.enabledoff by default, but an explicit1in php.ini, a pool file or a virtual host overrides that. - Until you can patch, disable upload progress in php.ini or the FPM pool, not with
ini_set(), which PHP says is too late. This blocks the easiest path but, as depthfirst puts it, not the flaw itself. - Limit untrusted data in sessions. Store IDs and flags, not large user-supplied strings.
- Consider an atomic session backend. PHP’s advisory says a backend that replaces records atomically avoids this defect. Redis, Memcached or a database handler all qualify for this specific bug.
- Turn off FastCGI connection reuse if you cannot patch yet, to cover CVE-2026-129289, and keep PHP-FPM listeners off untrusted networks.
phpAfterShell vs PHP2Shell: how do they compare?
| PHP2Shell | CVE-2026-115560 | phpAfterShell | |
|---|---|---|---|
| CVEs | 2026-109618, 2026-109619 | 2026-115560 | 2026-126714 |
| Fixed | 21 October 2026 | 19 November 2026 | 19 November 2026 |
| CVSS 4.0 | 9.2 each | 9.2 | 9.2 |
| Root cause | Memory corruption, stale state | Serializer mismatch | Non-atomic session write |
| Config needed | Varies | Upload progress plus mixed serializers | Default files handler |
| In CISA KEV | Yes, 26 October | No (27 November) | No (27 November) |
The pattern is familiar. A first patch closes the demonstrated exploit, and researchers who read the patch find the root cause still there. We saw the same with Drupal Fail2Install, where the first patch was not enough, and with how quickly attackers moved on the WP Rocket bug six days after its fix. PHP2Shell’s five-day path to KEV is a reason not to wait for exploitation reports this time.
What is still unknown?
- The second bug. depthfirst’s working chain relied on an undisclosed memory-corruption bug in a native PHP class. Whether the 19 November releases fix it is not stated.
- The version table. depthfirst’s research page includes a table dated 17 November that lists the 8.4.28 and 8.5.13 release candidates as vulnerable to its second variant. PHP’s advisory and depthfirst’s own landing page treat the final 8.4.28 and 8.5.13 as fixed. The sources do not explain the difference, so confirm with your vendor.
- Old branches. depthfirst says the 7.4, 8.0 and 8.1 mitigation branches are not affected; NetSPI says older releases may be. The vulnerable code dates back to PHP 4.1.0, so unmaintained builds deserve suspicion.
- Severity in practice. Red Hat rates CVE-2026-129481 Important while others list it as critical, and PHP itself says the critical issues need uncommon setups. Real-world exploitability will depend on gadget chains in popular frameworks.
The bottom line
phpAfterShell is a race in PHP’s default session storage that the PHP2Shell patch did not touch. Exploiting it takes timing, shaped session data and a gadget chain, which is why there are no attack reports yet. Upgrade PHP, restart every worker and remove any explicit upload progress setting now, because the last critical PHP session bug was in CISA’s catalog within five days.
Sources
- PHP security advisory GHSA-fm2m-fjf5-v3cp (CVE-2026-126714)
- PHP security advisory GHSA-658j-r8rw-q6mx (CVE-2026-115560)
- PHP security advisory GHSA-qc49-hpvq-g2w6 (CVE-2026-129289)
- php.net news archive 2026
- depthfirst: phpAfterShell research write-up
- depthfirst: phpAfterShell remediation page
- The Hacker News: phpAfterShell explained
- BleepingComputer: PHP security updates fix 18 flaws
- Cloudflare: WAF protection against phpAfterShell
- Red Hat RHSB-2026-020
- NetSPI: phpAfterShell critical PHP vulnerabilities
- CISA Known Exploited Vulnerabilities catalog
This article is written for defenders and authorised security testers. Only test systems you own or have written permission to assess.