PHP last week patched a critical-severity vulnerability residing in the same dangerous state as the PHP2Shell flaws, cybersecurity firm Depthfirst says.
Dubbed phpAfterShell, the security flaw is tracked as CVE-2026-126714 (CVSS score of 9.2), and was resolved on November 19 alongside six other critical issues.
According to Depthfirst, the bug could allow an attacker who can control data written to a session file and interrupt the session write operation to trigger an object deserialization and achieve remote code execution (RCE).
It exists because PHP overwrites the session file from the start without emptying it first. If the operation is interrupted mid-write, or before the subsequent truncation operation removes old trailing data, the file is left with mixed content: fresh session data followed by remnants of the old session.
“We discovered reliable methods to interrupt the file operation during session upload-progress updates, allowing us to splice the prefix of one valid session with the suffix of another. A subsequent session operation treats the corrupted data as legitimate server-side state, giving attackers control over session values and the ability to trigger object deserialization,” Depthfirst notes in its technical write-up.
An attacker could arrange the new and old data so that the combined file would be interpreted differently from the original sessions, and parts of ordinary strings would become serialized object data. A future session would create the objects and invoke their deserialization.
“Session upload progress provides one way for a remote client to influence stored session data through multipart uploads. The same underlying problem can arise when an application stores large user-controlled strings in a session. In threaded PHP builds, a hard memory-limit failure in another thread can terminate the process while the session write is in progress,” PHP notes in its advisory.
phpAfterShell, Depthfirst explains, is related to PHP2Shell, which occurred because, during the parsing of an unauthenticated multipart request, PHP’s upload-progress callback could open and decode a file-backed session before the target script would begin.
Because objects would become active during the callback, PHP added restrictions to which objects could be created in memory, but did not modify the underlying file update behavior.
“Even with the new restrictions in place, the callback still reads the existing Session, adds upload-progress state, serializes the whole thing, and writes it back to the same file,” Depthfirst explains.
Successful exploitation of phpAfterShell requires certain conditions to be met: default session storage to be active, an exploitation route (the easiest is upload progress tracking), the PHP process to stop mid-write, a request to call session_start() on the corrupted file, and a deserialization-to-code-execution path.
Patches for the vulnerability were included in PHP versions 8.6.0, 8.5.13, 8.4.28, 8.3.37, and 8.2.36. There appear to be no reports of phpAfterShell’s in-the-wild exploitation.
Related: SAP NetWeaver, Cisco Expressway Flaws Exploited in Attacks
Related: WhatsApp Fixes Flaw Uncovered While Disrupting Scam Campaign
Related: Ruby Patches Ruby2Shell Vulnerability That Could Lead to RCE
Related: F5 Patches Critical NGINX2Root Flaws as PoC Exploits Go Public
