truix Request resume

blog

PHP2Shell: I Reproduced the Worst PHP Bug of the Decade in an Afternoon (and Didn't Publish the Gun)

PHP just patched two engine-level bugs nicknamed PHP2Shell. I reproduced the attack chain in an isolated lab. This post covers what it means for you and leaves out the exploit details on purpose.

7 minute read

Saitama: opening hook

On October 21, 2026, the PHP security team released emergency patches for two CVEs, CVE-2026-109618 and CVE-2026-109619. Together they are nicknamed PHP2Shell. They affect every supported PHP branch, which means every PHP version shipped in roughly the last decade. PHP runs something like 70% of the websites on earth, so a lot of servers are exposed.

I read the advisory and wanted to know if it was as bad as it sounded. It was. I got it working myself in an isolated lab in a few hours, and I'm no wizard, so the bug is easy to reach once you know where to look. I'm writing it up without handing anyone a loaded gun.

The one-sentence version

Light Yagami: bug scale

PHP can end up in a corrupted state when it runs out of memory while reading an incoming web request, before your application code even runs. If an attacker gets a PHP worker into that state, then under the right conditions they can make it run code they chose. No login is needed and it works remotely. WordPress, Drupal, Joomla and basically anything else written in PHP is affected, however careful the app code is.

Why this one is different

Most remote code execution bugs live in somebody's application, like a bad plugin or a careless upload handler. You patch the app and you're done.

L: AI-assisted bug hunting

This one is in the engine itself, the part every PHP site shares no matter what's built on top. The vulnerable behavior has apparently been there for over a decade. Frontier AI models found it while fuzzing and pattern-matching across the PHP codebase. The same tools that help defenders find bugs faster also cut the time attackers need to find them. For years bugs like this stayed theoretical because exploiting them took slow, manual, specialist work, and that has changed.

What I actually did

I built an isolated lab first. It has no connection to any production network, nothing in it faces the internet, and it runs on throwaway containers. Then I tried to make the bug happen, starting with only the public advisory text.

Lab topology: isolated VM with four Docker containers, no internet access

Lab topology: isolated VM with four Docker containers, no internet access

Okabe: public PoC fails

Within a few hours I could crash a vulnerable PHP worker every time I tried, and the patched version never crashed. I ran the two side by side, so I have actual numbers to show you. I also found a second crash on a different PHP version, through a different code path.

After that I ran a full attack chain over HTTP against my own lab target. I sent some web requests and the page started showing text I wrote instead of what it used to say. From there I got a working shell, and then a small persistence and exfiltration demo. All of it was self-contained, I tore it down afterward, and none of it touched anything outside the isolated VM.

Live exploit demo: terminal runs the exploit while the browser shows the page changing from Hello World to This site is now mine in real time

Live exploit demo: terminal runs the exploit while the browser shows the page changing from Hello World to This site is now mine in real time

yeah, it only takes 3 seconds to pwn your site

Side-by-side crash comparison: PHP 8.5.11 shows SIGSEGV crashes, PHP 8.5.12 returns clean 200s

Side-by-side crash comparison: PHP 8.5.11 shows SIGSEGV crashes, PHP 8.5.12 returns clean 200s

Shikamaru: SIGSEGV victory

Along the way I also found and documented a separate crash that still reproduces on the fully patched release. It is a different bug from the two CVEs and it can't be triggered remotely. You can only hit it through a common server configuration, and then it takes your own server down. I'm sending that one to the PHP team directly and not putting steps in a public writeup, since a crash that survives the patch needs a fix before anyone needs to read about it.

Nami: measurement confounds

Aqua: disk filling, 14GB

How it works, at the level you need to understand the risk

First, PHP can be pushed into running out of memory while it is still parsing an incoming request. That happens before your code runs, and before PHP has finished setting up its own bookkeeping for the request.

You would expect the worker process to just die cleanly at that point. In the vulnerable versions it can keep running, with some internal state pointing at memory that is no longer valid. The technical term is a use-after-free, where the program keeps using memory after it told the system it was done with it.

Then the next request handled by that same worker can end up touching that stale memory. Depending on what is sitting there, the server either crashes, which is bad but only a denial of service, or it runs code the attacker chose, which is full compromise.

I'm not walking through the gap between those two outcomes. It was found by Calif and Wiz, and the Calif writeup is the one to read. Rapid7, Unit 42 and others have covered it too, and the advisory and those writeups already describe the mechanism publicly in general terms. I don't add operational detail to that, and I stop short of it on purpose.

Why I'm not publishing the code

Gojo: redacting exploit code

I want you to know the bug is serious and close to the surface, and I don't want to hand out a kit. So I left out everything you would need to go from understanding the bug to firing it at a target. That means no trigger payloads, no timing or sizing parameters, no memory-layout tricks, no poisoning or persistence code and no shell source. The screenshots, the before and after demo and the plain-language explanation back up what I'm saying without being a how-to.

If you run PHP in production you don't need the exploit internals anyway. You need the next section.

What to do about it

Kakashi: patch now, restart workers

Gintoki: production version-string trap

  1. Patch now. 8.2.35, 8.3.36, 8.4.27, or 8.5.12, whichever branch you're on.
  2. Restart your PHP workers after patching. Updating the file on disk does nothing until the running process reloads it. Under mod_php that means restarting Apache, under FPM it means restarting the FPM service, and with containers it means rebuilding the image. Afterward, check the live Server response header. php -v alone can tell you the wrong thing.
  3. If you can't patch right away, set memory_limit = -1 and restart your workers anyway, and turn off session.upload_progress if your app doesn't use it. Also watch your logs for SIGSEGV entries right after multipart POST requests, since that is what an attempt looks like.

What bothers me

It took a public advisory, a weekend and an isolated lab for one person (me) to go from reading about this to having video of it working. What stuck with me is how short the gap has gotten between a bug being disclosed and someone using it. Patch your stuff. In 2026 you can't treat a critical CVE as something to get to later.


Everything shown above was done in a network-isolated lab against disposable containers I built for this purpose. No production systems or third-party targets were involved. No exploit code, payload content, or reproduction steps are included in this post.