How to Audit and Safely Remediate Critical PHP Vulnerabilities on Ubuntu
Running php -v is not a complete PHP security audit. It reports only the default command-line interpreter. Apache may serve one website through PHP-FPM and another through CGI, while cron jobs and queue consumers use explicit PHP binaries.
This guide provides a change-controlled process for auditing and remediating critical PHP vulnerabilities on a multi-version Ubuntu server using Apache, PHP-FPM and hosting control panels such as ISPConfig and cPanel/WHM. It is written for Magento and PHP application owners, Linux administrators and agencies responsible for shared hosting infrastructure.
Executive summary
A defensible remediation inventories every installed and active runtime, maps each domain and background task to the PHP binary it actually uses, verifies the complete vendor package revision, simulates changes, updates supported branches, and tests the affected applications. Remove an old branch only after proving that no website, scheduled job, consumer or deployment process uses it.
Risk and affected runtimes
On 21 October 2026, the PHP project published fixes for CVE-2026-109618 and CVE-2026-109619. Its advisory describes unauthenticated remote-code-execution risk affecting web-serving PHP SAPIs, including PHP-FPM, Apache module deployments and PHP-CGI.
| PHP branch | First upstream fixed release | Security support ends |
|---|---|---|
| 8.2 | 8.2.35 | 31 December 2026 |
| 8.3 | 8.3.36 | 31 December 2027 |
| 8.4 | 8.4.27 | 31 December 2028 |
| 8.5 | 8.5.12 | 31 December 2029 |
These values were checked on 23 October 2026 against the official PHP security announcement and PHP supported-versions table. Recheck the advisory before a live change. PHP 8.1 and older no longer receive upstream PHP releases; any vendor backport must be confirmed from the vendor advisory and exact package revision.
Safe read-only audit procedure
Record the OS and package sources
READ-ONLY
cat /etc/os-release
uname -a
grep -RhE '^[[:space:]]*deb |^Types:|^URIs:|^Suites:|^Components:' \
/etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null
apt-mark showhold
Record whether each branch comes from Ubuntu or an additional repository. Ubuntu security status does not automatically apply to an independently built package.
Inventory installed packages
READ-ONLY
dpkg-query -W \
-f='${binary:Package}\t${db:Status-Status}\t${Version}\n' \
'php*' 'libapache2-mod-php*' 2>/dev/null | \
awk '$2 == "installed"' | sort
Keep the complete package revision. The distribution suffix can prove that a backported fix is present even when the shortened upstream version has not changed.
Inventory CLI and CGI interpreters
READ-ONLY
type -a php php-cgi 2>/dev/null
php -v
php-cgi -v 2>/dev/null
update-alternatives --display php 2>/dev/null
update-alternatives --display php-cgi 2>/dev/null
for binary in /usr/bin/php[0-9].* /usr/bin/php-cgi[0-9].*; do
[ -x "$binary" ] && "$binary" -v | head -n 1
done
Inventory PHP-FPM services, pools and sockets
READ-ONLY
systemctl list-unit-files 'php*-fpm.service'
systemctl --type=service --state=running 'php*-fpm.service'
ps -eo pid,user,cmd | grep -E '[p]hp-fpm'
ss -lxnp | grep -E 'php|fpm'
find /etc/php -path '*/fpm/pool.d/*.conf' -type f -print
grep -RHE '^[[:space:]]*(listen|user|group)[[:space:]]*=' \
/etc/php/*/fpm/pool.d 2>/dev/null
Inspect Apache and hosting control-panel mappings
READ-ONLY
apache2ctl -M | grep -E 'php|proxy_fcgi|fcgid'
apache2ctl -S
grep -RHE \
'SetHandler|proxy:unix:|FcgidWrapper|Action[[:space:]].*php|FilesMatch' \
/etc/apache2/sites-enabled /etc/apache2/conf-enabled 2>/dev/null
Mappings may use an FPM socket, an FcgidWrapper, a CGI action or mod_php. Review the PHP mode and version assigned to every website in the hosting control panel. In ISPConfig, check the website's PHP mode, selected PHP version and generated vhost or pool. In cPanel/WHM, verify the domain assignment in MultiPHP Manager and the installed PHP packages or profiles managed through EasyApache.
These control panels do not necessarily use the same package names or update workflow. Use the panel and package source that owns the runtime; do not apply the Ubuntu APT examples blindly to cPanel-managed PHP. Where a panel owns generated configuration, change its source setting instead of maintaining a manual edit that may be overwritten.
Check scheduled and background workloads
READ-ONLY
systemctl list-timers --all
grep -RlE 'php([0-9]+\.[0-9]+)?' \
/etc/cron.d /etc/cron.daily /etc/systemd/system 2>/dev/null
ps -eo user,pid,etime,cmd | \
grep -E '[p]hp|[c]onsumers:start|[c]ron:run'
Review user crontabs through the approved administrative process, but do not publish their contents. Commands can expose private paths, account names or tokens.
Domain-to-runtime mapping example
| Workload | Mapping | Runtime | Evidence |
|---|---|---|---|
shop.example.test | Vhost to FPM socket | PHP 8.3 FPM | Package, pool and process |
legacy.example.test | CGI wrapper | PHP 8.2 CGI | Wrapper and package revision |
| Magento cron | Explicit CLI command | PHP 8.3 CLI | Command and binary |
| Queue consumers | Process manager | PHP 8.3 CLI | Unit and restarted process |
The mapping is complete only after every public website, cron job, queue consumer and deployment command has an identified runtime.
Backup and rollback checklist
- Create and verify a provider or hypervisor snapshot.
- Back up application code, media and databases outside the web root.
- Back up Apache, PHP-FPM, cron, systemd and hosting-control-panel-managed configuration.
- Record exact package revisions, active services, sockets and alternatives.
- Test that backups can be listed or restored in an isolated environment.
- Define the approval gate, maintenance window, rollback owner and acceptable downtime.
- Confirm whether old packages remain available, but do not rely on a package downgrade as the only rollback method.
Supported-branch update procedure
The APT examples below apply to PHP installed from compatible Debian or Ubuntu repositories. If a control panel supplies and manages its own PHP packages, use that vendor's supported update workflow after performing the same inventory, simulation, backup and approval checks.
Confirm that the installed application supports its PHP branch. Magento operators should check Adobe's current Commerce system requirements. Do not introduce a PHP branch migration as an unplanned side effect of an emergency point-release update.
STATE-CHANGING: refreshes local APT metadata only
sudo apt-get update
Stop if APT reports an invalid signature, unavailable repository or release error.
READ-ONLY: build an explicit list of installed branch packages
mapfile -t PHP_PACKAGES < <(
dpkg-query -W \
-f='${binary:Package} ${db:Status-Status}\n' \
'php8.3*' 'libapache2-mod-php8.3' 2>/dev/null | \
awk '$NF == "installed" {print $1}' | sort -u
)
printf '%s\n' "${PHP_PACKAGES[@]}"
SIMULATION: does not install packages
sudo apt-get --simulate install --only-upgrade \
"${PHP_PACKAGES[@]}"
Investigate a proposal that changes branches, removes unrelated packages, changes Apache integration, selects an unapproved repository or leaves an affected SAPI below the fixed revision.
STATE-CHANGING: only after backup, simulation and approval
sudo apt-get install --only-upgrade \
"${PHP_PACKAGES[@]}"
--only-upgrade limits the requested package names to already-installed packages. Dependencies can still change, so the simulation is an essential approval artifact. Avoid replacing this targeted transaction with a broad OS upgrade.
Vendor backports and end-of-life considerations
Ubuntu can backport security fixes while preserving the upstream version component. A scanner that checks only a PHP banner may therefore produce an incorrect result. Canonical explains this in its documentation for Ubuntu security updates and version banners.
Use the full installed revision, APT candidate, applicable security notice or OSV record, and package changelog. For a third-party repository, obtain evidence from that package maintainer. A temporary backport does not eliminate the need to migrate an end-of-life branch.
Safe retirement of an unused PHP version
Before removal, prove that the branch has no Apache mapping, hosting control-panel assignment, FPM pool, CGI wrapper, cron reference, systemd service, queue consumer, deployment script or active CLI alternative.
READ-ONLY
mapfile -t OLD_PHP_PACKAGES < <(
dpkg-query -W \
-f='${binary:Package} ${db:Status-Status}\n' \
'php7.4*' 'libapache2-mod-php7.4' 2>/dev/null | \
awk '$NF == "installed" {print $1}' | sort -u
)
printf '%s\n' "${OLD_PHP_PACKAGES[@]}"
SIMULATION: does not remove packages
sudo apt-get --simulate remove "${OLD_PHP_PACKAGES[@]}"
sudo apt-get --simulate autoremove
Review autoremove separately. Stop if either simulation includes an active PHP branch, Apache, ISPConfig dependencies or unexpected application packages.
STATE-CHANGING: controlled removal after approval
sudo apt-get remove "${OLD_PHP_PACKAGES[@]}"
Prefer remove before purge during the observation period. Never run autoremove without a separately reviewed package list. Verify the CLI and CGI alternatives afterward.
Verification procedure
READ-ONLY: validate before any reload
sudo apache2ctl configtest
sudo php-fpm8.3 --test
Do not reload Apache when its configuration test fails. Correct the authoritative configuration, test again and obtain approval for the service action.
STATE-CHANGING: restart the affected FPM branch
sudo systemctl restart php8.3-fpm
sudo systemctl is-active php8.3-fpm
A mod_php deployment normally requires an approved Apache restart to load the replaced module. CGI starts new interpreter processes but still requires endpoint validation. Restart only what the verified mapping requires.
READ-ONLY: confirm packages and active processes
dpkg-query -W -f='${binary:Package}\t${Version}\n' \
'php8.3*' 2>/dev/null | sort
php8.3 -v
php-fpm8.3 -v
systemctl --type=service --state=running 'php*-fpm.service'
ps -eo pid,lstart,cmd | grep -E '[p]hp-fpm'
READ-ONLY HTTP REQUESTS
curl -fsS -o /dev/null \
-w 'storefront %{http_code} %{time_total}s\n' \
https://shop.example.test/
curl -fsS -H 'Content-Type: application/json' \
--data '{"query":"{__typename}"}' \
https://shop.example.test/graphql
Use approved test endpoints. Never place a private administrative route, token or customer information in the transcript.
Magento-specific validation
Run commands as the application filesystem owner, not root, and invoke the intended PHP binary explicitly.
READ-ONLY
php8.3 bin/magento --version
php8.3 bin/magento indexer:status
php8.3 bin/magento cache:status
php8.3 bin/magento queue:consumers:list
composer check-platform-reqs
Test the storefront, category and product pages, search, login, cart and checkout to an approved point; expected GraphQL and REST calls; cron and consumers; payment, email and integrations in test mode; and Magento, Apache and PHP-FPM logs. Test an authenticated Admin workflow through the unpublished route.
Running cron, restarting consumers, compiling dependency injection or changing cache state modifies the application. Include these only where the reviewed deployment requires them.
Common mistakes and lessons learned
- Assuming CLI PHP is the version Apache serves.
- Checking FPM while overlooking CGI,
mod_php, cron or consumers. - Ignoring vendor backport revisions and relying only on the upstream banner.
- Changing branches unintentionally during an emergency update.
- Using a broad OS upgrade for a targeted remediation.
- Removing an old branch before reviewing the hosting control panel, vhosts and scheduled jobs.
- Running
autoremovewithout previewing every package. - Reloading Apache with invalid configuration.
- Assuming replaced packages are active without restarting long-running processes.
- Treating patching as a substitute for incident response.
Reusable final checklist
- Inventory CLI, CGI, FPM and Apache-module packages and processes.
- Map every website, cron job and consumer to its runtime.
- Verify full package revisions against the correct vendor advisory.
- Confirm application support for the PHP branch.
- Create and test backups, a snapshot and a rollback plan.
- Simulate the targeted update and obtain approval.
- Validate configuration before restarting affected services.
- Verify package revisions, active processes and application endpoints.
- Simulate old-branch removal and review
autoremoveseparately. - Escalate suspicious files through incident response.
- Record evidence before declaring remediation complete.
Primary references
- PHP security announcement, 21 October 2026
- PHP supported versions
- PHP 8 changelog
- Ubuntu security updates
- Ubuntu backport and version-banner guidance
- Ubuntu apt-get manual
- Apache apachectl documentation
- Adobe Commerce system requirements
Need help auditing or updating a Magento server?
Agile Codex can review PHP runtime mappings, package update scope, Magento compatibility and post-change validation through an existing support package.