VulnWatch by ve1ve2
critical 9.2 EPSS 13.1%

GHSA-fm2m-fjf5-v3cp / CVE-2026-126714: Partially overwritten session files can lead to remote code execution

Source:
PHP releases (GitHub php/php-src tags)
Published:
Fetched:
Updated:
Affects:
php ext-session

https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp ↗

repo-advisoryphpCWE-367CWE-662securityrepo:php/php-src

Partially overwritten session files can lead to remote code execution ### Summary PHP's file-based session handler can leave a session file containing parts of two different serialized sessions if a write is interrupted. An attacker who can influence the session contents and interrupt a replacement write may be able to make PHP deserialize attacker-controlled objects when the session is next opened. A suitable object gadget chain in the application can turn this into remote code execution. This affects the `files` session save handler, which is PHP's default. The issue is not limited to session upload progress or PHP 8.6. ### Details When updating a session, `ps_files_write()` writes the new serialized data into the existing file. The vulnerable implementation does not clear the existing contents before every write. If the operation stops after replacing only part of the file, the result can contain a prefix of the new session followed by a suffix of the old one. The file lock prevents competing session operations from accessing the file during the write, but does not make an interrupted write atomic. PHP's session decoders use its unserialization machinery to restore session values. Carefully arranged old and new data can cause the combined file to be interpreted differently from either original session. Bytes that were previously part of an ordinary string can become serialized object data. A later `session_start()` or another session-reading operation can then create those objects and invoke their deserialization behavior. Session upload progress provides one way for a remote client to influence stored session data through multipart uploads. The same underlying problem can arise when an application stores large user-controlled strings in a session. In threaded PHP builds, a hard memory-limit failure in another thread can terminate the process while the session write is in progress. This provides a way to influence where the write stops. The fix truncates the session file to zero before writing the replacement data and aborts the write if truncation fails. An interrupted write can still lose session data, but it can no longer retain the old suffix that enables this attack. ### Impact Successful exploitation can execute code with the privileges of the PHP worker. It requires attacker influence over the session data, an interruption at a useful point in the write, and an application with a suitable deserialization gadget chain. The issue can also corrupt session state. Authentication requirements depend on how the application exposes the affected session operations. Other session storage implementations are not affected by this specific file-write defect, although their own handling of interrupted updates must be considered separately. ### Affected versions The affected code has been present since PHP 4.1.0. This is based on code inspection. ### Mitigation Upgrade to the fixed release for your PHP branch when it becomes available. As a temporary measure, disable `session.up Affected packages: php:ext-session Patched: ext-session 8.2.36, ext-session 8.3.37, ext-session 8.4.28, ext-session 8.5.13

Linked vulnerabilities (2)

CVE-2026-126714 critical 9.2 EPSS 13.1% (p96) NVDCVE.orgGHSA
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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

Partially overwritten session files can lead to remote code execution. The files session save handler, which is the default, writes updated session data into the existing session file without first clearing it. If a write is interrupted, the file can contain the beginning of the new session followed by the end of the old one, and bytes of an ordinary string can later be unserialized as objects. An attacker who can influence the session data, for example through session upload progress, and interrupt a write at a suitable point may inject objects, which can lead to code execution when the...

CWE: CWE-367, CWE-662, CWE-502Aliases: CVE-2026-115560, CVE-2026-129289, CVE-2026-127960, CVE-2026-128064, CVE-2026-128090, CVE-2026-129291, CVE-2026-129292, CVE-2026-129496, CVE-2026-129506, CVE-2026-129538, CVE-2026-15353, GHSA-fm2m-fjf5-v3cp, CVE-2026-129481, CVE-2026-129501NVD: Awaiting Analysis
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

Partially overwritten session files can lead to remote code execution

CWE: CWE-367, CWE-662Aliases: CVE-2026-126714