
PHP’s default file-based session storage can be configured to return objects chosen by an attacker, interrupting the writing of a session at just the right moment. When combined with a second weakness, such as an appropriate gadget chain in the application, these objects can allow the attacker to execute code on the server.
Today’s PHP versions fix the flaw, called phpAfterShell.
The fault is followed as CVE-2026-126714 and rated 9.2 out of 10 on the CVSS 4.0 scale by PHP officials. Depthfirst, a security company, says it found the flaw and reported it to officials.
The October 21 PHP releases, which address two critical vulnerabilities known as PHP2Shell, do not contain this fix. Updated servers then remain affected until they install today’s versions. Neither the maintainers nor the company report any attacks using phpAfterShell.
Who is affected and what to do
These versions are affected, according to the maintainers’ security advisory:
Fork | Affected versions | Corrected version |
|---|---|---|
PHP8.2 | Before 8.2.36 | 8.2.36 |
PHP8.3 | Before 8.3.37 | 8.3.37 |
PHP8.4 | Before 8.4.28 | 8.4.28 |
PHP8.5 | Before 8.5.13 | 8.5.13 |
PHP 8.6.0, also released today, includes the fix.
The flaw lies in the file session manager, which PHP uses by default. Sessions persisted in Redis, a database, or another store are not affected by this flaw, although each store’s handling of a cut update requires its own verification.
Whether an attacker needs to log in depends on how the application exposes its session management.
On the path tested by the company, the attacker uses download progress, a PHP feature that records the download progress of a file in the user’s session. When the feature is enabled, a multi-part form upload containing its field causes PHP to write to the session before the application code executes. The app doesn’t need a download page, just any page that logs you in later.
PHP 8.1 and earlier are end of life. The official end-of-life mitigation branches for 7.4, 8.0, and 8.1 are not affected, but older, unpatched versions of these releases are, according to the company.
The company’s remediation guidelines outline these steps:
- Install the patched version for your branch, as noted above. If you are running PHP 8.1 or earlier, switch to a supported branch.
- Rebuild all container images and redeploy them.
- Verify that the PHP version serving web requests is the new one.
If you can’t update yet and your app doesn’t use download progress, set session.upload_progress.enabled = 0 In php.ini or server PHP settings, then restart PHP Workers. Also limit the untrusted data your application stores during sessions.
Disabling the feature is not a complete solution. This closes the download path, but applications that place attacker-controlled data into sessions through other means remain affected, officials say.
Officials listed the same setting on October 21 as a temporary measure for one of the PHP2Shell flaws. Servers that have kept it disabled since then still need the update.

Moving sessions to a store that replaces records in a single step also avoids this defect. Updating is always the recommended fix for sites that retain the file manager.
According to the company, Linux distribution packages can include the patch without changing the PHP version number, so the version number alone may not indicate whether a server is patched.
Once installed, patched versions flush the session file before each write and stop writing if that step fails. An interrupted write can still lose session data, but it can no longer leave old data behind for an attacker to use.
Updates also disable download progress by default. The Hacker News compared the PHP source code for the October 21 and today’s versions. The built-in setting is enabled in 8.2.35, 8.3.36, 8.4.27, and 8.5.12, and disabled in 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0.
The release notes do not mention or explain the change. The sample php.ini files still show the old parameter in a commented line. A php.ini file, distribution package, or hosting panel that enables the setting will retain it.
Where nothing else defines it, apps that depend on download progress will need to be re-enabled after the update.
The same versions also fix other PHP security vulnerabilities.
How the attack works
The attack begins with session writing performed before application code is executed, Depthfirst researchers say in their technical analysis.
A PHP session file stores each value as a name followed by serialized data. The length fields in this data tell PHP where each string ends, and nothing in the file marks a write as complete.

PHP locks the file while it’s writing, but the lock can’t undo a write that stops halfway. If the worker process stops midway, the file can retain the start of new data and the end of old data.
By setting the length of the new data, an attacker can cause the text that was harmless in the old data to be read as a separate record, including a serialized object. The following query that calls session_start() loads this record and creates the object.
The researchers’ public proof uses a harmless built-in object, stdClass, which appears in the session after the file is mixed.
Emergency PHP2Shell patches on October 21 responded to an earlier attack via the same step.
“The original exploit stopped working, but the underlying problem was still there,” the researchers say of the PHP2Shell patch.
This exploit required objects to become active while PHP saved download progress, so maintainers limited which classes could load at that time. The change did not affect the writing of the file. The object’s data always reaches disk and becomes active later, when an ordinary query calls session_start().
The attack depends on stopping the writing at the right time. Maintainers say one solution is a memory limit failure in another thread of a threaded PHP build, which can kill the process being written.
Executing the code then still requires an appropriate gadget chain in the application, and the flaw can also corrupt the session state.
In the researchers’ own Linux tests, PHP’s execution timeout only triggered after writing was complete, so they used an out-of-memory kill to stop the worker while it was writing.
The planted object appeared on the 11th attempt when retrying. This number measures getting the file into the correct state on their servers, not how often the code executes successfully.
Their own channel didn’t need any of the app’s gimmicks, the researchers say. He used a second bug instead, memory corruption in one of PHP’s built-in classes.
They are withholding its details for coordinated disclosure and have not indicated whether this bug is fixed in today’s releases.
The same trick can also override ordinary session values, such as the person logged in, their permissions, or a CSRF token, before the app checks them, the researchers say.
