← All field notes

How to Patch PHP2Shell on VMs, Container Images and Kubernetes

PHP2Shell is being exploited in the wild. Here is how to patch PHP on Debian, Ubuntu and RHEL servers, rebuild your container images, roll the fix out across Kubernetes, and prove it is actually running.

Dark cover image with the headline "Patch PHP2Shell the right way." and labels for VM, Docker image, Kubernetes rollout and verify, with the Turf Dev logo at the bottom.

PHP2Shell (CVE-2026-109618 and CVE-2026-109619) is being exploited in the wild, and the only complete fix is a patched PHP. This guide shows how to patch it on a VM, in a container image and across a Kubernetes cluster, and how to prove the fix is actually running.

If you missed the background, read our breakdown of the October 2026 2Shell attacks first.

Before you start: what “patched” means

Key point: A patched PHP only protects you once the fixed package is installed and every PHP process has been restarted.

The fixed upstream releases are PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35. Two things trip teams up:

  • Distro version numbers don’t change. Debian, Ubuntu and RHEL backport the fix into their own builds. A patched Ubuntu 24.04 server still reports PHP 8.3.6, so check the package release, not just the PHP version.
  • Installing the package is not enough. PHP-FPM workers, Apache children and LiteSpeed processes keep the old code in memory until you restart them.

PHP 7.4, 8.0 and 8.1 are end-of-life. Limited backports exist, but the durable fix is moving to a supported branch.

Part 1: Patch PHP on a VM

In short: Upgrade the PHP packages → restart PHP-FPM and Apache → check the package release.

Debian and Ubuntu

Step 1: Refresh the package lists.

shell
sudo apt update

Step 2: Upgrade every installed PHP package.

shell
sudo apt install --only-upgrade $(dpkg -l 'php*' | awk '/^ii/{print $2}')

Step 3: Restart PHP-FPM.

shell
sudo systemctl restart 'php*-fpm.service'

Step 4: Restart Apache, if you use mod_php.

shell
sudo systemctl restart apache2

1 of 4 sections shown

Anees Khan

Co-Founder & CTO at Turf Dev, focused on Kubernetes, platform engineering, cloud infrastructure, and production reliability. I write about real-world infrastructure problems, how we investigate them, and the engineering approaches used to solve them.

Meet Turf Dev ↗

Discussion

Have a question or something to add? Share it below.

Comments appear immediately. Please keep the discussion respectful.

No comments yet. Be the first to join the discussion.

Keep exploring

More from the field.

All articles ↗

Platform Mandate

Request Architecture Review

Review platform posture, reliability constraints, and cost governance priorities with an infrastructure engineering team.

Request Architecture Review