CVE-2026-129496
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
PHP is a general-purpose scripting language used mostly for web development. It runs behind web servers through server APIs such as Apache mod_php and PHP-FPM, and powers content management systems and frameworks such as WordPress, Drupal, Moodle and Laravel. When error_log points to a file, PHP prefixes each logged message with a timestamp formatted in the configured timezone, which it resolves through a per-request timezone cache in the date extension.
A Use After Free vulnerability (CVE-2026-129496) has been identified in how PHP formats error log timestamps outside a request, which allows a diagnostic logged during process startup to leave a reference to a freed timezone cache that a later diagnostic, raised early in request initialization, reads or modifies. On affected configurations a remote attacker can corrupt memory, crash a worker and potentially execute code with the privileges of the PHP worker. The PHP project tracks this issue as GHSA-gr4f-wgx5-jpfv.
Per MITRE CWE-416: The product reuses or references memory after it has been freed.
This issue affects all versions of PHP before 8.2.36, PHP 8.3 before 8.3.37, PHP 8.4 before 8.4.28 and PHP 8.5 before 8.5.13, which includes the End-of-Life release lines PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 through their final releases.
Details
Module Info
- Product: PHP
- Affected packages: php-src (main, ext/date)
- Affected versions: <8.2.36, >=8.3.0 <8.3.37, >=8.4.0 <8.4.28, >=8.5.0 <8.5.13
- GitHub repository: https://github.com/php/php-src
- Published packages: https://www.php.net/downloads
- Package manager: N/A
- Fixed in:
- OSS PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13
- NES for PHP
Vulnerability Info
This Critical-severity vulnerability is found in all versions of PHP before 8.2.36, PHP 8.3 before 8.3.37, PHP 8.4 before 8.4.28 and PHP 8.5 before 8.5.13, which includes the End-of-Life release lines PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 through their final releases. The PHP project scores it 9.2 under CVSS 4.0 (CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N). The PHP project also classifies it as CWE-459, Incomplete Cleanup.
php_log_err_with_severity() formats the timestamp for file-based error logs. In a non-thread-safe build it always asks for local time, which makes the date extension allocate its timezone cache on first use. In PHP 8.5.12, the code reads:
#ifdef ZTS
if (!php_during_module_startup()) {
error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1);
} else {
error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 0);
}
#else
error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1);
#endif
A diagnostic emitted during module startup, such as the warning for an invalid date.timezone value or a warning or deprecation caused by session configuration, makes PHP allocate the cache in temporary startup memory. That memory is released at the end of startup, but the cache pointer stays set until the date extension initializes the first request. A diagnostic raised before that, such as the warning produced when request input exceeds max_input_vars, then reads or modifies a freed hash table, and the released memory may already hold attacker-controlled request data.
The startup diagnostic must be written through PHP's file-based error_log path; PHP-FPM's own error log does not meet this condition by itself. In PHP-FPM and Apache mod_php, workers can inherit the stale reference from the parent process, and the window lasts until a worker completes its first normal request, so new and recycled workers can be exposed again. The issue was also reproduced with CGI.
A crafted HTTP request has been shown to crash an FPM worker with the default max_input_vars value. Native command execution was demonstrated locally in PHP-FPM and in Apache mod_php with known memory addresses and additional configuration assumptions. A complete remote bypass of address space layout randomization has not been demonstrated. Exploitation does not require application-level code execution or attacker control of PHP_VALUE or PHP_ADMIN_VALUE.
The advisory lists the supported branches. The final releases of the End-of-Life PHP 5.6 through 8.1 lines contain the same logging code and the same lazily allocated timezone cache, so they may be affected in the same way.
The fix formats error log timestamps in UTC unless a request is fully initialized and active, so request-local timezone state is not used at unsafe points in the lifecycle:
time(&error_time);
error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, PG(modules_activated) && EG(active));
Mitigation
The PHP project publishes security fixes only for its supported release lines. PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1 are End-of-Life and will not receive any public updates to address this issue.
Until an upgrade is possible, correct configuration errors and deprecated settings that produce startup diagnostics, then restart the PHP master process and all workers. Sending PHP errors to a destination that does not use the file timestamp path, such as syslog, also avoids the demonstrated trigger. Changing request variable or cookie settings is not a complete mitigation.
Users of the affected components should apply one of the following mitigations:
- Upgrade to PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13, or later.
- Leverage a commercial support partner like HeroDevs (NES for PHP) for post-EOL security support.
Credits
- Sebastian Bergmann (finder)
- Go Kudo (finder)
- Ilija Tovilo (remediation)