Skip to content
The site is hacked

php2shell: how to patch PHP

PHP fixed two critical vulnerabilities on 21 October 2026 in 8.2.35, 8.3.36, 8.4.27 and 8.5.12. How to patch PHP on shared hosting, your own server and Docker.

You need
Hosting panel
Updated

php2shell is the name given to two critical PHP vulnerabilities, CVE-2026-109618 and CVE-2026-109619. PHP fixed them on 21 October 2026 in versions 8.2.35, 8.3.36, 8.4.27 and 8.5.12. The bug is in PHP on the server, so updating WordPress or your plugins won't help. You're protected once the server runs one of the patched versions and PHP has been restarted. For the background, see our article on php2shell.

Check which PHP version you have

Go to Tools → Site Health, open the Info tab and expand Server. The PHP version is listed there.

PHP version Update to
8.2 8.2.35 or later
8.3 8.3.36 or later
8.4 8.4.27 or later
8.5 8.5.12 or later
8.1 and older PHP 8.3 or newer, or a patched package from Ubuntu or Ondřej Surý in the meantime

If Site Health shows a lower version, PHP hasn't been patched. The exception is packages that carry the fix without a new PHP version, such as Ubuntu's own PHP and Ondřej Surý's PHP 8.1 and older. Site Health still shows the old version number there, so check the package version as described under Ubuntu and Debian.

Patch PHP

On shared hosting, your hosting provider installs PHP updates for every customer. You can't do it yourself.

  1. Look for a status page or news post from your hosting provider about php2shell.
  2. If there's nothing, ask support which PHP version your site runs and when the security update will be installed.
  3. If the site runs PHP 8.1 or older, switch version in the hosting control panel. Our article on upgrading PHP explains how to do it without taking the site down.

Not sure who your hosting provider is? Here's how to find out who hosts your website.

Stopgaps if you can't patch today

Only the update closes the vulnerabilities. If you can't patch straight away, PHP recommends the settings below. They block the routes PHP has confirmed, not every variant of the attack.

Setting Vulnerability What it does
session.upload_progress.enabled = 0 CVE-2026-109619 Turns off upload progress tracking. WordPress doesn't use it.
fatal_error_backtraces = 0 CVE-2026-109619, PHP 8.5 only Stops PHP storing a backtrace when a script dies with a fatal error.
memory_limit = -1 CVE-2026-109618 Removes the memory limit the attacker uses to stop PHP mid-request.
post_max_size = 32M CVE-2026-109618 Caps the size of requests PHP accepts. Use 8M if the site takes no file uploads.

Without a memory_limit, a single request can use up the server's memory. Put a memory limit on the container or on the PHP service in systemd instead. Don't use ulimit -v for this, as that kind of limit triggers exactly the failure you're trying to avoid.

These settings must go in php.ini, the PHP-FPM pool or the Apache configuration, and every PHP worker needs restarting afterwards. .user.ini and ini_set() won't work, because PHP reads them after it has already parsed the request. On shared hosting that means you can't do this yourself, so ask your hosting provider.

Add these lines to the pool file, for example /etc/php/8.3/fpm/pool.d/www.conf on Ubuntu and Debian:

php_admin_flag[session.upload_progress.enabled] = off
php_admin_value[memory_limit] = -1
php_admin_value[post_max_size] = 32M
php_admin_value[upload_max_filesize] = 30M

On PHP 8.5, add php_admin_flag[fatal_error_backtraces] = off as well. Restart PHP-FPM afterwards. With php_admin_, neither WordPress nor plugins can change the values.

Check the settings have taken effect. Create info.php in the root folder containing <?php phpinfo();, open it in your browser and search for session.upload_progress.enabled. The Local Value column should read Off. Delete the file as soon as you're done, because it reveals details about your server that an attacker could use.

If the site sits behind Cloudflare, Cloudflare has had rules against the attack since 03:02 UTC on 21 October, on the Free plan too. On paid plans, check that the Cloudflare Managed Ruleset is set to Block. The rules only help if your server can't be reached directly on its IP address, and they don't replace the patch.

If the site runs PHP 8.1 or older

PHP ships no new releases for 8.1 and older. The PHP security team has written a minimal patch for 7.4, 8.0 and 8.1, and Ubuntu and Ondřej Surý have added it to their PHP packages, as listed in the table under Ubuntu and Debian. On RHEL, AlmaLinux and Rocky Linux it's in the AlmaLinux packages and in Remi Collet's. If you build PHP yourself, you'll need to apply the patch yourself.

The patch only closes php2shell, so move to PHP 8.3 or newer anyway, as described in our article on upgrading PHP. If you have neither a patched package nor the option to upgrade right away, restrict the site to known IP addresses until it's upgraded. Your hosting provider or developer can set that up.

Once PHP is patched

The patch closes the vulnerabilities, but it doesn't remove a backdoor planted before you applied it. Check the server as described in how to look for a compromise after php2shell.

PHP suggests keeping session.upload_progress.enabled = 0 after patching too, because the feature is rarely used and rarely tested. If you set memory_limit = -1, put it back to a normal value such as 256M. A low post_max_size can stay.