VMTech
Discuss a project →

PHP Releases Fixes for Critical phpAfterShell Session Storage Flaw

PHP Releases Fixes for Critical phpAfterShell Session Storage Flaw

PHP has released fixes for phpAfterShell, a critical vulnerability in the language’s default file-based session handler. Tracked as CVE-2026-126714, the issue has a CVSS 4.0 score of 9.2 and can help an attacker turn a disrupted session write into object deserialization and, with an additional suitable weakness, server-side code execution.

Depthfirst discovered and reported the flaw. Fixed versions are PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13 and PHP 8.6.0. The October 21 releases that addressed two PHP2Shell flaws did not include this correction, so servers updated at that time remain affected until they install the newly released versions. PHP maintainers and Depthfirst have not reported exploitation of phpAfterShell in attacks.

How an interrupted write changes a session file

The defect concerns the files session handler, which PHP uses by default. A session file contains named values and serialized data, with length fields defining where strings end. It does not contain a marker showing that a write completed. PHP locks the file while writing, but a lock cannot reverse a write that ends partway through.

If a worker process dies during that operation, the file can retain the beginning of new session data and the tail of old data. By controlling length values in the new data, an attacker may cause content embedded in the old data to be interpreted as a separate record, including a serialized object. A subsequent request that invokes session_start() can load that record and instantiate the object.

Depthfirst tested a route involving PHP upload progress. When enabled, a multipart upload carrying the relevant field writes progress information to the session before application code runs. An application does not need to offer a dedicated upload page; any page that opens the session later can be relevant. Whether authentication is required depends on the application’s session exposure.

Code execution needs another component

Creating an object from mixed session data is not automatically code execution. The researchers state that execution requires a suitable gadget chain in the application, or another weakness. Their public proof of the session-file state uses the harmless built-in stdClass object. Their own code-execution chain instead relied on a separate memory-corruption bug in a PHP built-in class, whose details are being withheld for coordinated disclosure.

The maintainers say a hard memory-limit failure in another thread of a threaded PHP build is one possible way to terminate a process mid-write. In Depthfirst’s Linux testing, an execution timeout occurred after the write finished, so the team used an out-of-memory kill. The planted object appeared on the 11th attempt in a fresh run; that result measured reaching the required file state, not the probability of successful code execution.

The same condition could also alter ordinary session values before an application checks them, including a logged-in identity, permissions or a CSRF token. That makes the issue relevant beyond the code-execution scenario.

Update, redeploy and validate the active runtime

Organizations using PHP 8.1 or older should move to a supported branch. PHP’s end-of-life mitigation branches for 7.4, 8.0 and 8.1 are not affected, but Depthfirst says older unpatched builds of those versions are. Teams should install the fixed release for their branch, rebuild container images, redeploy workloads and confirm the PHP binary handling web requests contains the fix.

Linux distribution packages can carry the correction without changing the visible PHP version number, so version checks alone may not be conclusive. The fixed releases empty a session file before every write and stop the write if that step fails. An interrupted write may still lose session data, but it should no longer preserve old content that can be reused by an attacker.

The releases also disable upload progress by default. Where an immediate update is impossible and upload progress is unused, setting session.upload_progress.enabled = 0 and restarting PHP workers closes the tested upload path. It is not a complete fix because applications may store attacker-controlled data in sessions through other routes. Session stores such as Redis or databases are outside this particular files-handler defect, although their behavior during interrupted updates requires separate assessment. The practical priority is to patch the web-serving PHP runtime and verify session-handling controls across deployed applications.

#phpsecurity#websecurity#vulnerability#sessionsecurity
Open analytics
On the site 6 views
min read 5 19.11.2026
Instagram

PHP Releases Fixes for Critical phpAfterShell Session Storage Flaw

Open the post on Instagram ↗