PHP2Shell: When the Bug Isn't in Your Code
On this page
You can write clean, careful PHP and still get owned. PHP2Shell is a good reminder of that, because the problem isn’t in WordPress, or a plugin, or your code. It’s in PHP itself.
On October 21, the PHP project pushed out emergency releases for two bugs: CVE-2026-109618 and CVE-2026-109619. Both are rated 9.2 (critical), and under the right conditions both allow remote code execution without logging in. In plain terms, someone on the internet may be able to run code on your server by sending it the right request.
What actually broke
Section titled “What actually broke”Some background first. A PHP web worker is a process that handles requests, usually many of them over its lifetime. For each request it allocates memory, does its work, and cleans up. Both bugs come down to that cleanup going wrong.
| CVE | What goes wrong |
|---|---|
| CVE-2026-109618 | Runs out of memory mid-operation; cleanup then uses half-built data. |
| CVE-2026-109619 | Keeps pointers to freed memory; the next request on the same worker uses them. |
The first one is interesting because hitting the memory limit is normally boring. The request dies with a fatal error and that’s it. Here, the way PHP bails out leaves its internal structures in a bad state, and cleanup trips over them. Researchers turned this into code execution on Apache with mod_php, including through a path that fires before your application code even starts running. The code runs as the web server user (think www-data), not root. Still more than enough to do real damage.
The second one is a classic use-after-free. PHP holds on to an address for memory it already gave back. That memory can be reused for something else, but PHP still trusts the old pointer. If an attacker can control what lands there, they can steer what PHP does next.
Not Just a WordPress Problem
Section titled “Not Just a WordPress Problem”The demos were run against WordPress, Drupal and Joomla, but those were just convenient targets. Any PHP application served through an affected runtime is in scope. Researchers also showed the bugs could leak chunks of process memory, which may include database passwords, API keys and session tokens.
That said, “vulnerable” doesn’t mean “one request and you’re done.” Exploitation depends on the PHP version, which extensions are loaded, configuration and memory layout. It doesn’t mean any deployment is safe to leave unpatched.
Why it blew up this week
Section titled “Why it blew up this week”According to the PHP Foundation, the out-of-memory issue was first spotted back in 2024. Fixing it properly meant hard compatibility tradeoffs, and the work stalled. In 2026, reports showed it could be turned into real remote code execution, and it became urgent.
Then things got messy. The CVE IDs leaked on October 20, a demo video was published by mistake, and PHP pulled the release forward from October 22 to October 21.
There’s also an AI angle. Wiz says frontier models helped its researchers build and adapt the exploit chains. Honestly, that’s the part that sticks with me. Memory bugs like these used to take a lot of skilled time to weaponize. If that time keeps shrinking, “we’ll patch it next month” stops being a reasonable plan.
Is anyone exploiting it?
Section titled “Is anyone exploiting it?”Cloudflare reports attack traffic aimed at these bugs, including attempts to tweak payloads to get past its filters. That tells us people are trying. It doesn’t tell us how many succeeded.
Cloudflare has added WAF rules, but it is also telling customers to patch. A WAF buys you time. It isn’t the fix.
What to update
Section titled “What to update”| PHP branch | Fixed in |
|---|---|
| 8.2 | 8.2.35 |
| 8.3 | 8.3.36 |
| 8.4 | 8.4.27 |
| 8.5 | 8.5.12 |
Anything serving web requests is affected: PHP-FPM, Apache mod_php, CGI, FrankenPHP and LiteSpeed. PHP 8.1 and older no longer get regular releases. Because these bugs are so severe, the PHP security team made an exception and published source-level fixes for 7.4, 8.0 and 8.1, mainly for people who build PHP themselves. If you use your distro’s packages, check its security advisory for a backported fix. Either way, this is a good excuse to finally upgrade.
Checking your own server
Section titled “Checking your own server”Don’t trust php -v on its own. That shows the CLI version, which isn’t always the one serving your site. On Debian or Ubuntu, list every installed PHP package instead:
apt list --installed 2>/dev/null | grep -E '^php'To update all of them together:
sudo apt update && sudo apt install --only-upgrade 'php8.*'Then restart PHP-FPM or Apache so the running workers pick up the new binary. Until you restart, the old vulnerable code is still in memory.
On shared or managed hosting, open a ticket and ask directly whether the PHP version serving your site includes both fixes. Updating WordPress, your theme or your plugins does nothing here, because none of them touch the PHP runtime.
If you can’t update right away, PHP’s advisory lists a partial stopgap for CVE-2026-109619: set session.upload_progress.enabled=0 in php.ini or your FPM pool config, then restart every worker. It blocks the confirmed attack path, not every variant. The only complete fix is the update.
Patch first. Leave the WAF on as a backup.