PHP patches critical session flaw CVE-2026-126714 in latest releases
New PHP updates fix phpAfterShell, a critical vulnerability in default file-based session storage that allows remote code execution via interrupted writes.
PHP maintainers have released emergency updates to fix a critical security vulnerability known as phpAfterShell, tracked as CVE-2026-126714. The flaw, rated 9.2 out of 10 on the CVSS 4.0 scale, affects the default file-based session handler and could allow attackers to execute arbitrary code on affected servers. These new releases arrive shortly after the October 21 updates that addressed the PHP2Shell vulnerabilities, meaning servers patched last month remain vulnerable until they apply today’s fixes.
What happened
The vulnerability was discovered by Depthfirst, a security research firm, which reported the issue to the PHP development team. The core issue lies in how PHP handles session data stored in files when a write operation is interrupted. If an attacker can force the PHP worker process to stop midway through writing session data, the resulting file may contain a mix of old and new data. By carefully crafting the input, an attacker can manipulate length fields in the serialized data to make harmless text appear as a malicious serialized object.
This specific attack vector leverages the upload progress feature, which writes to the session before the application’s own code executes. This means an attacker does not need a dedicated upload page; any page that starts a session is potentially exploitable if upload progress is enabled. The researchers demonstrated that by triggering an out-of-memory error in a threaded PHP build, they could kill the worker process at the precise moment needed to corrupt the session file. On their test systems, they successfully planted a harmless object after approximately 11 attempts.
It is important to note that the October 21 releases, which fixed the PHP2Shell flaws, did not address this underlying issue. While those earlier patches limited which classes could be loaded during upload progress recording, they did not fix the file write mechanism itself. Consequently, object data could still reach the disk and become active during a subsequent standard request when session_start() is called. Neither the PHP maintainers nor Depthfirst have reported any active exploitation of this flaw in the wild.
How it works
PHP’s default session handler stores data in plain files, where each value consists of a name followed by serialized data. The format relies on length fields to determine where one string ends and the next begins, with no explicit marker indicating that a write operation has completed successfully. When PHP writes to these files, it locks them, but this lock cannot prevent corruption if the process dies unexpectedly during the write.
If the process terminates mid-write, the file may retain the beginning of the new data alongside the end of the old data. An attacker can exploit this by controlling the length fields in the new data. This manipulation tricks PHP into interpreting residual bytes from the previous session state as a new, separate record. If this record contains a serialized object, PHP will instantiate it the next time the session is loaded. To achieve remote code execution, the attacker typically needs a "gadget chain"—a sequence of existing code within the application or PHP itself—that performs dangerous actions when the object is created or destroyed.
Key details
- Affected versions: PHP 8.2 before 8.2.36, 8.3 before 8.3.37, 8.4 before 8.4.28, and 8.5 before 8.5.13.
- Fixed versions: PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13, and the newly released 8.6.0.
- Default change: The new releases disable
session.upload_progress.enabledby default, whereas it was previously enabled. - Mitigation limitation: Disabling upload progress closes the primary tested attack path but does not fix the underlying file write vulnerability if other methods inject attacker-controlled data into sessions.
- End-of-life status: PHP 8.1 and older are end-of-life. While official mitigation branches for 7.4, 8.0, and 8.1 are not affected, unpatched builds of these versions remain vulnerable.
- Linux packages: Some Linux distribution packages may include the fix without changing the visible PHP version number, so version checks alone may be insufficient.
Why it matters
For teams building and maintaining PHP applications, this vulnerability highlights the risks inherent in default configurations. Many developers assume that updating to the latest minor version provides comprehensive security, but the gap between the October 21 PHP2Shell fixes and today’s phpAfterShell patch shows that critical issues can persist across multiple release cycles. Since the default session handler is widely used, a large portion of the PHP ecosystem is potentially exposed unless administrators have explicitly switched to alternative storage backends like Redis or databases.
The fact that the upload progress feature is now disabled by default is a significant behavioral change. Applications that rely on this feature for user experience enhancements, such as progress bars for file uploads, will break after the update unless developers manually re-enable it. This creates a trade-off between convenience and security that teams must manage actively. Furthermore, the reliance on a second bug for full code execution in the researchers' proof of concept suggests that the threat landscape is complex, and partial mitigations may not be enough to secure high-value targets.
What you can do
- Update immediately: Install the fixed release corresponding to your PHP branch (8.2.36, 8.3.37, 8.4.28, or 8.5.13) or upgrade to 8.6.0.
- Rebuild and redeploy: If you use containers, rebuild your images with the new PHP version and redeploy all instances to ensure the patch is active.
- Verify the running version: Check the actual PHP version serving web requests, as command-line interface versions may differ from web server versions.
- Disable upload progress if unable to patch: If you cannot update immediately and do not use upload progress, set
session.upload_progress.enabled = 0in yourphp.iniand restart PHP workers. - Audit session data: Review your application to ensure it does not store untrusted, attacker-controlled data in sessions, which could provide alternative exploitation paths.
- Check Linux package sources: If you rely on OS-provided PHP packages, verify with your distribution’s security advisories whether the fix has been backported without a version number change.



