PHP SECURITY
Patch PHP2Shell on Ubuntu or Debian with PHP-FPM
For an Ubuntu or Debian server, identify the package source and the PHP service used by the website before installing the distributor’s fixed packages. A successful package update must be followed by the correct service replacement and application checks; the command-line PHP version alone cannot close the change.

Advisory details checked on 22 October 2026. Recheck the linked vendor advisories before applying a production change.
Confirm this runbook matches your server
This guide is for an authorised administrator of a server whose PHP packages are managed through Ubuntu or Debian’s supported package channels. It is not a command list for Hostinger shared hosting, a cPanel EasyApache installation, a Plesk-provided runtime or a custom container. Those environments may use separate vendors, paths and service names. Establish the owner before changing software that a hosting control panel manages.
Prepare a recovery route you can actually use. Confirm that you can reach the management console if the web service fails, retain a current configuration copy and check that backups are recoverable. Record the maintenance owner and test contact. If there are signs of an active intrusion, preserve evidence and contain the service as part of incident response before making broad changes to the machine.
Read the operating system, packages and request path
Connect using the organisation’s approved administration method. The following inspection examples show the operating system and installed PHP-related packages. Package listings can include components that are not active; use them as an inventory, then map each public virtual host to its actual PHP service. Check the full package revision and repository origin, not only the first three version numbers.
cat /etc/os-release
dpkg-query -W -f='${Package}\t${Version}\n' 'php*' 2>/dev/null
systemctl list-units --type=service --all 'php*-fpm.service'
command -v php
php --versionRead the relevant web-server virtual-host configuration through your normal configuration management or administrator tooling. Identify whether the PHP request is sent to an FPM socket or handled through Apache mod_php. A machine can have both, and a command-line default selected through alternatives does not change a web-server socket. Document the domain, pool, service and package relationship so the update has an explicit target.
Use the correct fixed package mapping
Canonical’s advisory checked on 22 October lists Ubuntu 24.04’s PHP 8.3 fix as 8.3.6-0ubuntu0.24.04.13 and Ubuntu 22.04’s PHP 8.1 fix as 8.1.2-1ubuntu2.28. These examples demonstrate backporting: a lower-looking base version can contain the security change. Check the full current revision for your Ubuntu release and any required support entitlement; do not apply those revisions to a different distribution.
For Debian, the security tracker checked on the same date lists bookworm’s fixed PHP 8.2 source package as 8.2.35-1~deb12u1 and trixie’s fixed PHP 8.4 source package as 8.4.27-1~deb13u1 for both CVEs. Consult both current tracker entries and the relevant advisory. Testing, unstable and third-party repositories can have different status. The package candidate visible to your server must come from a channel you trust and that actually provides the relevant correction.
Check the candidate before applying the upgrade
The example below assumes Ubuntu 24.04 using its distribution PHP 8.3-FPM packages. Substitute only packages and service names already confirmed in your inventory. Read the proposed changes before proceeding. If the installed package is held, the security repository is absent, or the candidate comes from an unexpected vendor, investigate that condition instead of adding a random repository to make the numbers look current.
sudo apt update
apt-cache policy php8.3-fpm php8.3-common php8.3-cli
sudo apt upgrade --simulate
sudo apt upgradeA full supported upgrade may affect more than PHP, so plan its maintenance scope and review failures. Where a narrowly targeted update is necessary, obtain the complete package set and dependency instructions from your distributor or administrator; do not update only the convenient CLI package while leaving the web interpreter behind. Retain the transaction output and final package revisions in the change record.
If PHP came from an external repository, the distribution notice may not establish its patch status. Ask that supplier for its advisory, fixed build and ongoing support position. Decide whether to move to distribution packages as a controlled migration. Swapping package origins during an emergency without checking extension and configuration differences can create a second outage.
Replace the service that executes the requests
After installation, replace the serving PHP processes using the method appropriate to the identified handler. For the Ubuntu 24.04 PHP 8.3-FPM example, a controlled restart is shown below. Plan for interrupted requests and supervise recovery. If Apache uses mod_php, the Apache service is the relevant interpreter host; restarting only an unused FPM service would not address it. If multiple FPM versions serve sites, cover each affected service.
sudo systemctl restart php8.3-fpm
systemctl is-active php8.3-fpm
systemctl show php8.3-fpm -p MainPID -p ActiveEnterTimestamp -p ExecStart
journalctl -u php8.3-fpm --since "15 minutes ago" --no-pagerThe service timestamps and successful restart help demonstrate process replacement, but they do not identify the security content of the installed package. Use them alongside the vendor revision mapping. Where a load balancer or more than one server is involved, record the operation for every node and ensure a node that failed its update cannot silently rejoin later.
Verify PHP through the website’s actual handler
Use a protected operational diagnostic or existing application health mechanism to confirm the web request reaches the expected SAPI, pool and build. Do not publish a phpinfo page on the public internet to collect evidence. If a temporary diagnostic is unavoidable, restrict access before deployment, return only the minimum required fields and remove it afterwards. A cached homepage cannot tell you which interpreter processed the contact form.
| Check | What it establishes | What it does not establish |
|---|---|---|
| Vendor package revision | Installed files map to a documented fix | Every old process has exited |
| Service replacement record | The identified service started again | All domains use that service |
| Protected web-runtime check | The request reaches the intended handler | Every other node is also updated |
| Business transaction test | The changed application still behaves correctly | No earlier compromise occurred |
Treat disagreements as evidence to investigate. For example, a correct CLI revision with an older web build usually points to a second package, socket or deployment route. Do not suppress the mismatch just because the public page renders.
Test business functions and keep rollback secure
- Open an uncached dynamic page and inspect server errors, response status and latency.
- Test login, logout and session continuity where the site has accounts.
- Submit a non-sensitive test enquiry using an approved test mailbox and confirm the result.
- Exercise checkout in the payment provider’s test mode, never with invented live card details.
- Verify scheduled jobs, background consumers, required PHP extensions and application logs.
Define a fallback that does not simply restore the vulnerable interpreter. A corrected alternate pool, a compatible fixed image or a static maintenance response can be safer than an old snapshot reopened to the internet. If an application is incompatible, keep the affected service isolated while resolving the issue. Record the failed test and the chosen containment rather than marking the patch complete for administrative convenience.
Example: the command line is fixed but one site is not
Imagine a server with two websites: one uses the distribution FPM pool, while an older subdomain points at a second custom pool. An administrator updates PHP and verifies the shell version, but the subdomain continues using the other service. Mapping both virtual hosts to their sockets exposes the gap. The team updates the second runtime through its actual supplier, replaces its workers and retests the affected domain.
A good final record includes the distributor advisory, previous and final package revisions, repository origin, each runtime service, restart time and business test outcomes. Log retention and intrusion review remain separate tasks. This workflow provides evidence for patch deployment without pretending that an operating-system update is a complete hacked-website recovery investigation.
Frequently asked questions
Can I use Ubuntu’s fixed package number on Debian?
No. Match the operating-system release and package supplier to its own advisory. Debian and Ubuntu maintain different package revisions. The leading PHP version may look similar while the security maintenance history differs.
Why does Ubuntu show PHP 8.3.6 after the fix?
Distribution maintainers can backport security corrections into their maintained package branch. Verify the full Ubuntu revision and the vendor’s fixed-package mapping rather than judging the base version in isolation.
Is a successful apt upgrade enough?
No. Inspect whether the relevant packages actually changed, replace the serving processes and verify the domain-to-runtime mapping. A held package, a separate FPM version or another node can leave exposure unresolved despite a successful overall transaction.
Do I always have to restart Nginx?
Nginx and PHP-FPM are separate components in a typical FPM configuration. The PHP service must use the updated interpreter. Follow the vendor’s change instructions and restart or reload other components when their own packages or configuration require it; do not use an Nginx restart as a substitute for PHP verification.
Should I upgrade the whole PHP branch during the emergency?
Prefer the supplier’s supported security update for the current compatible branch when available. A branch migration can be appropriate but needs extension and application testing. Do not leave an unverified runtime public while waiting indefinitely for a perfect migration plan.
Can I prove the patch by sending an exploit request?
That is not needed for this runbook. Package provenance, the vendor fix mapping and evidence that the active service uses the new build provide a safer verification path. Destructive or unreviewed exploit tests can cause an outage and do not establish absence of earlier compromise.
Sources and further reading
Official documentation and advisories supporting the technical points above. The recovery workflows and examples are editorial guidance for adapting to your own systems.
- Canonical: PHP2Shell vulnerability fixes and Ubuntu package revisions — accessed 22 October 2026
- Debian security tracker: CVE-2026-109618 — accessed 22 October 2026
- Debian security tracker: CVE-2026-109619 — accessed 22 October 2026
- PHP-FPM configuration reference — accessed 22 October 2026
Get practical support for your next step.
Tell CyberXperts what happened, which systems are affected and what you have already checked. Do not include passwords or sensitive incident evidence in the initial form.
Discuss your website security