CVE-2026-126714 (phpAfterShell): deserialization through a partially rewritten session file in PHP
phpAfterShell (CVE-2026-126714): PHP deserializes a half-written session file. A follow-up to php2shell, fixed in 8.5.13, 8.4.28, 8.3.37 and 8.2.36.

Context
PHP published seven critical advisories on 19 November 2026. Only one has a name: phpAfterShell, for CVE-2026-126714. The name comes from Depthfirst, the company that found the flaw while studying the fix for php2shell.
The defect lies in file-based session storage, which PHP uses by default. If the process dies while rewriting a session file, that file can keep the start of the new data and the end of the old. PHP then reads it back without suspicion and deserializes it.
An attacker who controls both halves can thereby make values or objects appear in the session that the application never wrote.
PHP's advisory and Depthfirst's publication do not measure the risk the same way. For PHP, code execution requires an exploitable object chain in the application. Depthfirst says it obtained it without that condition, through a second flaw it has not published. We present both versions without being able to decide between them.
We did not reproduce the flaw. This article relies on PHP's advisory, on Depthfirst's publication and on the three commits in PHP's repository that touch session writing.
Technical summary
| Item | Value |
|---|---|
| Identifiers | CVE-2026-126714, "phpAfterShell", advisory GHSA-fm2m-fjf5-v3cp |
| Component | File-based session handler, function ps_files_write() (ext/session/mod_files.c) |
| Class | CWE-367, time-of-check time-of-use; CWE-662, improper synchronization |
| Severity | Critical for PHP, CVSS 4.0 of 9.2. Red Hat: "Critical", CVSS 3.1 of 8.1 |
| CVSS 4.0 vector | AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| Affected versions | PHP before 8.2.36, 8.3.37, 8.4.28 and 8.5.13; code present since PHP 4.1.0 |
| Fixes | PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13 (19 November 2026); PHP 8.6.0 includes the fix |
| Conditions | Sessions stored in files, session content the attacker can influence, interrupted write |
| Discovery | Depthfirst (publication signed Yuhang Wu); PHP's advisory credits GitHub account zplinn |
| Exploitation | None reported as of 20 November; not in the KEV catalog (18 November edition) |
PHP uses low attack complexity, Red Hat high complexity. The difference concerns the interruption of the write, which Red Hat counts as a difficulty. Depthfirst manages it in about ten attempts, so PHP's score seems to us the closer to reality.
CISA rates exploitation as "none" and the flaw as automatable.
How we triage this kind of advisory is described in our article on vulnerability prioritization.
Affected systems
Three conditions must be met.
Sessions stored in files
This is the default setting (session.save_handler = files) and that of most installations.
Sessions held in Redis, Memcached or a database do not go through the code at fault. The advisory still recommends checking how those stores behave when an update is interrupted.
Session content the attacker can influence
The attacker has to get data of their choosing written twice into the same session. There are two ways.
The first is upload progress tracking. When this feature is on, a multipart form upload makes PHP write to the session before the application's code runs. The application needs neither an upload form nor to open a session on the targeted page. No account is required.
The feature was on by default until 19 November. Many servers had already turned it off, since that was the measure recommended against php2shell from 21 October.
The second way does not depend on that setting. An application that stores long user-supplied strings in the session offers the same grip. That generally requires an account, or a session opened by the application.
An interrupted write
The attack assumes the process dies during the file rewrite.
PHP's advisory cites one case: in a threaded build, a memory overrun in one thread can terminate the process while another is writing a session. Read alone, it suggests that PHP-FPM and prefork Apache are not affected.
Yet Depthfirst's tests run on Apache. There the interruption comes from the kernel, which kills a worker when the container exceeds its memory limit. PHP in a memory-limited container is the most common deployment today.
We therefore treat every installation as exposed, with or without threads. Nothing in the fix restricts the defect to threaded builds.
How it works
This section stays at the advisory's level of detail. Depthfirst describes its triggering method precisely, and we do not repeat it.
The session file
A session file is a sequence of records, each made of a name and a serialized value. Every string in it is preceded by its length, which tells PHP where to resume reading.
The file contains neither a total size nor an end marker. PHP therefore cannot tell a complete file from one made of two pieces, as long as the whole remains parsable.
The write
To update a session, PHP writes the new data over the old, in the same file. Before the fix, it only emptied the file beforehand if the new data was shorter.
PHP locks the file during the operation. If the process disappears halfway, the kernel releases the lock and the file stays as it is, with the start of the new data followed by the end of the old.
The mix
Both contents are valid, and their combination can be valid too. By choosing the lengths announced in the new start, the attacker gets text that sat inside a long string of the old content read as a separate record.
That text can be a simple value or a serialized object. The next request that calls session_start() loads the file, and PHP creates whatever it finds there.
From an interrupted write to an object in the session
- 1
First write
the attacker has the session record content that hides, inside a long string, the bytes they want to activate.
- 2
Second write
they have the same session rewritten with content whose start shifts the parsing.
- 3
Interruption
the worker dies during that rewrite. The file keeps the start of the second content and the end of the first.
- 4
Read
an ordinary request opens the session, and PHP deserializes the mix.
Result
the session contains the values or objects chosen by the attacker, before any check by the application.
The link with php2shell
One of the php2shell flaws already went through upload progress: objects became active while PHP was recording that progress. The 21 October fix restricted which classes can be loaded at that moment.
That fix did not touch the file write. The object's bytes still reach the disk, and they become active later, when a normal request opens the session and the restriction no longer applies. Depthfirst puts it this way: the original exploit stopped working, but the underlying problem was still there.
For an operator, this confirms a habit worth forming. A fix released in an emergency is often followed by a second, and it is better to plan the window for the next one as soon as the first lands.
An August commit, since reverted
The file's history contains a third commit, which the advisories do not mention.
On 24 August 2026, a developer moved the truncation of the file to after the write. With the old order, a failed write could lose the whole session. That change only reached the November release candidates.
It opened a second window: the old content stayed in the file for the whole write, and it was enough for the process to die just before the truncation. Depthfirst describes this variant.
The security fix dates from 11 November and is three lines long. PHP now empties the file before every write and gives up if that operation fails. The August commit was reverted four days later, as incompatible with this fix.
The fix therefore has a cost, which the advisory acknowledges: an interrupted write can now lose a session.
The consequences
The first consequence requires no object. The mix can replace ordinary session values: the identifier of the logged-in user, their permissions, a CSRF token, the state of a password reset. The application reads those values before its access checks.
The sources say little about it. For a business application it is nonetheless the most direct scenario, since it depends on nothing else.
The second is the advisory's. An object created when the session is opened runs the methods its class provides. If the application or its dependencies contain an exploitable class chain, the attacker obtains code execution.
The third is Depthfirst's. The company says it built a chain that uses only PHP's native classes, thanks to a memory corruption in one of them. It shows a demonstration and reserves the details for coordinated disclosure.
Depthfirst does not say whether that second flaw is fixed by the 19 November releases. We have no way of checking. In any case, the update removes its known entry point.
Available fixes
Distributions backport the fix without changing the upstream version number. The package version has to be compared with the one in the distribution's advisory.
| Distribution | Status recorded on 20 November 2026 |
|---|---|
| PHP (sources) | 8.5.13, 8.4.28, 8.3.37, 8.2.36 |
| Debian 13 (trixie) | Fixed by php8.4 8.4.28-1~deb13u1 (DSA-6641-1) |
| Debian 12 (bookworm) | Fixed by php8.2 8.2.36-1~deb12u1 (DLA-4916-1) |
| Debian forky, sid | Vulnerable (8.4.27-1) |
| Ubuntu 22.04 to 26.10 | Awaiting triage, no fixed package; priority "medium" |
| Ubuntu 16.04, 18.04 | Fixed under Ubuntu Pro (php7.0 and php7.2) |
| Red Hat (RHEL 7 to 10) | No erratum; severity "Critical" |
php Docker images | Fixed tags published late in the afternoon of 19 November |
For PHP 7.4, 8.0 and 8.1, PHP had published backports of the php2shell fix in October. According to Depthfirst, those backports cut upload progress at the point where phpAfterShell comes in. The accountless path is therefore closed there, for installations that applied them.
The second path, that of data the application itself stores in the session, is not covered. We found no new upstream backport for these branches.
Checking a machine
Session configuration is read from the PHP that serves the web. The command-line one often loads a different php.ini.
php-fpm8.4 -i 2>/dev/null | grep -E '^session\.(save_handler|save_path|upload_progress\.enabled|serialize_handler)'session.save_handler => files puts the server in scope. session.upload_progress.enabled => On means the accountless path is open.
An explicit setting in a php.ini, a PHP-FPM pool, a virtual host or a .user.ini overrides the default, including that of the fixed releases. So it has to be looked for:
grep -R -n 'upload_progress' /etc/php /etc/apache2 /etc/nginx /var/www 2>/dev/nullThat leaves the package version:
dpkg -l 'php*' 2>/dev/null | grep -E 'fpm|libapache2-mod-php'None of this can be read from outside. Settling the matter remotely would mean attempting the attack, and therefore crashing workers and corrupting sessions. We offer no remote test for this flaw.
Remediation
- Update PHP to 8.5.13, 8.4.28, 8.3.37 or 8.2.36, or install the distribution's fixed package.
- Restart PHP-FPM or Apache, then check the version that serves the web.
- Purge existing sessions.
- Rebuild and redeploy container images based on an earlier version.
- Check that no setting turns upload progress back on where it is not needed.
Purging sessions appears in no advisory. We recommend it because the fix changes how a session file is written, and not how it is read. A mixed file dropped before the update would still be deserialized afterwards.
Deleting the files in the session directory logs every user out. That is a limited inconvenience.
Until the update
The advisory gives the same interim measure as in October:
session.upload_progress.enabled = 0It is set in the server configuration, and not through ini_set(), then requires restarting the workers. It closes the accountless path.
It does not protect an application that stores user data in the session. The advisory therefore also recommends limiting the untrusted data kept there.
Moving sessions to Redis or a database avoids this defect. That is an architecture change, which we would not make in a hurry to gain a few days.
After the update
The fixed releases turn upload progress off by default. According to The Hacker News, which compared the sources, the release notes do not flag it.
An application that displays a progress bar through this feature will stop doing so. It will then have to be re-enabled explicitly, knowing what that reopens.
Looking for compromise
Neither PHP nor Depthfirst has published an indicator of compromise. The three signals below are deduced from the method described. We have not tested them against a real attack.
The kernel records the workers it kills for lack of memory:
journalctl -k --since '2026-10-21' | grep -E 'Out of memory|oom-kill|Killed process'Several apache2 or php-fpm workers killed in a row, on a service that had been stable, should be set against the access logs of the same moment. The method takes several attempts and so leaves several traces.
The access logs, for their part, show large and repeated form uploads to pages that do not receive files, followed by a simple request carrying the same session identifier.
The last signal is on disk. An ordinary session weighs a few kilobytes, whereas Depthfirst's tests handle sessions of several megabytes.
find /var/lib/php/sessions -name 'sess_*' -size +1M -ls 2>/dev/nullThe path to use is that of session.save_path. Some applications store a lot in the session, and a large file proves nothing by itself. It is worth opening before it is deleted.
Where there is serious doubt, we would treat the machine like any machine where code may have run with the web server's privileges. That covers searching for recent PHP files in writable directories, for unexplained processes or outbound connections, and rotating the application's secrets.
Timeline
Depthfirst states that the flaw was found by its AI models, with its researchers. The discoverers of php2shell said the same thing a month earlier.
CVE-2026-126714 timeline
Origin
December 2001
PHP 4.1.0
according to the advisory, the session file write code already has the behaviour at fault.
24 August 2026
Truncation moved
a commit unrelated to security truncates the file after the write. It will only reach the November release candidates.
Discovery
21 October 2026
php2shell fix
PHP restricts class loading during upload progress tracking, without touching the file write.
Late October 2026
Report
Depthfirst reports the flaw to PHP.
Fix
11 November 2026
Fix commit
three lines in mod_files.c. The CVE identifier is reserved the same day.
15 November 2026
August commit reverted
it is deemed incompatible with the fix.
Disclosure
19 November 2026, 14
Advisory and releases
advisory GHSA-fm2m-fjf5-v3cp, PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36. Depthfirst publishes its analysis the same day.
20 November 2026
Status at this date
Debian fixed, Ubuntu and Red Hat without packages, no attack reported, flaw absent from the KEV catalog.
The other flaws of 19 November
phpAfterShell came out with six other critical advisories.
Two of them depend on the server configuration: request smuggling in PHP-FPM and memory corruption in the timezone cache. We cover them in a joint article.
CVE-2026-115560 is close to phpAfterShell. It also goes through upload progress and also ends in a deserialization, this time through a format mismatch between two reads of the same session. The same setting closes its simplest path.
CVE-2026-129182 and CVE-2026-129481 also complete the October fix. We track the whole in the php2shell article.
Knowing where PHP runs
The servers concerned are roughly those of php2shell. Those fixed on 21 October have to be done again, and those that were not now carry both flaws.
The update itself is simple. The work is mostly in finding the forgotten PHP installations: an old brochure site, an internal tool published for a contractor, the console of an appliance that ships its own PHP and only updates with the vendor's firmware.
That list is kept current continuously, by inventorying your external attack surface.
Frequently asked questions about phpAfterShell (CVE-2026-126714)
What is phpAfterShell?
A flaw in PHP's file-based session storage, tracked as CVE-2026-126714. If a session rewrite is interrupted, the file can contain the start of the new data and the end of the old. PHP then deserializes that mix, which lets an attacker introduce values or objects of their choosing into the session.
Which PHP versions are affected?
Every version before 8.2.36, 8.3.37, 8.4.28 and 8.5.13, when sessions are stored in files. According to the advisory, the code at fault has existed since PHP 4.1.0. PHP 8.6.0 includes the fix.
I updated PHP in October against php2shell. Am I protected?
No. The 21 October releases (8.5.12, 8.4.27, 8.3.36 and 8.2.35) do not contain this fix. The 19 November ones have to be installed.
I disabled session.upload_progress in October. Is that enough?
No. That setting closes the attack path that requires no account. An application that stores user-supplied data in the session is still exposed, as PHP's advisory states.
My sessions are in Redis. Am I affected?
Not by this defect, which lies in the file-based session handler. The advisory still recommends examining how the chosen store behaves when an update is interrupted.
Does the flaw allow code execution?
According to PHP's advisory, yes, if an exploitable object chain exists in the application. Depthfirst says it got there without that condition, through a second PHP flaw it has not published. The flaw also makes it possible to replace session values such as the user's identity or permissions.
Is the flaw being exploited?
No attack has been reported as of 20 November 2026, and the flaw is not in CISA's KEV catalog. We found no public exploit code. Depthfirst's publication does, however, describe the method precisely, and CISA rates the flaw as automatable.
Should sessions be deleted after the update?
We recommend it. The fix prevents a mixed session file from being created, but it does not remove any that may have been dropped beforehand. Emptying the session directory logs users out and rules that risk out.
Sources
- php-src, advisory GHSA-fm2m-fjf5-v3cp, "Partially overwritten session files can lead to remote code execution"
- Depthfirst, "phpAfterShell: From Interrupted Session Writes to Remote Code Execution", 19 November 2026
- Depthfirst, phpAfterShell summary page
- php-src, commit e2d3cee, "Fix GHSA-fm2m-fjf5-v3cp: RCE via corrupted session file"
- php-src, commit c2b02f2, "ext/session: Truncate session file after successful write", 24 August 2026
- php-src, commit 4c5abca, revert of the previous one, 15 November 2026
- php.net, PHP 8 changelog
- CVE-2026-126714 record (cve.org)
- The Hacker News, "phpAfterShell Explained: How Hackers Could Turn a PHP Session Flaw Into Code Execution"
- Wiz, "phpAfterShell and Critical PHP RCE Vulnerabilities"
- Debian, security tracker for CVE-2026-126714
- Ubuntu, CVE-2026-126714 record
- Red Hat, CVE-2026-126714 record
- CISA, Known Exploited Vulnerabilities catalog
Let’s discuss your external exposure
Request a personalized Flawfence demo and discover your real exposure level.
