CVE-2026-129182: PHP use-after-free in last_fatal_error_backtrace after request shutdown (affects PHP 8.5.* before 8.5.13)

CVE-2026-129182 is a use-after-free in PHP involving last_fatal_error_backtrace. A fatal error raised while modified INI settings are restored during request shutdown can repopulate the stored fatal error backtrace after the executor has been cleaned up. The request memory is then freed, and a diagnostic emitted before executor initialization in a later request handled by the same PHP-FPM or mod_php worker can access the stale backtrace. This can cause memory corruption and worker crashes, and may allow remote code execution. Fixed in PHP 8.5.13.

Overview

CVE-2026-129182 affects PHP 8.5. before 8.5.13.

Per the NVD entry and PHP security advisory GHSA-2fjv-p558-g82m, the issue is a use-after-free via repopulation of the last_fatal_error_backtrace global after shutdown.

Trigger conditions

The shutdown error requires per-path configuration of one of the following:

- max_memory_limit - zlib.output_compression together with output_handler, which can also be set via .user.ini

The early diagnostic later requires either:

- Apache per-directory configuration, or - For PHP-FPM, a PHP_VALUE or PHP_ADMIN_VALUE parameter sent by the front end

Impact

- Memory corruption - PHP-FPM or mod_php worker crashes - Possible remote code execution

Fixed version

- PHP 8.5.13 or later

What to do

1. Identify all PHP workers running PHP 8.5. versions before 8.5.13, especially PHP-FPM and mod_php deployments. 2. Upgrade to PHP 8.5.13 or later. Test the upgrade in a staging environment before production rollout. 3. If an immediate upgrade is not possible, review the vendor advisory at https://github.com/php/php-src/security/advisories/GHSA-2fjv-p558-g82m and the NVD entry for any official mitigations or workarounds. 4. Audit your configuration for the trigger conditions: per-path max_memory_limit, zlib.output_compression combined with output_handler, .user.ini usage, Apache per-directory PHP settings, and front-end-supplied PHP_VALUE or PHP_ADMIN_VALUE parameters in PHP-FPM. Restrict or disable these where possible. 5. Monitor PHP-FPM/mod_php workers for unexpected crashes or memory-corruption indicators, and watch for further updates from the PHP project before changing production systems.

Sources