Upgrade to PHP 8.2.35, 8.3.36, 8.4.27 or 8.5.12 on Ubuntu, Debian, RHEL and Docker, restart every PHP worker, and verify both PHP2Shell fixes.
Updating to a fixed PHP release, or to a Linux distribution package that contains both fixes, is the only complete remediation for PHP2Shell (CVE-2026-109618 and CVE-2026-109619). Now that you have your inventory from the previous lesson, you are ready to patch your systems in order of exposure. You will start with internet-facing servers running Apache mod_php, move on to FastCGI Process Manager (FPM) pools and containers, restart every PHP worker process, and verify that the fix is active in memory.
Previous lesson: Find Every PHP Version and SAPI You Run | Next lesson: PHP2Shell Mitigations When You Cannot Patch Yet
The PHP project released four updated versions on 21 October 2026 to resolve both CVE-2026-109618 and CVE-2026-109619. If you install upstream PHP packages or use official container images, you must reach at least these versions.
| PHP Branch | Vulnerable Versions | Fixed Upstream Version | Official Release Status |
|---|---|---|---|
| PHP 8.5 | Before 8.5.12 | 8.5.12 | Fixed release available |
| PHP 8.4 | Before 8.4.27 | 8.4.27 | Fixed release available |
| PHP 8.3 | Before 8.3.36 | 8.3.36 | Fixed release available |
| PHP 8.2 | Before 8.2.35 | 8.2.35 | Fixed release available |
| PHP 7.4, 8.0, 8.1 | All versions | None (source backports only) | Check OS vendor for backports |
| PHP 5.4 to 7.3 | All versions | None | End-of-life, no fix from PHP |
Treat these versions as the minimum, not the target. On 19 November 2026, PHP released 8.2.36, 8.3.37, 8.4.28, and 8.5.13 with fixes for further critical session and request-handling flaws, so install the newest patch release on your branch.
Linux distributions and Long Term Support (LTS) vendors received the patches in advance. If you use distribution packages on Ubuntu, Debian, or Red Hat Enterprise Linux (RHEL), your package manager will keep the base version number (such as 8.1 or 8.2) and add the security fix as a backport. Check your vendor's current security notice for the exact package revision that contains the fix.
Take the three systems at Brightline Logistics as your patching order:
brightline-www: Public WordPress site on Ubuntu 22.04 with Apache mod_php and PHP 8.1. Patch this first because it is internet-facing and uses mod_php, which the PHP advisory considers the highest risk Server Application Programming Interface (SAPI).brightline-portal: Customer portal on PHP 8.3 with PHP-FPM and nginx, running in Docker. Patch this second by rebuilding the image.brightline-invoicing: Internal app on PHP 7.4 on RHEL 8. Handle this through vendor backports or end-of-life mitigation, which you will cover in Lessons 4 and 6.Patching without a clear priority order wastes critical minutes on low-risk internal tools while public web servers remain exposed.
On Linux virtual machines and bare-metal servers, use your system package manager to pull the patched packages from your distribution's security repository.
For brightline-www on Ubuntu 22.04, update the package index and upgrade all installed PHP 8.1 packages and the Apache module. The commands below modify your system packages.
bashCopy
If your Ubuntu or Debian server runs multiple PHP versions or uses PHP-FPM, upgrade all installed php* packages at once so you do not miss a secondary pool or Command Line Interface (CLI) binary:
bashCopy
On RHEL, Rocky Linux, and AlmaLinux systems, use dnf to apply the updated Red Hat Package Manager (RPM) packages:
bashCopy
Common Mistake: Relying on third-party repositories without checking their release status. The PHP advisory noted that the remirepo RPM repository would not have updates ready on release day and recommended using official distribution packages or building from source. If you use a third-party repository on Ubuntu or RHEL, verify the changelog after upgrading to make sure you actually received the fix.
Upgrading the packages on disk only completes half the job because running processes still hold the vulnerable code in memory.
When you upgrade a package on Linux, the files on disk change immediately. However, running processes like Apache, PHP-FPM, and background queue workers keep the old shared libraries loaded in RAM until those processes restart.
Think of patching PHP like updating the safety manual in a commercial kitchen. Replacing the binder in the manager's office does nothing until the cooks on the line stop, read the new rules, and start their next order using the updated steps.
Depending on which web server and SAPI you run, restart the corresponding service. These commands restart active services on your host.
bashCopy
If you run alternative SAPIs such as FrankenPHP or LiteSpeed, restart those server daemons as well.
Do not forget long-running CLI workers. While the CLI SAPI is not the direct vector for web exploitation, application workers managed by Supervisor or systemd (such as Laravel Horizon or Symfony Messenger consumers) should run the patched binary too.
bashCopy
Check the systemd status right after restarting to confirm the service started cleanly and shows a recent start timestamp:
bashCopy
A patch is not active until the process serving web requests has been restarted and its process start time is newer than the package installation time.
Containerized applications do not use apt or dnf on a live server. Instead, you must update the base image in your Dockerfile, rebuild the image, and replace every running container.
At Brightline Logistics, brightline-portal uses the official Docker image php:8.3-fpm. If your Dockerfile uses a floating tag like php:8.3-fpm, a normal build might reuse a cached, vulnerable layer stored on your Continuous Integration (CI) runner.
Pin the exact fixed version in your Dockerfile so no build machine can accidentally use an older release.
Before:
dockerfileCopy
After:
dockerfileCopy
If you use PHP 8.2, 8.4, or 8.5, pin to 8.2.36, 8.4.28, or 8.5.13 respectively. Next, build the image with the --pull flag to force Docker to check the registry for the latest base layers, and redeploy your containers:
bashCopy
Pro Tip: After redeploying across your cluster or Docker hosts, run docker ps on each node to ensure no old containers are still running alongside the new ones, and prune old images so a rollback script cannot accidentally launch the vulnerable build.
In a containerized environment, patching means replacing every running container instance from a newly built image.
If you run PHP on managed WordPress hosting, Platform-as-a-Service (PaaS) providers, or shared cPanel servers, you usually cannot run apt or dnf yourself. Many managed hosts deployed patches quickly after the 21 October 2026 release, but you must verify this for your specific account and plan.
Check your provider's status page or security bulletin for explicit mention of CVE-2026-109618 and CVE-2026-109619.
On every system you control, run a final verification check for both the CLI and the web SAPI.
First, for upstream builds and official Docker containers (brightline-portal), check the reported version number inside the running container:
bashCopy
Confirm the output shows 8.2.36, 8.3.37, 8.4.28, or 8.5.13, or a newer release. Versions 8.2.35, 8.3.36, 8.4.27, and 8.5.12 fix PHP2Shell but miss the security fixes released on 19 November 2026.
Second, for Linux distribution packages (brightline-www), verify that both CVE numbers appear in the installed package changelog:
bashCopy
Third, confirm that no running process still has the old PHP files loaded in memory. When a package upgrade replaces a file that a process is using, Linux marks the old copy as "(deleted)" in that process's memory map:
bashCopy
Each result is a path such as /proc/1234/maps, where 1234 is a process ID. Run ps -p 1234 -o pid,comm to see which service it belongs to. Any apache2, httpd or php-fpm process in this list is still running the old code and must be restarted.
Quick Challenge: What happens if the package changelog shows both CVE numbers, php -v shows the updated build date, but you forgot to run systemctl restart apache2 on brightline-www? The CLI binary is safe, and the files on disk are patched, but Apache's mod_php workers in RAM are still vulnerable to remote code execution.
Never close a patching ticket until you have verified the version or changelog and confirmed that no running worker is holding onto old libraries in memory.
Practice the verification workflow on a Linux server or container you manage using these safe, read-only commands:
bashCopy
bashCopy
bashCopy
If your system is not yet patched and you cannot upgrade it immediately due to change freezes or legacy dependencies, you need stopgap protections right away.
In the next lesson, PHP2Shell Mitigations When You Cannot Patch Yet, you will apply the official temporary configuration changes and request limits to reduce exposure on systems that cannot be patched immediately.
Was this lesson helpful?