CVE-2026–126714: Critical PHP Session Vulnerability Could Allow Remote Code Execution Without…
PHP's default file-based session handler could leave a session file containing a mix of old and new serialized data if a write is interrupted, and PHP might then interpret attacker-influenced bytes as serialized objects. If the application has a suitable gadget chain, this could lead to remote code execution with the PHP worker's privileges.
Published on mohammadasifdevops.medium.com
PHP
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
PHP's built-in session mechanism lets a web application remember state between HTTP requests: login status, user ID, cart contents, preferences and other temporary data. When an application calls session_start();, PHP loads the session associated with the user's session ID. By default PHP uses the files session handler, which stores session information in files on the server, commonly under /var/lib/php/sessions or another configured session directory. When session data changes, PHP writes the updated information back to the session file.
The vulnerability described here, CVE-2026-126714, sits in that write path. It affects the ext-session component and specifically the default files save handler. The PHP project published a critical security advisory on November 19, 2026 under the title Partially overwritten session files can lead to remote code execution. The issue involves interrupted session-file writes, inconsistent serialised data and PHP's object deserialisation process. Under suitable conditions, an attacker who can influence session contents may be able to trigger remote code execution in the context of the PHP worker.
The advisory assigns a CVSS 4.0 score of 9.2 (Critical).

Key details as published:
| Field | Value |
|---|---|
| CVE | CVE-2026-126714 |
| Component | PHP ext-session |
| Vulnerability type | Race condition / unsafe deserialisation |
| Severity | Critical |
| CVSS | 9.2 (CVSS 4.0) |
| Attack vector | Network |
| Authentication | No privileges required in the CVSS assessment |
| User interaction | Not required in the CVSS assessment |
| Disclosure date | November 19, 2026 |
Setup
The advisory concerns default installations rather than a specific application. The preconditions it sets out are that the attacker must be able to influence session contents, the session-file write must be interrupted at a useful point, and the application must contain a suitable deserialisation gadget chain. The CVSS assessment does not mean that every PHP installation is automatically exploitable.
No specific target application, account, role or tooling is described in the advisory. The affected code has existed since PHP 4.1.0, so older, unsupported branches are not safe merely because they fall outside the maintained release lines.
Finding it
The problem is in PHP's internal ps_files_write() function. When PHP updates an existing session, the vulnerable implementation writes the new serialised session data into the existing file without first clearing the old contents. If the write operation is interrupted after only part of the new data has been written, the file can contain:
- A beginning section from the new session.
- A remaining section from the previous session.
In other words, the resulting file is a combination of two different serialised sessions. That is not necessarily a valid session representation, but an attacker may be able to influence the contents so that PHP interprets part of the combined data as serialised objects. When PHP subsequently reads the session, those objects may be instantiated, and if suitable application-level gadget chains exist, their deserialisation behaviour can trigger unintended operations and potentially execute attacker-controlled code.
Exploitation
The attack requires more than simply sending an ordinary HTTP request. One possible way to influence session contents is through PHP's session upload-progress functionality. A simplified sequence looks like this.
Step 1: Attacker influences session data
The attacker sends specially crafted multipart upload requests. PHP's session upload-progress functionality can allow data from the upload to be written into session storage.
Step 2: Session-file write is interrupted
The attacker must also cause the replacement session-file write to stop at a useful point. The vulnerability allows the resulting file to retain part of the old session data after the new data has been written.
Step 3: A mixed session file is created
The file now contains a combination of old and new serialised data. Carefully arranged data can cause bytes that previously represented an ordinary string to be interpreted as serialised object data.
Step 4: PHP reads the manipulated session
When the application subsequently opens the session using session_start() or another session-reading operation, PHP processes the manipulated serialised data.
Step 5: Object deserialisation is triggered
Attacker-controlled objects may be instantiated. If the application contains a suitable object gadget chain, the resulting behaviour can lead to remote code execution. The executed code runs with the privileges of the affected PHP worker.
What is an object gadget chain?
An object gadget chain is a sequence of existing application or library methods that can be triggered during object deserialisation. Some PHP applications and frameworks contain classes with methods such as __wakeup() or __destruct() that execute when objects are restored or destroyed. An attacker may be able to arrange serialised objects so that these methods trigger a sequence of unintended operations. A suitable gadget chain can turn unsafe deserialisation into a serious security issue, including remote code execution.
The advisory makes clear that successful exploitation requires attacker influence over session data, a useful interruption of the write operation and a suitable deserialisation gadget chain in the application.
Root cause
The mistake is in the write path of the default file-based session handler. Updating an existing session writes the new serialised data into the existing file without first clearing the old contents, so an interrupted write leaves a file that mixes a beginning section from the new session with a remaining section from the previous session. When PHP later reads that file, it may interpret attacker-controlled data as serialised PHP objects, and deserialisation of those objects can reach application gadget chains.
The affected code has existed since PHP 4.1.0. Because the files handler is the default, administrators may be running the vulnerable implementation without explicitly configuring it.
Impact
Successful exploitation can allow an attacker to execute code with the permissions of the PHP worker. Depending on the worker's privileges and application configuration, this could allow an attacker to:
- Read application files accessible to the PHP process.
- Modify application data.
- Access database credentials stored in application configuration.
- Interact with connected services.
- Execute unauthorized commands under the PHP worker's account.
- Disrupt application availability.
The actual impact depends on the permissions assigned to the PHP worker and the application's architecture. The advisory's hedges apply throughout: attacker influence over session data, a useful interruption of the write and a suitable gadget chain are all required.
Fix
The PHP developers corrected the way the built-in file-based session handler writes updated session data. The fix changes the process:
- PHP first truncates the existing session file to zero bytes.
- It then writes the replacement session data.
- If truncation fails, the write operation is aborted.
This prevents old session data from remaining at the end of a partially overwritten file. An interrupted write may still result in lost session data, but the old suffix required for this attack can no longer remain.
The fix is included in PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13 and PHP 8.6.0.
Affected and patched branches
The official PHP security advisory identifies the affected branches:

Administrators using older, unsupported PHP versions should not assume they are safe simply because they are outside the maintained release branches. They should upgrade to a supported PHP release or obtain an appropriate vendor security fix.
Recommended actions
- Upgrade PHP to the fixed version corresponding to the branch in use: PHP 8.2 to 8.2.36 or later, PHP 8.3 to 8.3.37 or later, PHP 8.4 to 8.4.28 or later, PHP 8.5 to 8.5.13 or later, PHP 8.6 to 8.6.0 or later. Check the PHP version actually used by the web application, not just the system's default CLI version.
- Disable session upload progress if not required, as a temporary mitigation:
session.upload_progress.enabled = Off
This removes one potential route for an attacker to influence session data, but it does not completely resolve the vulnerability because applications may independently store attacker-controlled data in sessions.
- Review session storage configuration. Consider alternative session storage mechanisms such as Redis or database-backed sessions. These implementations are not affected by this specific file-write defect, although they must still be configured and secured properly.
- Limit untrusted data in sessions. Avoid storing large amounts of user-controlled data in session variables, and review upload functionality and application code that writes externally supplied values into PHP sessions.
- Review application permissions. Ensure PHP workers operate with the minimum privileges required, and restrict access to sensitive configuration files, application directories and other server resources.
Why a WAF is not a complete solution
A web application firewall may help protect against many common web attacks, but this vulnerability is difficult to identify reliably through request filtering alone. The manipulated session data can resemble normal serialised data, and the actual condition that makes the attack possible is an interrupted write operation occurring on the server. A WAF rule cannot reliably replace the PHP security update. The recommended solution is to install the patched PHP release.
- Session upload progress as a write primitive. On a PHP instance using the
fileshandler withsession.upload_progress.enabledon, send multipart uploads whose progress data lands in the session and inspect the resulting session file. A positive result is attacker-influenced bytes appearing in the session file in a position that survives a subsequent write. - Interrupted writes. Attempt to stop a session-file replacement partway through and inspect the file afterwards. A positive result is a file whose beginning comes from the new session and whose tail still holds the previous session's serialised data.
- String-to-object reinterpretation. Arrange session data so that bytes previously stored as an ordinary string are read back as serialised object data. A positive result is PHP instantiating an object from data the attacker placed in the session.
- Gadget chain reachability. In the target application or its libraries, look for classes with
__wakeup()or__destruct()methods that perform useful operations. A positive result is a chain reachable from a deserialised object that produces an observable effect under the PHP worker's account. - Alternative session backends. Where Redis or database-backed sessions are used, confirm the file-write defect does not apply, then review the backend's own configuration and access controls.
Final thoughts
CVE-2026-126714 highlights how a seemingly ordinary file-writing operation can become a critical security weakness. The issue is not simply about storing session information; it is about what happens when a write operation is interrupted and the application later trusts the resulting serialised data. Because PHP's file-based session handler is the default, administrators should identify affected runtimes and prioritise patching. For production environments, upgrading PHP is the recommended remediation. Disabling session upload progress and reviewing session-storage architecture are useful additional security measures, but they should not replace the official fix.
Official references
- PHP GitHub Security Advisory: https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp
- PHP Security Releases, November 19, 2026: https://www.php.net/archive/2026.php
- PHP 8.6.0 release changelog: https://www.php.net/ChangeLog-8.php#8.6.0
- CVE reference: https://www.cve.org/CVERecord?id=CVE-2026-126714
What happened, in plain words
On 19 November 2026 the PHP project published a critical security advisory for a bug tracked as CVE-2026-126714, titled Partially overwritten session files can lead to remote code execution. PHP is a programming language used to build a very large share of the websites on the internet, from WordPress and Laravel applications to enterprise helpdesk platforms and custom web services. The bug sits in the part of PHP that remembers who a visitor is between page loads, and in the worst case it can let an attacker run their own code on the server.
The advisory gives it a CVSS 4.0 score of 9.2, which is in the Critical band. CVSS is a standard scoring system for how serious a security flaw is; 9.2 out of 10 means it should be taken seriously and patched quickly.
The bug is not a magic key that opens every PHP server. It needs a few things to line up: the server must use PHP's default way of storing sessions in files, the attacker must be able to get some data of their choosing into a session, a file write must be interrupted at the right moment, and the application must contain a particular kind of code that the attacker can abuse. The advisory is explicit that the score does not mean every PHP installation is automatically exploitable.

Here are the key details as the advisory published them:
| Field | Value |
|---|---|
| CVE | CVE-2026-126714 |
| Component | PHP ext-session |
| Vulnerability type | Race condition / unsafe deserialisation |
| Severity | Critical |
| CVSS | 9.2 (CVSS 4.0) |
| Attack vector | Network |
| Authentication | No privileges required in the CVSS assessment |
| User interaction | Not required in the CVSS assessment |
| Disclosure date | November 19, 2026 |
A few of those words need unpacking before anything else makes sense.
- CVE stands for Common Vulnerabilities and Exposures. It is a public catalogue number for a known security flaw, a bit like a registration plate for a bug, so that everyone talking about it means the same thing.
- Component is the part of the software where the bug lives. Here it is
ext-session, the session extension of PHP. - Attack vector: Network means the attacker reaches the bug over the network, by sending requests to the web server, rather than needing to sit at the keyboard of the machine.
- Authentication: No privileges required means, in the scoring, the attacker does not need a valid account or password to start the attack.
- User interaction: Not required means the attacker does not need to trick a logged-in person into clicking something.
- Race condition means a bug that only appears when two things happen at almost the same time and the order or timing goes wrong, like two people grabbing for the same door handle at once.
- Deserialisation is the process of turning stored data back into live objects inside a program. It is explained properly further down.
Setup
The advisory is about default installations of PHP, not about one particular website or product. So there is no target application, account, role or tooling to describe here. What matters is whether a server meets the conditions the advisory sets out:
- The
filessession handler must be in use. This is the default, so many servers meet it without anyone choosing it. - The attacker must be able to influence what goes into a session.
- The session-file write must be interrupted at a useful point.
- The application must contain a suitable deserialisation gadget chain, which is explained later.
The affected code has existed since PHP 4.1.0. That is a very old version, which means older, unsupported PHP branches are not safe just because they are no longer maintained. If a server runs an old PHP that no longer receives updates, it still contains the flawed code.
Finding it
What a session is, from zero
When you browse a website, your browser and the server have a short conversation. The web was built so that each request is independent: the server does not automatically remember that the request for this page came from the same person who asked for the previous page. But a shop needs to remember your cart, and a login page needs to remember that you signed in.
A session is the server's memory of one visitor across several requests. The server gives your browser a label, called a session ID, usually kept in a cookie (a small piece of text your browser stores for a site and sends back with every request). When you come back, you present the label, and the server looks up the matching memory.
In PHP, the application starts that memory with a call:
session_start();
That single line tells PHP: find the session belonging to this visitor's session ID and load it. By default PHP stores each session in a file on the server's disk, usually in a directory such as /var/lib/php/sessions or another directory configured by the administrator. This default is called the files session handler. When the session data changes, PHP writes the updated information back into that file.
A useful comparison: think of the session file as a notebook page with the visitor's name at the top. Every time something changes, PHP rubs out the page and writes the new version. The bug is in how that rubbing out and rewriting is done.
Where the bug is
The problem is in an internal PHP function called ps_files_write(). When PHP updates an existing session, the vulnerable version writes the new data into the existing file without first clearing the old contents. If the write is interrupted after only part of the new data has been written, the file can end up containing:
- A beginning section from the new session.
- A remaining section from the previous session.
In other words, the file becomes a mixture of two different sessions. That mixture is not necessarily a valid session on its own, but an attacker may be able to arrange the contents so that PHP reads part of the combined data as serialised objects. When PHP later reads the session, those objects may be created inside the program, and if the application has suitable gadget chains, that can trigger unintended operations and potentially run attacker-controlled code.
To go back to the notebook comparison: imagine the page is not wiped clean but only partly overwritten. The top half is the new text, the bottom half is the old text still showing through. If the old text was carefully chosen, the reader can be made to read the two halves together as one instruction.
Exploitation
The attack is not a single ordinary request. One possible way to get attacker-chosen data into a session is PHP's session upload-progress feature. A simplified sequence of five steps looks like this.
Step 1: Attacker influences session data
The attacker sends specially crafted multipart upload requests. A multipart request is the format a browser uses when you submit a form that includes a file, such as a profile picture: the request body is split into parts, one per field. PHP's session upload-progress feature can allow data from the upload to be written into session storage. That is the foothold: the attacker gets to place some bytes of their choosing into the session.
Step 2: Session-file write is interrupted
The attacker must also cause the replacement session-file write to stop at a useful point. The vulnerability allows the resulting file to keep part of the old session data after the new data has been written. This is the race condition: the attacker needs the timing to go wrong in a specific way.
Step 3: A mixed session file is created
The file now holds a combination of old and new serialised data. Serialised means turned into a text format that can be stored and later rebuilt into the original data. Carefully arranged data can make bytes that used to be an ordinary string be read back as serialised object data instead.
Step 4: PHP reads the manipulated session
When the application next opens the session, using session_start() or another session-reading operation, PHP processes the manipulated serialised data. This is the moment the trap is sprung: the application is simply doing its normal job of loading the visitor's session.
Step 5: Object deserialisation is triggered
Attacker-controlled objects may be created inside the program. If the application contains a suitable object gadget chain, the resulting behaviour can lead to remote code execution. Remote code execution, usually shortened to RCE, means the attacker can make the server run commands or code of their choosing. The executed code runs with the privileges of the affected PHP worker. A PHP worker is one of the processes that handles incoming requests; its privileges decide what the attacker's code is allowed to touch.
What is an object gadget chain?
An object gadget chain is a sequence of existing application or library methods that can be triggered during object deserialisation. Some PHP applications and frameworks contain classes with methods such as __wakeup() or __destruct() that run when objects are restored or destroyed. An attacker may be able to arrange serialised objects so that these methods trigger a chain of unintended operations.
A comparison: imagine a row of dominoes already standing in the application's code. The attacker does not build the dominoes; they only need to knock over the first one, and the rest fall by themselves. A suitable gadget chain turns unsafe deserialisation into a serious security issue, including remote code execution.
The advisory makes clear that successful exploitation requires all three of: attacker influence over session data, a useful interruption of the write operation, and a suitable deserialisation gadget chain in the application. The CVSS score does not mean that every PHP installation is automatically exploitable.
Root cause
The mistake is in the write path of the default file-based session handler. Updating an existing session writes the new serialised data into the existing file without first clearing the old contents. An interrupted write therefore leaves a file that mixes a beginning section from the new session with a remaining section from the previous session. When PHP later reads that file, it may interpret attacker-controlled data as serialised PHP objects, and deserializing those objects can reach application gadget chains.
Because the files handler is the default, administrators may be running the vulnerable implementation without ever having configured it deliberately. That is why the default configuration matters so much.
Impact
Successful exploitation can allow an attacker to execute code with the permissions of the PHP worker. Depending on the worker's privileges and the application's configuration, this could allow an attacker to:
- Read application files accessible to the PHP process.
- Modify application data.
- Access database credentials stored in application configuration.
- Interact with connected services.
- Execute unauthorized commands under the PHP worker's account.
- Disrupt application availability.
The actual impact depends on the permissions assigned to the PHP worker and the application's architecture. The advisory's conditions apply throughout: attacker influence over session data, a useful interruption of the write, and a suitable gadget chain are all required.
Fix
The PHP developers corrected the way the built-in file-based session handler writes updated session data. The fix changes the process:
- PHP first truncates the existing session file to zero bytes. Truncate means cut the file down to nothing, so no old text can survive underneath.
- It then writes the replacement session data.
- If truncation fails, the write operation is aborted.
This prevents old session data from remaining at the end of a partially overwritten file. An interrupted write may still result in lost session data, but the old suffix required for this attack can no longer remain.
The fix is included in PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13 and PHP 8.6.0.
Affected and patched branches
The official PHP security advisory identifies the affected branches:

Administrators using older, unsupported PHP versions should not assume they are safe simply because they are outside the maintained release branches. They should upgrade to a supported PHP release or obtain an appropriate vendor security fix.
Recommended actions
- Upgrade PHP to the fixed version for the branch in use: PHP 8.2 to 8.2.36 or later, PHP 8.3 to 8.3.37 or later, PHP 8.4 to 8.4.28 or later, PHP 8.5 to 8.5.13 or later, PHP 8.6 to 8.6.0 or later. Check the PHP version actually used by the web application, not just the system's default command-line version. A server can have more than one PHP installed, and the one answering web requests is the one that matters.
- Disable session upload progress if not required, as a temporary mitigation:
session.upload_progress.enabled = Off
This is a line from PHP's configuration file. session.upload_progress.enabled is the setting that turns the upload-progress feature on or off, and Off switches it off. This removes one potential route for an attacker to influence session data, but it does not completely resolve the vulnerability, because applications may independently store attacker-controlled data in sessions.
3. Review session storage configuration. Consider alternative session storage mechanisms such as Redis or database-backed sessions. Redis is a fast in-memory data store often used to hold sessions, and a database-backed session keeps session data in a database table instead of a file. These implementations are not affected by this specific file-write defect, although they must still be configured and secured properly.
4. Limit untrusted data in sessions. Avoid storing large amounts of user-controlled data in session variables, and review upload functionality and application code that writes externally supplied values into PHP sessions.
5. Review application permissions. Ensure PHP workers operate with the minimum privileges required, and restrict access to sensitive configuration files, application directories and other server resources. Least privilege is the principle of giving a process only the access it genuinely needs, so that if it is abused the damage is smaller.
Why a WAF is not a complete solution
A web application firewall, or WAF, is a filter placed in front of a website that inspects incoming requests and blocks ones that look malicious. It may help against many common web attacks, but this vulnerability is difficult to identify reliably through request filtering alone. The manipulated session data can resemble normal serialised data, and the actual condition that makes the attack possible is an interrupted write operation happening on the server. A WAF rule cannot reliably replace the PHP security update. The recommended solution is to install the patched PHP release.
Variants to test
- Session upload progress as a write primitive. On a PHP instance using the
fileshandler withsession.upload_progress.enabledon, send multipart uploads whose progress data lands in the session and inspect the resulting session file. A positive result is attacker-influenced bytes appearing in the session file in a position that survives a subsequent write. A write primitive simply means a way to get your own data written somewhere it should not be. - Interrupted writes. Attempt to stop a session-file replacement partway through and inspect the file afterwards. A positive result is a file whose beginning comes from the new session and whose tail still holds the previous session's serialised data.
- String-to-object reinterpretation. Arrange session data so that bytes previously stored as an ordinary string are read back as serialised object data. A positive result is PHP creating an object from data the attacker placed in the session.
- Gadget chain reachability. In the target application or its libraries, look for classes with
__wakeup()or__destruct()methods that perform useful operations. A positive result is a chain reachable from a deserialised object that produces an observable effect under the PHP worker's account. - Alternative session backends. Where Redis or database-backed sessions are used, confirm the file-write defect does not apply, then review the backend's own configuration and access controls.
Final thoughts
CVE-2026-126714 shows how a seemingly ordinary file-writing operation can become a critical security weakness. The issue is not simply about storing session information; it is about what happens when a write operation is interrupted and the application later trusts the resulting serialised data. Because PHP's file-based session handler is the default, administrators should identify affected runtimes and prioritise patching. For production environments, upgrading PHP is the recommended remediation. Disabling session upload progress and reviewing session-storage architecture are useful additional measures, but they should not replace the official fix.
Official references
- PHP GitHub Security Advisory: https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp
- PHP Security Releases, November 19, 2026: https://www.php.net/archive/2026.php
- PHP 8.6.0 release changelog: https://www.php.net/ChangeLog-8.php#8.6.0
- CVE reference: https://www.cve.org/CVERecord?id=CVE-2026-126714
Glossary
- CVE: Common Vulnerabilities and Exposures, a public catalogue number given to a known security flaw so everyone can refer to the same bug.
- CVSS: Common Vulnerability Scoring System, a standard 0 to 10 scale for how serious a security flaw is; 9.2 is Critical.
- PHP: A programming language widely used to build websites and web applications.
- ext-session: The PHP extension that provides sessions; the component affected here.
- Session: The server's memory of one visitor across several requests, such as login status or cart contents.
- Session ID: The label the server gives a browser so it can find that visitor's session again.
- Cookie: A small piece of text a website asks your browser to store and send back with later requests.
- Session handler: The mechanism PHP uses to store and load sessions; the default is
files. filessession handler: PHP's default session storage, which keeps each session in a file on the server's disk.session_start(): The PHP call that loads the session belonging to the current visitor.ps_files_write(): The internal PHP function that writes session data to the session file; the bug is in this write path.- Race condition: A bug that appears only when the timing of two operations goes wrong, for example a write being interrupted.
- Serialisation: Turning live data into a text format that can be stored and later rebuilt.
- Deserialisation: Turning stored serialised data back into live objects inside a program.
- Unsafe deserialisation: Deserializing data an attacker can influence, so that the attacker's data becomes objects in the program.
- Object: A bundle of data and behaviour inside a program, created from a class.
- Class: A template in code that describes what an object holds and what it can do.
- Method: A function belonging to a class or object.
__wakeup()/__destruct(): PHP methods that run automatically when an object is restored from serialised data or destroyed.- Object gadget chain: A sequence of existing application or library methods that can be triggered during deserialisation to produce an unintended effect.
- Remote code execution (RCE): A flaw that lets an attacker make the server run code or commands of their choosing.
- PHP worker: A server process that handles incoming PHP requests; its privileges limit what exploited code can do.
- Multipart request: The request format used when a form includes a file upload, with the body split into parts.
- Session upload progress: A PHP feature that records the progress of file uploads in the session.
- Write primitive: Any way for an attacker to get their own data written to a place it should not be.
- Truncate: Cut a file down to zero bytes, removing all previous contents.
- Redis: A fast in-memory data store often used to hold session data instead of files.
- Database-backed sessions: Storing session data in a database table rather than in files.
- Least privilege: Giving a process only the access it genuinely needs, to limit damage if it is abused.
- WAF: Web application firewall, a filter in front of a website that inspects requests and blocks ones that look malicious.
- Attack vector: How an attacker reaches the flaw, for example over the network.
- Authentication: Proving who you are, usually with an account and password; the CVSS assessment says no privileges are required to start this attack.
- User interaction: Whether the attacker needs a real person to do something, such as click a link; not required here.
- Advisory: The official notice a software project publishes about a security flaw and its fix.
- Branch: A maintained line of releases of a software project, such as PHP 8.2 or 8.3.