SAASMENT

News

A cut-off PHP session write can plant objects that run code.

PHP's default file-based sessions can be left half-written so the next request loads objects an attacker chose. Today's releases fix that flaw, CVE-2026-126714, and the October PHP2Shell patches do not.

Illustration of a charcoal file split by a cut, with lime rows and a pink token at the seam

Impact

What was impacted
The PHP files session handler, which is the default, tracked as CVE-2026-126714 and called phpAfterShell by Depthfirst. PHP's maintainers rate it 9.2 on CVSS 4.0. A session write that stops halfway can leave the start of the new data and the end of the old data in the same file. Length fields in the new data can make leftover text parse as a separate record, including a serialized object, when the next request calls session_start(). With a suitable gadget chain in the app, that object can run code. The same mix can also replace ordinary session values, such as who is logged in, their permissions, or a CSRF token. Depthfirst's own chain needed no gadget from the app. It used a second bug, memory corruption in a built-in PHP class, whose details they are holding for coordinated disclosure. They have not said whether that second bug is fixed in today's releases. Sessions kept in Redis, a database, or another store are outside this defect, though each store's handling of a cut-off update needs its own check.
Who was impacted
Operators on PHP 8.2 before 8.2.36, 8.3 before 8.3.37, 8.4 before 8.4.28, and 8.5 before 8.5.13. PHP 8.6.0 includes the fix. Servers that only installed the October 21 PHP2Shell releases are still affected. Whether an attacker must log in depends on how the app exposes session handling. On the path Depthfirst tested, upload progress writes the session before the app's own code runs, and the app does not need an upload page, only a later page that opens the session. PHP 8.1 and older are end of life. The official end-of-life mitigation branches for 7.4, 8.0, and 8.1 are not affected, but older unpatched builds of those versions are, according to Depthfirst. A Linux distribution package may include the fix without changing the PHP version number.
What you need to do
Install 8.2.36, 8.3.37, 8.4.28, or 8.5.13 for the branch you run. PHP 8.6.0 also includes the fix. If you are on PHP 8.1 or older, move to a supported branch. Rebuild container images, redeploy, and confirm the PHP version serving web requests. If a package may have backported the fix, check the package changelog rather than the version number alone. If you cannot update yet and the app does not use upload progress, set session.upload_progress.enabled to 0, restart the PHP workers, and limit untrusted data stored in sessions. That is not a full fix: it closes the upload path, and apps that put attacker-controlled data into sessions another way stay affected. Servers that turned the setting off on October 21 for a PHP2Shell workaround still need this update. Moving sessions to a store that replaces a record in one step also avoids this defect. The update is still the recommended fix for sites that keep the files handler. Neither the maintainers nor Depthfirst report attacks.

Depthfirst reported CVE-2026-126714 to the PHP maintainers, who rate it 9.2 on CVSS 4.0. The company calls it phpAfterShell. It sits in the files session handler PHP uses by default. A session file stores each value as a name followed by serialized data, and length fields say where each string ends. Nothing in the file marks a write as finished. PHP locks the file while it writes, but the lock cannot undo a write that stops halfway. If the worker dies mid-write, the file can keep the start of the new data and the end of the old data. By setting those lengths, an attacker can make text that sat inside the old data read as a separate record, including a serialized object. The next request that calls session_start() loads that record. Code execution still needs a suitable gadget chain in the app. The flaw can also corrupt session state, including who is logged in, their permissions, or a CSRF token, before the app checks them. Neither the maintainers nor Depthfirst report any attacks.

The October 21 releases that fixed PHP2Shell do not contain this fix. Those patches limited which classes can load while PHP records upload progress, which stopped the earlier exploit, and they did not change the file write. Object data can still reach the disk and become active later, when an ordinary request calls session_start(). On the path Depthfirst tested, upload progress writes the session before the application's own code runs, as long as the feature is on and a multipart form carries its field. The app does not need an upload page, only any page that opens the session later. Whether the attacker must already be logged in depends on how the app exposes session handling. Depthfirst's public proof plants a harmless built-in object, stdClass. Their own chain needed no gadget from the app. It used a second bug, memory corruption in one of PHP's built-in classes. They are holding those details for coordinated disclosure and have not said whether that bug is in today's releases.

Affected releases are PHP 8.2 before 8.2.36, 8.3 before 8.3.37, 8.4 before 8.4.28, and 8.5 before 8.5.13. PHP 8.6.0, also released today, includes the fix. PHP 8.1 and older are end of life. The official end-of-life mitigation branches for 7.4, 8.0, and 8.1 are not affected, but older unpatched builds of those versions are, according to Depthfirst. Sessions kept in Redis, a database, or another store are outside this defect, though a cut-off update in those stores still needs its own check. Moving to a store that replaces a record in one step also avoids this defect. The update remains the recommended fix for sites that keep the files handler. A Linux distribution package may ship the fix without changing the version number, so the version string alone may not show whether a server is fixed.

If you cannot update yet and the app does not use upload progress, set session.upload_progress.enabled to 0 in php.ini or the server's PHP settings, restart the PHP workers, and limit the untrusted data the app stores in sessions. Switching the feature off is not a full fix. It closes the upload path, and apps that put attacker-controlled data into sessions in other ways remain affected. The maintainers listed the same setting on October 21 as a temporary measure for one of the PHP2Shell flaws. Servers that have kept it off since then still need this update. Depthfirst's steps are to install the fixed release for the branch, or move off PHP 8.1 and older onto a supported branch, rebuild container images and redeploy, then check that the PHP version serving web requests is the new one.

Once installed, the fixed releases empty the session file before each write and stop the write if that step fails. A cut-off write can still lose session data, but it can no longer leave old data behind for an attacker to use. The same releases switch upload progress off by default. A comparison of the PHP source for the October 21 releases and today's releases shows the built-in setting on in 8.2.35, 8.3.36, 8.4.27, and 8.5.12, and off in 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0. The release notes do not mention the change. The sample php.ini files still show the old setting in a commented-out line. A php.ini file, distribution package, or hosting panel that switches the setting on will keep it on. Where nothing else sets it, apps that rely on upload progress need it switched back on after the update. The same releases also fix other PHP security flaws.

For your AI agent

Agent instructions — copy paste to Claude

You are helping me respond to CVE-2026-126714, called phpAfterShell by Depthfirst, in PHP's default files session handler. Do not write or run an exploit, a proof of concept, or a request meant to interrupt a session write. Do not use any public proof, including one that plants a stdClass object.

Facts from the report:
- PHP's maintainers rate CVE-2026-126714 at 9.2 on CVSS 4.0. Depthfirst says it found the flaw and reported it. Neither the maintainers nor Depthfirst report attacks.
- A session write that stops halfway can leave the start of the new data and the end of the old data in the same file. The next session_start() can load a serialized object shaped from that mix, or ordinary session values such as login state, permissions, or a CSRF token can be replaced. Code execution through an application object still needs a suitable gadget chain.
- Depthfirst's own chain needed no gadget from the app. It used a second bug, memory corruption in a built-in PHP class. They are holding the details for coordinated disclosure and have not said whether that second bug is fixed in today's releases. Do not go looking for it and do not invent a CVE for it.
- The October 21, 2026 PHP2Shell releases do not contain this fix. They limited which classes can load while upload progress is recorded. They did not change the file write. Servers updated only then are still affected.
- Fixed releases: PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0. Affected on those branches: everything before those versions.
- PHP 8.1 and older are end of life. Move those to a supported branch. The official end-of-life mitigation branches for 7.4, 8.0, and 8.1 are not affected. Older unpatched builds of those versions are, according to Depthfirst.
- The defect is in the files session handler. Sessions in Redis, a database, or another store are outside this defect. Each of those stores still needs its own check for a cut-off update. A store that replaces a record in one step also avoids this defect. The update is still the recommended fix for the files handler.
- On the path Depthfirst tested, upload progress writes the session before application code runs. The app does not need an upload page, only a later page that opens the session. Whether a login is required depends on how the app exposes session handling.
- If you cannot update yet and the app does not use upload progress, set session.upload_progress.enabled to 0 and restart PHP workers. Also limit untrusted data stored in sessions. This is not a full fix. Apps that put attacker-controlled data into sessions another way stay affected. Servers that turned this off on October 21 still need the update.
- The fixed releases empty the session file before each write and stop the write if that step fails. They also switch upload progress off by default. The built-in setting is on in 8.2.35, 8.3.36, 8.4.27, and 8.5.12, and off in the fixed releases named above. Release notes do not mention that change. A php.ini file, distribution package, or hosting panel that turns the setting on will keep it on. Apps that rely on upload progress need it switched back on after the update where nothing else sets it.
- A Linux package may include the fix without changing the PHP version number. Do not treat the version string alone as proof.

Context:
- What was impacted: PHP's default file-based session files on the affected releases.
- Who should care: operators of PHP 8.2 through 8.5 below today's fixed builds, anyone still on the October 21 PHP2Shell patches only, and anyone on end-of-life PHP that is not an official mitigation branch.
- What to do: install the fixed build for the branch, rebuild images, and confirm the version that serves requests. Use session.upload_progress.enabled = 0 only as a stopgap when the app does not use upload progress.

Do this in order. Ask before editing php.ini, moving session storage, rebuilding images, or restarting PHP workers. Prefer read-only inventory first. Do not write or run an exploit or a proof of concept.

1. Inventory
   - Record the PHP version serving web requests on each host or image. Map 8.2 before 8.2.36 to 8.2.36, 8.3 before 8.3.37 to 8.3.37, 8.4 before 8.4.28 to 8.4.28, and 8.5 before 8.5.13 to 8.5.13. If the version is 8.6 before 8.6.0, the fixed build named here is 8.6.0. If a distribution package may have backported the fix, say the version number is not enough and ask for the changelog.
   - Record whether sessions use the files handler, or Redis, a database, or another store.
   - Record the value of session.upload_progress.enabled, and whether any php.ini, package, or hosting panel sets it.
   - Note whether the host only has the October 21, 2026 security release. Those builds do not fix this flaw.
   - If the version is 8.1 or older, say it is end of life. The official mitigation branches for 7.4, 8.0, and 8.1 are not affected. Older unpatched builds of those versions are, according to Depthfirst.
2. Contain
   - If the fixed build is not installed and the app does not use upload progress, propose setting session.upload_progress.enabled to 0 and restarting PHP workers. Ask before applying it. State that this does not replace the update and does not cover apps that store attacker-controlled data in sessions another way.
3. Remediate
   - Plan the branch update listed above, then a rebuild and redeploy of any container image. Ask before installing or restarting.
   - Do not jump a site to a different major or minor line unless the operator asks. The exception in this report is PHP 8.1 and older, which should move to a supported branch.
   - After the update, if the app needs upload progress and nothing else turns it on, propose setting session.upload_progress.enabled back to 1 and ask before doing it. The fixed releases turn it off by default.
4. Verify
   - Confirm the PHP version serving web requests is the fixed build you intended, or that the package changelog shows the backport.
   - Record whether upload progress is on or off after the change, and whether sessions still use files.
5. Report back
   - Versions found, session storage in use, whether upload progress was enabled, what you changed, and anything still on an unfixed build. Say that Depthfirst has not said whether their second, withheld memory-corruption bug is fixed today.

Do not invent CVEs, package versions, or exploit conditions. If a check needs access I have not given you, say what you need and stop.

← All news

Try the platform.

Open the demo workspace with mock data. No login. Register from the banner when you want early access. No security team. No call.

Try the platform