CVE-2026-126714
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
PHP is a general-purpose scripting language used mostly for web development. It runs behind web servers through server APIs such as Apache mod_php and PHP-FPM, and powers content management systems and frameworks such as WordPress, Drupal, Moodle and Laravel. PHP's default session save handler, files, stores each session as a serialized file and rewrites that file when the session changes.
A Deserialization of Untrusted Data vulnerability (CVE-2026-126714) has been identified in how the files session save handler rewrites session files, which allows an attacker who can influence the session contents and interrupt a replacement write to leave a file that mixes two serialized sessions, so that PHP deserializes attacker-controlled objects the next time the session is opened. With a suitable object gadget chain in the application, this can lead to remote code execution. The PHP project tracks this issue as GHSA-fm2m-fjf5-v3cp.
Per MITRE CWE-502: The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.
This issue affects all versions of PHP before 8.2.36, PHP 8.3 before 8.3.37, PHP 8.4 before 8.4.28 and PHP 8.5 before 8.5.13, which includes the End-of-Life release lines PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 through their final releases.
Details
Module Info
- Product: PHP
- Affected packages:
php-src(ext/session) - Affected versions: <8.2.36, >=8.3.0 <8.3.37, >=8.4.0 <8.4.28, >=8.5.0 <8.5.13
- GitHub repository: https://github.com/php/php-src
- Published packages: https://www.php.net/downloads
- Package manager: N/A
- Fixed in:
- OSS PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13
- NES for PHP
Vulnerability Info
This Critical-severity vulnerability is found in the session extension of all versions of PHP before 8.2.36, PHP 8.3 before 8.3.37, PHP 8.4 before 8.4.28 and PHP 8.5 before 8.5.13, which includes the End-of-Life release lines PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 through their final releases. The PHP project scores it 9.2 under CVSS 4.0 (CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N). The PHP project classifies it as CWE-367 and CWE-662.
When a session is updated, ps_files_write() writes the new serialized data into the existing file. It clears the old contents first only when the new data is shorter. In PHP 8.5.12, the code reads:
/* Truncate file if the amount of new data is smaller than the existing data set. */
if (ZSTR_LEN(val) < data->st_size) {
php_ignore_value(ftruncate(data->fd, 0));
}If the write stops after replacing only part of the file, the result holds a prefix of the new session followed by a suffix of the old one. The file lock keeps other session operations away during the write, but it does not make an interrupted write atomic. PHP's session decoders use the unserialization machinery to restore values, and carefully arranged old and new data can make the combined file decode differently from either original: bytes that were part of an ordinary string can become serialized object data. A later session_start(), or another operation that reads the session, then creates those objects and invokes their deserialization behavior.
Session upload progress gives a remote client one way to influence stored session data through multipart uploads, and an application that stores large user-controlled strings in a session has the same underlying problem. In thread-safe PHP builds, a hard memory limit failure in another thread can end the process while the session write is in progress, which gives an attacker a way to influence where the write stops.
Successful exploitation can execute code with the privileges of the PHP worker. It needs attacker influence over the session data, an interruption at a useful point in the write and a suitable gadget chain in the application. The issue can also corrupt session state. Other session storage back ends are not affected by this file write defect. The same conditional truncation is present in the final releases of the End-of-Life PHP 5.6 through 8.1 lines.
The fix truncates the session file before every write and aborts the write if truncation fails. An interrupted write can still lose session data, but it can no longer keep the old suffix:
if (ftruncate(data->fd, 0) != 0) {
php_error_docref(NULL, E_WARNING, "ftruncate() failed: %s (%d)", strerror(errno), errno);
return FAILURE;
}Mitigation
The PHP project publishes security fixes only for its supported release lines. PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 are End-of-Life and will not receive any public updates to address this issue.
Until an upgrade is possible, set session.upload_progress.enabled=0 administratively if the feature is not needed, and limit the amount of untrusted data stored in sessions. Disabling upload progress removes that input path but does not protect applications that store attacker-controlled session data themselves. A session storage back end that replaces records atomically avoids this defect.
Users of the affected components should apply one of the following mitigations:
- Upgrade to PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13, or later.
- Leverage a commercial support partner like HeroDevs (NES for PHP) for post-EOL security support.
Credits
- zplinn (finder)
- Ilija Tovilo (remediation)