Skip to content
Security & Trust

PHP's first session patch blocked the exploit, not the flaw, Depthfirst says

CVE-2026-126714 shows how a fix for one attack path can leave the cause in place, say Depthfirst's researchers

W
WebPulse Newsroom
AI-assisted · 4 min read
Share on X LinkedIn
PHP's first session patch blocked the exploit, not the flaw, Depthfirst says
In brief
  • Depthfirst says PHP's file-based session storage can be tricked into returning attacker-chosen data. This is CVE-2026-126714, rated 9.2 by PHP's maintainers.
  • The October 21 PHP releases, which fixed PHP2Shell, do not contain this fix. The maintainers and Depthfirst report no attacks so far.
  • Install the new PHP releases and check the upload-progress setting. Ask whether your last patch removed the cause or only the first exploit.

A fix can stop an exploit and leave the bug

A patch is often treated as a box to tick. Depthfirst's new research on PHP shows why that box can mislead. The researchers say the October patch for PHP2Shell stopped one attack. It did not touch the weakness that made the attack possible.

The lesson here is that a patch answers the question "does the known exploit still work?" Leaders also need to ask whether the reason the bug existed has gone.

What was found

Depthfirst, a security company, reported a new flaw to the PHP maintainers, called phpAfterShell. It is tracked as CVE-2026-126714. The maintainers' severity score is 9.2 on CVSS 4.0, a scale that tops out at 10, as The Hacker News reports.

The Hacker News reports that the October 21 releases, which fixed two flaws known as PHP2Shell, do not include this fix. A server that took that October update still needs a second one. Neither the maintainers nor Depthfirst report any attacks using phpAfterShell.

The weak point is PHP's built-in way of keeping sessions in plain files on disk. PHP does this unless an operator tells it otherwise. Teams that keep sessions in Redis, a database or another store do not have this particular defect, The Hacker News says. It adds that each store still needs its own check for how it handles an interrupted update.

How the attack works

A session is the server's memory of a visitor: who they are, what is in their cart, where they are in a workflow. PHP's default handler keeps each session in a file.

Depthfirst found that PHP updates that file in place. It uses two separate steps: writing the new bytes and trimming the old ones. Depending on the PHP version, the trim happens either before or after the write. These steps are not atomic, meaning they do not succeed or fail as one unit. If the PHP worker dies partway, the file can hold the start of the new session joined to the end of the old one.

Both halves are valid on their own. Joined, they can mean something else. The session format uses length fields to say where each value ends. An attacker who controls those lengths can make bytes that were harmless text read as a separate session entry, including a serialized object. The researchers say the file has no checksum or commit marker to catch this.

Depthfirst's route in uses upload progress, a feature that logs a file upload's status inside the visitor's session. When it is on, PHP updates the session while it is still reading the upload request, ahead of the application's first line of code. The application only needs some later page that opens the session. At that point PHP reads the spliced file as trusted state and rebuilds the object.

The timing is hard, and the researchers say they solved it. In one test setup, attackers pushed the web server close to its memory limit so that a worker was killed mid-write. Depthfirst reports a hit on the eleventh attempt in a fresh run of one variant, and in ten attempts for another.

Depthfirst says it chained this with a memory-corruption bug in a PHP-native class and reached code execution. It has withheld the details for coordinated disclosure. It says the chain does not need a gadget class written by the application. The Hacker News describes the usual case differently: code execution typically needs an extra weakness in the app, such as a usable gadget chain.

Why the first patch fell short

The PHP2Shell fix restricted which classes could come to life while upload progress was being processed. Depthfirst says that did its job. But the session file was still rewritten in place. The dangerous bytes simply waited on disk until the next session_start() call, when the restriction no longer applied.

Depthfirst also argues that AI speeds up both sides. A model can write a guard and a regression test quickly. That can stop the proof of concept while the deeper bug stays.

What the new releases change

The Hacker News reports that after the update, PHP clears the old file contents first. If the clearing fails, it abandons the save. An interrupted save may still cost a user their session. It cannot leave stale bytes that an attacker could reuse.

The new releases also ship with upload progress turned off. The release notes do not mention this, The Hacker News says. That is only the factory default, though. Any configuration layer that enables upload progress, whether a php.ini file, a distribution package or a hosting panel, still overrides the new default. Where nothing else sets it, applications that depend on upload progress must turn it back on.

Linux distribution packages may carry the fix without changing the version number, according to Depthfirst. A version check alone may not settle the question.

Questions to put to your team

Ask which PHP releases run in production, and whether each has the new fix. For packaged builds, ask the vendor, not the version string.

Ask whether upload progress is on, and where it is set. Setting session.upload_progress.enabled to 0 closes the upload path. The maintainers say it is not a full fix, because other ways of putting attacker-controlled data into sessions remain.

Ask whether sessions need to live in files at all. According to The Hacker News, moving sessions to a store that replaces whole records at once also avoids this particular defect.

And ask the question this story is really about. After the last patch, who checked that the cause was gone, not only the exploit?

Produced by the WebPulse Newsroom with AI assistance from the original reporting credited below, and checked against that source by our editorial review. How we use AI.
Original reporting: Depthfirst.

CVE-2026-126714: PHP