PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36 were released today as security releases. The pre-announcement said that the issues rated CRITICAL “require either non-default configuration or uncommon setups.” The ChangeLog only lists advisory titles, so I went through all 17 advisories with Claude to see what those configurations are, and whether my servers have them.
The statement holds for most of the seven CRITICAL advisories. I think it is generous for two of them:
- The PHP-FPM request smuggling needs the web server to reuse FastCGI connections. That is not the default, but it is a common tuning.
- The magic method backtrace use-after-free
(PHP 8.5 only) is reachable with the built-in defaults. It is
php.ini-productionthat setszend.exception_ignore_args = Onand closes that path, so an installation running without aphp.iniis exposed.
Below are the checks I ran. The paths are for PHP 8.4 with PHP-FPM as
packaged on Debian; adjust to taste. I use
ripgrep, but grep -rnE works with
the same patterns.
FastCGI connection reuse
rg -n 'fastcgi_keep_conn' /etc/nginx/ rg -n 'enablereuse' /etc/apache2/
The request smuggling advisory
(GHSA-qc49-hpvq-g2w6)
requires a front end that keeps its connection to PHP-FPM open between
requests: fastcgi_keep_conn on in nginx, enablereuse=on with Apache
mod_proxy_fcgi, or a HAProxy FastCGI backend that retains connections. It
also requires an application that opens php://input without reading it to
the end, which according to the advisory can happen in frameworks before
routing or authentication.
This is the one I would treat as an emergency. It is a single unauthenticated request with no memory corruption involved. If either command finds an active setting, turn it off until PHP is upgraded.
PHP and FPM settings
One command covers the settings that the other advisories depend on, including per-pool overrides:
rg -n \ -e '^\s*error_log' \ -e '^\s*(catch_workers_output|pm\.status_path)' \ -e '^\s*session\.upload_progress\.enabled' \ -e '^\s*session\.(serialize|save)_handler' \ -e '^\s*session\.save_path' \ -e '^\s*zend\.exception_ignore_args' \ -e '^\s*(fatal_error_backtraces|date\.timezone)' \ -e '^\s*php_(admin_)?(value|flag)\[' \ /etc/php/
What to look for in the output:
error_loginphp.ini,conf.dor asphp_admin_value[error_log]in a pool. The timezone cache use-after-free requires a warning or deprecation at startup that is written through PHP’s own file-based error log. Theerror_loginphp-fpm.confis FPM’s own log, and the advisory says it does not meet the condition by itself. I got this wrong on the first pass and checked the FPM log only.session.upload_progress.enabledshould be0. No match means it is enabled, as that was the default until these releases. It is the entry point for the session serializer mismatch and one of the entry points for the partially overwritten session files. It must be set administratively, asini_set()in the application is too late.session.serialize_handlershould have the same value in every match, including the CLI configuration, if anything there reads the same session store.catch_workers_output = yesenables the FPM local privilege escalation, which takes code execution in a worker to the user of the FPM master, commonly root. The default isno, but the advisory notes that the official Docker images enable it.pm.status_pathenables the status page that the status endpoint XSS targets. Restricting access to the page does not help, as the payload is planted through an ordinary request to the application.- On PHP 8.5 only:
zend.exception_ignore_argsshould beOn, orfatal_error_backtracesshould beOff. The latter also covers the second backtrace use-after-free.
To see whether PHP produces startup diagnostics at all, restart FPM and look at the logs:
systemctl restart php8.4-fpm.service journalctl --no-pager -u php8.4-fpm.service -S '1 minute ago'
Check also the file named by PHP’s own error_log, if one is set.
Loaded modules
php-fpm8.4 -m | rg -i '^(curl|soap)$'
Without soap the two SOAP advisories
(GHSA-4646-p932-gw34,
GHSA-q23r-hr55-xmpg)
do not apply.
With curl loaded, applications that prefer it stay away from PHP’s HTTP
stream wrapper, which is where two of the HIGH advisories live. As far as I
know, both WordPress and phpMyAdmin use curl when it is available.
Application code
The remaining checks are searches of the application tree. I ran them
against wp-content of each WordPress site.
rg -n "(file_get_contents|fopen)\s*\(\s*['\"]?https?:" /path/to/wp-content
This finds calls through the HTTP stream wrapper, which are affected by the
mixed-case HTTPS scheme
issue (a URL starting with HTTPS:// is sent without TLS) and the
folded response header
denial of service. The pattern only matches literal URLs. Calls that build
the URL in a variable need a looser pattern and more reading. In both cases
the attacker must control the server being fetched or be able to observe the
traffic, so a fixed lowercase https:// URL to a vendor is not much of a
finding.
find /path/to/site -name '*.pubkey'
The
Phar signature bypass
only matters for OpenSSL-signed Phar archives, which have a .pubkey file
next to them.
rg -n 'Dom\\(XML|HTML)Document' /path/to/wp-content
The
DOM double free
(PHP 8.4 and 8.5) requires code that parses untrusted input with the new
Dom\XMLDocument or Dom\HTMLDocument classes and calls saveXml().
What the checks do not cover
- The use-after-free after interrupted session shutdown (PHP 8.3 and later) depends on application code raising a fatal error inside a session cleanup callback. I do not know of a way to rule it out from configuration. Code execution has not been demonstrated.
- The
partially overwritten session files
issue affects the default
fileshandler regardless of upload progress, if the application stores large attacker-controlled strings in sessions. The advisory describes interrupting the write on threaded builds. - Settings changed at runtime with
ini_set()or.user.inido not show up in/etc/php. - The
PHP-CGI advisory
applies to
php-cgionly, and the URI serialization advisory to the newUri\Rfc3986\Uriclass in PHP 8.5 only. I run neither.
Results
None of the 17 advisories turned out to be reachable on the PHP 8.4 servers I checked, so the upgrade can wait for the normal maintenance window. Had I not disabled session upload progress after the October releases, the answer would have been less comfortable.
Two things to keep in mind for the upgrade itself. Distributions that backport fixes will not show 8.4.28 as the version. And the fixed releases disable session upload progress by default and reject runtime changes to session settings while it is enabled, so an application that relies on either needs testing.
The searches also turned up things that have nothing to do with these releases:
- Plugins ship PHP files that were never meant to be requested: a PHPUnit
test in a vendored library (HTTP 500, as there is no PHPUnit to extend),
and a theme downloader that its author had disabled with an
exit;on line 10. Both were harmless, but both were executed. Denying.phpunder pluginvendor/andtests/directories in the web server would be tidier. - A plugin that bundles its own
fopen()based HTTP transport showed up only through warnings in an old log file, as it builds its URLs in variables. - A backup plugin kept its archives and logs under
wp-content, protected by an.htaccessfile.nginxdoes not read those. A log file came back with HTTP 200 from the outside. The directory has no index and the file names contain a random hash, but that is not much to rest a database dump on. The fix is alocation ^~ /wp-content/<directory>/ { deny all; }block, and a cache invalidation if a CDN is in front.