Remediating PHP2Shell on Ubuntu Instances in AWS

Context

PHP2Shell is the name given to two critical vulnerabilities in the PHP interpreter, tracked as CVE-2026-109618 and CVE-2026-109619. Both are rated 9.2 on CVSS v4.0. An unauthenticated attacker can exploit them remotely to run arbitrary code on the server.

The flaws are in PHP itself, not in a specific application. Any system that uses PHP to serve web requests is therefore exposed, regardless of the framework or content management system it runs. Technical details were disclosed before the fixes were released, public proof-of-concept code is available, and exploitation attempts have been reported. Updating PHP is the only complete remedy, and it should be done without delay.

How to get the fixes

If you run a supported Ubuntu release (22.04 LTS or later), the fixes are available through the standard Ubuntu archive. Apply them with a regular update:

sudo apt update
sudo apt upgrade

Restart any service that uses PHP, such as Apache, PHP-FPM or Nginx with PHP-FPM, so that it loads the patched version.

If you run an Ubuntu LTS release whose standard support period has ended, the fixes are delivered through Expanded Security Maintenance (ESM), which requires an Ubuntu Pro subscription. For the oldest releases, Canonical provides the Legacy add-on, which extends security coverage up to 15 years from the original release date.

In practice:

  • Ubuntu 18.04 LTS and 20.04 LTS: attach the system to Ubuntu Pro to receive the patches.
  • Ubuntu 14.04 LTS and 16.04 LTS: an Ubuntu Pro subscription with the Legacy add-on is required.
Release Package Name Remediation status Fix availability
Trusty (14.04) php5 Fixed in 5.5.9+dfsg-1ubuntu4.29+esm18 Needs Legacy Add-on
Xenial (16.04) php7.0 Fixed in 7.0.33-0ubuntu0.16.04.16+esm22 Needs Legacy Add-on
Bionic (18.04) php7.2 Fixed in 7.2.24-0ubuntu0.18.04.17+esm14 Needs Ubuntu Pro subscription
Focal (20.04) php7.4 Fixed in 7.4.3-4ubuntu2.29+esm5 Needs Ubuntu Pro subscription
Jammy (22.04) php8.1 Fixed in 8.1.2-1ubuntu2.28 Available by regular updates
Noble (24.04) php8.3 Fixed in 8.3.6-0ubuntu0.24.04.13 Available by regular updates
Resolute (26.04) php8.5 Fixed in 8.5.4-0ubuntu1.5 Available by regular updates
Stonking (26.10) php8.5 Fixed in 8.5.9-0ubuntu2.1 Available by regular updates

To confirm that a system has the fix, compare the installed package version with the table above:

dpkg -l | grep php

How to get Ubuntu Pro on AWS

There are two ways to get Ubuntu Pro on AWS. Ubuntu Pro on AWS is billed through your AWS account, on an hourly basis, with no separate contract with Canonical.

Option 1: Launch a new Ubuntu Pro instance and redeploy

Launch a new EC2 instance from an Ubuntu Pro image, available in the EC2 console and in AWS Marketplace, then redeploy your application on it. The instance is attached to Ubuntu Pro automatically at boot, and ESM updates are available immediately.

This option lets you build and test the new environment in parallel with the existing one, and switch traffic only when you are ready. It is the recommended approach when your deployment is automated or can be rebuilt with reasonable effort.

Option 2: In-place conversion of an existing instance

If you cannot redeploy, you can convert a running Ubuntu LTS instance to Ubuntu Pro without replacing it. AWS License Manager provides a license type conversion that changes the instance’s billing from Ubuntu LTS to Ubuntu Pro. The instance keeps its data, configuration and network settings.

The general steps are:

  1. Make sure the instance is managed by AWS Systems Manager (the SSM Agent is installed and the instance has the required IAM role).

  2. In AWS License Manager, create a license type conversion for the instance, from Ubuntu LTS to Ubuntu Pro.

  3. Start the machine, and confirm that ESM is enabled:

pro status
  1. Apply the updates and restart the services that use PHP, as described above.

Note: Take a snapshot or backup of the instance before you start, so that you can recover if anything goes wrong.

How to get the Legacy add-on

The Legacy add-on extends an Ubuntu Pro subscription and is required for Ubuntu 14.04 LTS and 16.04 LTS. It is not yet available as a self-service option, but you can obtain it by contacting the Canonical team at aws@canonical.com. The transaction and billing can be processed through AWS Marketplace, which is ideal if you want to draw down existing AWS commitments or consolidate charges onto a single AWS bill.

Once the add-on is active, attach the system to Ubuntu Pro, apply the updates and restart the services that use PHP.

Learn more about this:

2 Likes

After installing 8.3.6-0ubuntu0.24.04.13 on 24.04 and rebooting etc. the command php -v still reports 8.3.6 which and the date of build is displayed as 19th October. The dpkg query points to the correct package, though.

This led to a team discussion, because another team member checked the version and claimed that if it does not show 8.3.36 then it is not the correct version that contains the fix. This is also because the CVEs officially declare PHP versions below 8.3.36 as not fixed.

I am now unsure about this and I’d like a clarification on this.

Hi, that is normal.
In any Ubuntu LTS, you have libraries that won’t update to newer versions to avoid breaking changes. So this is indeed (and still) 8.3.6 but with the patch included.

Some security scanners are aware of this nuance that sits at package level, while other don’t, but that version does contain the fix.

To keep track of these changes, I suggest everyone to always double-check in our Ubuntu Security Notices site.