PHP2Shell: What to Do When Your PHP Version Can't Be Patched

By ·

A Serious PHP Flaw, and a Lot of Servers That Won't Get the Fix

On 21 October 2026 the PHP project released emergency fixes for two critical vulnerabilities, now known as PHP2Shell (CVE-2026-109618 and CVE-2026-109619). The release was brought forward a day after the details leaked, and security firms began seeing attacks the same day.

In plain terms, an attacker can send a specially crafted request to a PHP website and, in the worst case, run their own code on the server. No login is needed. The bugs are in PHP itself, so it doesn't matter whether the site runs WordPress, Drupal, Laravel or something written in-house fifteen years ago.

If you're on a current PHP version, the fix is simple: update and restart. This post is for everyone else - the organisations running applications on PHP versions that won't get an official patch, and that can't just be upgraded overnight. In my experience that's a lot more organisations than anyone admits.

PHP2Shell at a Glance

  • What it is: two memory-handling bugs in how PHP processes incoming request data
  • Impact: remote code execution without authentication, rated 9.2 (critical) by the PHP security team
  • Affected: reportedly PHP 5.4 through 8.5 - effectively every PHP version still in real-world use
  • Server setups affected: PHP-FPM, Apache with mod_php, php-cgi, LiteSpeed and FrankenPHP. On Apache with mod_php, a working exploit triggers before your application code even runs
  • Fixed in: PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35
  • Status: being exploited in the wild since 21 October 2026

Step 1: Find Out What You're Actually Running

Plenty of organisations don't know which PHP version their website runs on, especially if it was set up by someone who has since moved on. Find out before doing anything else.

On the server

Run php -v from the command line. Bear in mind that the command-line PHP isn't always the one serving your website. Servers often have several versions installed, so check which version PHP-FPM or Apache is actually using too.

On shared or managed hosting

Your hosting control panel (cPanel, Plesk, Cloudways and so on) will usually show the PHP version for each site. Many hosts are patching their supported versions right now. Ask them directly whether the version your site uses has been patched, and get the answer in writing.

Check every site, not just the main one

The forgotten sites are the risky ones: the old microsite, the staging copy that's still public, the intranet tool on a box in the corner. Every PHP site that can be reached from the internet counts.

Step 2: Work Out Which Situation You're In

PHP 8.2 to 8.5: patch now

Update to the fixed release for your branch, or to your Linux distribution's patched package, then restart PHP-FPM or Apache so the new version is actually loaded. This should be a same-day job. If your application breaks on a point release, that tells you something about your maintenance process worth fixing afterwards.

PHP 7.4 to 8.1: a fix exists, but you have to apply it

These versions are past end-of-life, but because of the severity the PHP security team published minimal source-code fixes for them. You won't get a ready-made package from php.net. Someone has to apply the fix to the PHP source, rebuild PHP, test it and deploy it. It's very achievable and it means your application doesn't change at all, but it needs someone comfortable compiling PHP. If your Linux distribution or hosting provider still supports your version, check whether they've already packaged the fix.

PHP 5.x to 7.3: no official fix

This is the hard case, and it's more common than you'd think. Old line-of-business applications, custom CMSs and abandoned intranet tools often run on PHP 5.6 or 7.0 because nobody has had the budget or the nerve to move them. There is no official patch for these versions, and there isn't going to be one.

Options When You Can't Simply Upgrade

There's no configuration setting that switches these flaws off, so if a patched PHP isn't an option, you need to reduce how exposed the server is while you work towards a proper fix. In rough order of how quickly they can be done:

1. Put a firewall in front of it - today

Services like Cloudflare have released rules targeting PHP2Shell attacks, and turning these on is quick. But attackers have already been seen trying to get around those rules. Treat a firewall as a way to buy time, not as a fix.

2. Take it off the public internet

If an application is only used by staff, it probably shouldn't be reachable by everyone on the internet. Putting it behind a VPN, an identity-aware proxy or IP allow-listing removes most of the risk while keeping the application exactly as it is. This is often the best option for internal tools.

3. Back-port the fix

The official fixes for 7.4 to 8.1 are small and targeted. For older versions it's sometimes possible to adapt the same fix to the older PHP source and build a patched version. Whether it's practical depends on how far the code has changed between versions, so it needs assessing case by case - and it needs testing properly, not just compiling.

4. Contain the server

Assume an old server may be compromised one day and limit what an attacker could reach. Run the application in its own container or virtual machine, give it the least database access it needs, keep it away from other systems on the network, and watch it for unexpected changes to files and processes.

5. Plan the upgrade properly

PHP2Shell won't be the last flaw of its kind, and every one from here on will leave old PHP versions further behind. The long-term fix is getting the application onto a supported version. That rarely means a rebuild: most old PHP applications can be brought forward in stages, fixing what breaks as you go. I've written about this approach in modernising without rebuilding.

Check Whether You've Already Been Hit

Exploitation started the day the fix was released, so patching alone isn't the end of it. If an internet-facing server was running an affected version from 20 October onwards, look for signs of compromise: new or modified PHP files in web directories, unfamiliar scheduled tasks, unexpected outbound connections, new user accounts and unusual processes. If you find anything, assume credentials stored on that server are compromised and rotate them.

For Australian organisations, remember that a breach involving personal information may need to be reported to the OAIC under the Notifiable Data Breaches scheme.

Frequently Asked Questions

What is PHP2Shell?

PHP2Shell is the name given to two critical flaws in PHP itself, CVE-2026-109618 and CVE-2026-109619. They are memory-handling bugs in how PHP processes incoming request data, and they can allow an attacker to run code on the server without logging in. Both are rated 9.2 out of 10 by the PHP security team.

Which PHP versions are affected by PHP2Shell?

Researchers report that versions from PHP 5.4 through to PHP 8.5 are affected. Fixed releases are PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35. The PHP team has also published source-code fixes for PHP 7.4 to 8.1, but these are not packaged releases. Older versions have no official fix.

Does PHP2Shell affect my site if I use WordPress or a framework?

Yes. The flaw is in PHP itself, not in WordPress, Laravel or your own code, and on some server setups it can be triggered before your application code runs. Keeping your CMS and plugins up to date does not protect you. Only the PHP version running on the server matters.

Is a web application firewall enough to protect an old PHP server?

A firewall such as Cloudflare reduces the risk and buys time, but it is not a fix. Attackers have already been seen trying to evade firewall rules for these flaws. Use a firewall as a stopgap while the server is patched, rebuilt or isolated.

My application won't run on a newer PHP version. What can I do?

For PHP 7.4 to 8.1 the official source fixes can be applied and PHP rebuilt, which keeps the application unchanged. For older versions the options are to back-port the fix yourself, isolate the application so it is not reachable from the internet, or upgrade the code to run on a supported PHP version. Get in touch and I can assess which is realistic for your system.

Stuck on Old PHP? Let's Work Out Your Options

I've been supporting legacy PHP applications for over twenty years, including the ones nobody else wants to touch. If you have a system on an old PHP version and you're not sure how exposed it is, get in touch. I'll tell you which version you're really running, what can be patched, and what it would take to make it safe.

Related service: ColdFusion & legacy application support

Get in Touch

I welcome all genuine enquiries. Please don't hesitate to contact me if you wish to find out more about my professional services or discuss how we can work together on your next or current project.

Start a conversation

"David is a pleasure to work with, right from the beginning as we were developing our new website all the way to delivery. He helped us see clearly what we were looking for - often when we were not sure - providing lots of suggestions on areas we had not thought of and then delivering what he promised."