A critical flaw in PHP's default session handler can let an attacker plant objects in a session file and, if the application has a suitable gadget chain, run code on the server. Researchers at depthfirst call it phpAfterShell, and it gets around the fix for the earlier php2shell bug (CVE-2026-109618). PHP shipped patched releases on November 19, 2026.
What Is It
PHP's files session handler, which is the default, writes updated session data into the existing session file without clearing it first. If that write is interrupted, the file can end up with the start of the new session followed by the tail of the old one. Because serialized strings carry length fields, an attacker who controls part of the session data can shape the new prefix so the leftover bytes are read as a separate key and a serialized object. That object is created the next time a request calls session_start() with the same session ID.
One way to supply the data is session upload progress. With it enabled, a multipart upload makes PHP rewrite the session file on every progress update, and depthfirst says those writes are not atomic. PHP's advisory adds that a hard memory-limit failure in another thread of a threaded build can also interrupt the write. NVD classifies it as CWE-367, a race condition.
The earlier php2shell fix stopped objects from becoming active during the upload callback. depthfirst says it did not make the session file update safe, so the underlying problem stayed. Its write-up withholds some details and chains this flaw with a memory-corruption bug in a PHP-native class.
Why It Matters
The PHP Group scores it CVSS 4.0 9.2 (Critical): network attack vector, low complexity, no privileges or user interaction, though specific conditions must be in place for an attack to work. NVD has not scored it yet and shows the record as "Received."
Exploitation needs a well-timed interruption of a write and, per the PHP advisory, a suitable gadget chain in the application. depthfirst says the timing needed calibration on each host. The flaw is not in CISA's Known Exploited Vulnerabilities catalog. The CISA Coordinator's SSVC entry records exploitation as "none," automatable as "no," and technical impact as "total." Successful exploitation would run code with the PHP worker's privileges.
What's Vulnerable
The PHP Group and NVD list these branches as affected:
- PHP 8.2.x before 8.2.36
- PHP 8.3.x before 8.3.37
- PHP 8.4.x before 8.4.28
- PHP 8.5.x before 8.5.13
The advisory says other session storage implementations are not affected by this specific file-write defect. depthfirst reports that unpatched 7.4, 8.0 and 8.1 builds keep the original behavior. Downstream packages may carry changes without changing the PHP version string, so check your vendor's build.
Patch Status
PHP fixed this in 8.2.36, 8.3.37, 8.4.28 and 8.5.13, all released on November 19, 2026. According to the PHP advisory, the patch truncates the session file to zero before writing and aborts if truncation fails.
The sources disagree. depthfirst's table, dated to the official php-src trees as of November 17, lists 8.2.35, 8.3.36, 8.4.27 and 8.5.12 as vulnerable, plus 8.4.28RC1 and 8.5.13RC1 onward, and describes no complete fix. The PHP advisory names the final releases as patched. That snapshot predates them, so we follow the vendor.
Admins who cannot upgrade yet can apply the advisory's workarounds. Turn off session.upload_progress.enabled if you do not need it, keep untrusted data out of sessions, and use a session backend that replaces records atomically. Upgrading is the real fix.