
PHP
PHP2Shell: What Just Happened to PHP, and How to Fix It
Published
If you build or run anything on PHP, today was not a normal Wednesday. The PHP project disclosed two critical vulnerabilities in the language itself, now collectively called PHP2Shell, and the headline making the rounds says up to 70% of the web is exposed. I have spent 8+ years in PHP, and I upgraded a large production platform from PHP 7.4 to 8.2 not long ago, so this one got my full attention. Here is what happened, what it means for you, and exactly what to do about it.
The short version
- Two vulnerabilities, CVE-2026-109618 and CVE-2026-109619, were found in the core PHP engine, not in WordPress, Laravel, or any plugin.
- The PHP project rates both 9.2 out of 10 (CVSS 4.0).
- An attacker with no account could potentially run code on your server or read memory from your PHP workers.
- Patches are out. Update to PHP 8.5.12, 8.4.27, 8.3.36, or 8.2.35, then restart your PHP workers.
What actually happened
According to Wiz Research, the flaws were found in August using frontier AI models, reported to the PHP team, and disclosed publicly on October 21 once a fix was ready. Researchers at Calif and OpenAI also worked on parts of the issue. Reporting from Fortune says the bug had been sitting in PHP for roughly 14 years.
The interesting part is not just that AI found it. Wiz explains that the underlying weaknesses were old, but turning them into a working attack meant chaining several bugs together and adapting to each server’s memory layout, work that used to take a world-class team months. With AI models helping iterate and debug, they say one researcher did it in about a week. That is the real shift: complexity is no longer the protection it used to be.
The disclosure also did not go perfectly smoothly. The Hacker News reported that details leaked on October 20, before the planned release, which pulled the patch date forward. Treat that as a signal that attackers had a head start on understanding this.
Why this is different from a normal PHP bug
Most PHP security issues live in application code: an unsanitized query, a vulnerable plugin, a missing CSRF check. This one lives below your application. Wiz demonstrated that even a bare “Hello World” script on a vulnerable PHP version can be exposed, and they built working exploits against default WordPress, Drupal, and Joomla container images.
All of the bugs come from how PHP handles fatal errors during a request, especially out-of-memory errors. When a request dies in the wrong place, PHP can leave stale pointers behind in a worker that stays alive. The next request handled by that worker can then trip over that leftover state. The four demonstrated bugs were:
- Upload-progress unserializer use-after-free (CVE-2026-109618): memory corruption leading to code execution.
- Remote process-memory disclosure (CVE-2026-109618): leaks worker memory into a
PHPSESSIDcookie, even if your app never callssession_start(). - Fatal-error backtrace use-after-free (CVE-2026-109619): cross-request memory corruption.
- OPcache type confusion (CVE-2026-109619): corrupts shared OPcache state across workers.
The memory disclosure piece deserves special attention. Leaked worker memory can contain passwords, tokens, API keys, and certificates from other requests. Wiz compares the overall severity to Heartbleed in 2014.
Am I affected?
Probably, if PHP serves web requests for you. Wiz says nearly every PHP version back to 5.4 is affected by at least one of the issues. Help Net Security notes the affected setups include PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP, and LiteSpeed, with mod_php carrying the highest risk.
Here is the fix matrix for supported branches:
| PHP branch | Vulnerable | Fixed in |
|---|---|---|
| 8.5 | below 8.5.12 | 8.5.12 |
| 8.4 | below 8.4.27 | 8.4.27 |
| 8.3 | below 8.3.36 | 8.3.36 |
| 8.2 | below 8.2.35 | 8.2.35 |
| 8.1 and older | End of life | No official fix from the PHP project |
If you are on 8.1 or older, you have two options: upgrade to a supported branch, or ask your Linux distribution or LTS vendor whether they have backported the fix. Also note that PHP 8.2 reaches end of life on December 31, 2026, so if you are patching 8.2 today, put a move to 8.3 or newer on the calendar.
How to fix it, step by step
Step 1: Find out what you are really running
Do not trust only the CLI. The command line PHP can be a different version than the one serving your site.
php -v
php-fpm -v # or php-fpm8.4 -v, depending on your install
apachectl -M | grep php # shows if mod_php is loaded
The fastest check for the web-facing version is a temporary phpinfo() page behind authentication, or checking your hosting control panel. Remove it when you are done.
Step 2: Update PHP
Ubuntu / Debian:
sudo apt update
sudo apt install --only-upgrade php8.4 php8.4-fpm # adjust to your branch
RHEL / Rocky / Alma: use dnf update php* and follow your vendor’s advisory.
Docker: pull a patched tag and rebuild, for example php:8.4.27-fpm or newer, and redeploy. Remember that a rebuilt image is not enough until the running containers are replaced.
Windows / IIS: download the patched build from windows.php.net, replace your PHP directory, and verify your handler mapping points to it.
Managed hosting (WordPress hosts, Pantheon, Cloudways, etc.): check your host’s dashboard or status page. Many will roll patches automatically, but confirm the version rather than assuming.
Step 3: Restart everything that runs PHP
This is the step people forget. The PHP project says to restart workers after upgrading and confirm that every web-facing pool is on the patched version. Updating the CLI package does not necessarily update a separate PHP-FPM service or an Apache module.
sudo systemctl restart php8.4-fpm
sudo systemctl restart apache2 # or nginx, if applicable
Step 4: Verify the patch actually took
Distribution packages sometimes keep the old version number and backport the fix, so a version string alone can mislead you. Check the package changelog for the CVE IDs:
apt changelog php8.4-fpm | grep -E "CVE-2026-10961[89]"
# or on RPM systems:
rpm -q --changelog php | grep -E "CVE-2026-10961[89]"
Step 5: If you cannot patch right now
Patching is the only complete fix, and the PHP project says no configuration change substitutes for it. But if you truly cannot update yet, these reduce exposure for CVE-2026-109619:
session.upload_progress.enabled = 0
fatal_error_backtraces = 0 ; PHP 8.5 only
Restart every worker after changing them. Many hosts and CDNs, including Cloudflare, Fastly, and Akamai, also pushed out WAF rules as a stopgap. Turn those on, but treat them as a bandage. The NSA has urged organizations that cannot update to consider taking affected systems offline.
Step 6: Hunt for signs of trouble
Because these bugs run below the application layer, your app logs may show very little. Wiz suggests watching for:
- Unusual multipart upload requests followed by memory-limit errors or repeated HTTP 500 responses
- Unexpectedly large or malformed
PHPSESSIDvalues in response cookies - Unexplained PHP worker churn or crashes
That last one is my own precaution, not an official recommendation: if you have any internet-facing PHP system that was exposed and unpatched, consider rotating API keys, database passwords, and tokens that PHP workers handle, since the memory disclosure bug could have leaked them.
What this means for developers
A few lessons I am taking from this:
- Know your whole stack, not just your code. Clean application code did not protect anyone here. Keep an inventory of PHP versions across dev, staging, and production, and your Docker base images.
- Make patching routine. Pinned base images, CI checks for runtime versions, and a tested upgrade path turn a scary day into a boring one. The upgrade from 7.4 to 8.2 I led was far easier because the groundwork was already there.
- Stay off end-of-life versions. PHP 8.1 and older will not get an official fix. That is the cost of falling behind.
- Assume faster attackers. If AI shortens the time between disclosure and working exploit, the window to patch shrinks. Waiting for the next maintenance window is a riskier bet than it used to be.
There is a hopeful side as well. The same AI capabilities that make exploitation cheaper also helped defenders find and fix a flaw that survived over a decade of human review. Used well, that is a net win for everyone who writes software.
Quick checklist
- Check the PHP version your web server actually uses.
- Update to 8.5.12, 8.4.27, 8.3.36, or 8.2.35 (or a vendor package with the backport).
- Restart PHP-FPM, Apache, or whatever serves PHP.
- Verify via changelog or version, including in containers.
- Enable WAF protections and the interim ini settings only if you cannot patch yet.
- Review logs and rotate secrets on exposed systems.
- Plan to leave PHP 8.1 and older, and schedule 8.2’s retirement.
Sources
- Wiz Research, “PHP2Shell: AI uncovers critical RCE vulnerabilities affecting 70% of the Internet”: https://www.wiz.io/blog/php2shell-php-rce
- Help Net Security, “PHP2Shell: Critical PHP vulnerabilities patched, update now!”: https://www.helpnetsecurity.com/2026/10/21/php2shell-php-vulnerabilities-patched-cve-2026-109618-cve-2026-109619/
- The Hacker News, “PHP Issues Emergency Patches for Two Critical PHP2Shell RCE Flaws”: https://thehackernews.com/2026/10/php-issues-emergency-patches-for-two.html
- CNN, “AI helped find a critical security flaw affecting 70% of the internet”: https://www.cnn.com/2026/10/21/tech/php2shell-vulnerability-ai
- Fortune, “AI tools discovered the PHP vulnerability that could take down 70% of the Internet”: https://fortune.com/2026/10/21/ai-tools-discovered-the-php-vulnerability-that-could-take-down-70-of-the-internet-now-the-race-is-on-to-patch-it-before-ai-powered-hackers-attack/
- Official PHP advisory and release notes: https://www.php.net/archive/2026.php
Need help auditing a PHP server or planning an upgrade? Reach out at hello@codingwithjuan.com.