PHP Patches phpAfterShell Flaw That Revives PHP2Shell Attack Path for RCE

PHP addressed a critical vulnerability tracked as CVE-2026-126714 with a CVSS score of 9.2 on November 19. The flaw, named phpAfterShell by Depthfirst, stems from incomplete session file overwrites that leave mixed old and new data when writes are interrupted. Attackers who control session data and can trigger an interruption can force object deserialization leading to remote code execution. The issue builds directly on the earlier PHP2Shell problems because PHP still writes session data without first truncating the file. Exploitation requires default session storage, an upload-progress route or similar, a mid-write process termination, and a deserialization gadget chain. Patches are available in PHP 8.6.0, 8.5.13, 8.4.28, 8.3.37 and 8.2.36. No in-the-wild exploitation has been observed so far.

SecurityWeekTranslated from English

Read at source

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.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Vulns & Exploits

Docker Sandboxes Flaw Allows Malicious Kits to Exfiltrate AI API Keys Without User Prompts
OFFIS DCMTK Toolkit Hit by Critical Missing Authorization and Partial String Comparison Flaws
CISA Warns of Critical Vulnerabilities in Nextgen Healthcare Mirth Connect Allowing Arbitrary Script Execution and Man-in-the-Middle Attacks