Patch PHP2Shell on Ubuntu and Debian
On Ubuntu and Debian, PHP comes from the distribution or from Ondřej Surý’s packages. The distribution backports the fix, so an ordinary security update is enough, and on Ubuntu the version number stays the same while only the package revision rises.
- You need
- root or sudo
- Updated
- By
- PXL
Fixed in
- Ubuntu 22.04: php8.1 8.1.2-1ubuntu2.28
- Ubuntu 24.04: php8.3 8.3.6-0ubuntu0.24.04.13
- Debian 12 (bookworm): php8.2 8.2.35-1~deb12u1
- Debian 13 (trixie): php8.4 8.4.27-1~deb13u1
- Ubuntu 20.04 and older: through Ubuntu Pro
Affected: Any Ubuntu or Debian server whose PHP packages predate the security update, including the versions these releases ship by default (for example PHP 8.1 on Ubuntu 22.04).
Update PHP
PHP comes from the distribution or from Ondřej Surý’s packages; pick the tab that matches your source. The distribution security update carries the fix, USN-8948-1 on Ubuntu, DLA-4848-1 on Debian 12 and DSA-6574-1 on Debian 13, and the Sury packages follow PHP’s own releases.
Ubuntu backports the fix to the PHP version it already ships, so the version number stays the same and only the package revision rises, so 8.1 stays 8.1 on 22.04. Check the revision: php8.1 8.1.2-1ubuntu2.28 on 22.04 and php8.3 8.3.6-0ubuntu0.24.04.13 on 24.04 (USN-8948-1).
sudo apt update && sudo apt upgradeUbuntu 20.04 and older need Ubuntu Pro
Ubuntu publishes the fix for PHP 7.4 on 20.04, PHP 7.2 on 18.04 and older releases only through Expanded Security Maintenance, which needs Ubuntu Pro. USN-8948-2 ships php7.4 7.4.3-4ubuntu2.29+esm5 on 20.04 and the matching +esm builds below it. Without Ubuntu Pro, move to a supported Ubuntu release.
pro statusBuild from source
If no package is available for your release, or you need the fix before your distribution ships it, build the fixed version for your branch from source. The main PHP build guide at /patched/php has the steps.
Reload PHP-FPM and restart workers
01Reload PHP-FPM, then restart any long-lived workers
Reload the service so it runs the updated binary, then restart Octane, Horizon, queue workers, Swoole or RoadRunner, which a package upgrade leaves running on the old binary.
sudo systemctl reload php8.3-fpm
Confirm the update
Compare the installed package with the fixed versions above. On Ubuntu the PHP version number doesn’t change, so check the package revision or look for the CVEs in the changelog.
dpkg -l "php*" | grep php
apt changelog php8.1 | grep -E "CVE-2026-10961[89]"