What A Time To Be Alive
Choose language: English

PHP fixes vulnerability in its default session storage

Security company Depthfirst found a serious flaw in the way PHP stores data about website visitors. An update fixes it, and servers that were already updated in October need it too. No attacks have been reported.

A hand scoops blue glass marbles into a glass jar on a desk; old red marbles still lie at the bottom, and where the layers meet, red and blue are mixed. Blurred server racks with blue lights in the background.
New data written over old data, without emptying first: that is how the flaw in PHP arose (illustrative photo, generated with AI)

Websites built with PHP, a widely used programming language for websites, often remember data about a visitor between two clicks, for example that someone is logged in or what is in a shopping basket. Such a set of data is called a session, and by default PHP keeps it in a file on the server. It is in exactly this default storage that the security company Depthfirst found a serious flaw. The makers of PHP announced it . The fix is in PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13.

The flaw is called phpAfterShell and has the number CVE-2026-126714. The makers of PHP gave it a 9.2 on CVSS, a scale up to 10 for how serious a vulnerability is. No attacks have been reported.

What goes wrong

When PHP updates a session, it writes the new data over the old data in the same file, without emptying the file first. If that writing is cut off halfway, a mixture is left behind: the start of the new data with the end of the old data after it. On the next visit, PHP reads that mixture back in. An attacker who can put text into the session themselves can choose that text so that, in the mixture, PHP no longer sees ordinary text but parts of a program that it puts back to work. That is dangerous, because such parts can make code run.

To do this, the attacker does have to make the writing stop at the right moment. In tests, Depthfirst did that by putting so much load on the server that the work was stopped halfway, and through a feature that keeps track of how far an upload has got. That feature updates the session before the website itself does anything, and in the tests the attacker did not need to log in for it. According to the makers of PHP, whether logging in is needed depends on the website.

In this way Depthfirst managed to run its own code on the server, by combining the flaw with a second flaw in PHP itself. The company is still holding back details of that second flaw, so that administrators can update first. The weak spot has been in the code since PHP 4.1.0, a very old version.

Updating once more after PHP2Shell

, emergency updates had already come out against PHP2Shell, two serious vulnerabilities that researchers from Wiz and Calif found in PHP with the help of AI. Those updates made sure that tracking uploads could no longer put parts of a program to work. They did not solve the underlying problem with the session files. Servers that were updated then therefore also need this new update.

The fix first empties the session file before the new data goes in, and stops if that does not work. An interruption can then still make session data disappear, but no mixture is left behind any more.

Anyone who cannot update yet can switch off the upload progress feature if the website does not use it, and keep as little outside data as possible in sessions. That only partly helps. Websites that store their sessions in some other way than in files are not affected by this flaw.

What does this mean for the road to the singularity?

In its analysis, Depthfirst points to a lesson for this time: with AI, the search for vulnerabilities goes faster, and a quick repair can stop one attack while the deeper flaw stays in place. PHP2Shell and phpAfterShell show this. The first repair closed off the route of the attack; the second makes the storage itself safe.

If such old flaws in widely used software come to light faster and faster, the makers' work shifts from a quick emergency repair to thoroughly fixing the cause. That is also where the opportunity lies. The same speed can be used straight after every repair to check whether the cause is really gone, and whether other routes lead to the same flaw. Then the software behind many websites gets stronger with every round, rather than only having its holes patched. For administrators, meanwhile, it stays simple: update, and check that the new version is really running.

What is the technological singularity? Read the explanation →

Sources

  1. depthfirst
  2. GitHub
  3. The Hacker News