Critical PHP2Shell: two unauthenticated RCE flaws in PHP itself. Fixes shipped on 21 Oct 2026. Check if you are affected →
← All news

PHP Timezone Cache Use-After-Free (CVE-2026-129496): A Startup Warning in Your Error Log Can Open the Door to RCE

Another critical fix in PHP's November 19, 2026 security releases: if PHP writes a startup diagnostic to a file-based error_log, fresh FPM, mod_php or CGI workers can touch a freed timezone cache, letting a crafted request crash the worker or potentially run code. Fixed in 8.5.13, 8.4.28, 8.3.37 and 8.2.36; the bug dates back to PHP 5.3.18.

PHP's November 19, 2026 security releases (8.5.13, 8.4.28, 8.3.37 and 8.2.36) include a critical memory-safety fix in the date extension: CVE-2026-129496, published as GitHub advisory GHSA-gr4f-wgx5-jpfv. It is a use-after-free (CWE-416) in PHP's timezone cache, rated critical with a CVSS v4 vector of AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H.

The interesting part is the trigger: an ordinary configuration warning written to a log file.

What goes wrong

When PHP writes to a file-based error_log, it formats the timestamp using the configured timezone. According to the advisory, in non-thread-safe (NTS) builds:

  1. A diagnostic emitted during module startup makes PHP allocate the timezone cache in temporary startup memory.
  2. That memory is released when startup ends, but the internal pointer to the cache survives until the date extension initialises the first request.
  3. If another diagnostic fires early in request initialisation — for example the warning when input exceeds max_input_vars — PHP reads or modifies the freed hash table. By then that memory may hold attacker-controlled request data.

In PHP-FPM and Apache mod_php, workers inherit the stale pointer from the parent process. The window stays open until a worker finishes its first normal request, and newly spawned or recycled workers hit the same state again. It has also been reproduced with CGI.

What triggers it in practice

The advisory names confirmed startup triggers:

  • an invalid date.timezone value;
  • a warning or deprecation caused by session configuration.

The diagnostic must actually go through PHP's file-based error_log path. FPM's own error log does not, by itself, meet the condition.

Impact

  • A crafted HTTP request has been shown to crash an FPM worker using the default max_input_vars and ordinary nginx header limits.
  • Native command execution was demonstrated locally in both FPM and Apache mod_php, with known runtime addresses and a suitable heap layout. The FPM chain used extra settings (auto_globals_jit=0, cookies in request_order, an oversized Authorization header). The Apache variant used a POST exceeding a 2 MB memory_limit and needed neither the cookie nor the auto_globals_jit changes.
  • ASLR stayed enabled in these proofs. The advisory calls a remote ASLR bypass plausible but not demonstrated.
  • No authentication, application-level code execution or control of PHP_VALUE/PHP_ADMIN_VALUE is required.

The bug was reported by Sebastian Bergmann (who wrote it up as "The wrong crash"), mbossard-wm and zeriyoshi, and fixed by Ilija Tovilo.

Affected versions

Everything before 8.2.36, 8.3.37, 8.4.28 and 8.5.13. Based on code inspection, the vulnerable code has existed since PHP 5.3.18 and 5.4.8, with an earlier form in 5.2.10, 5.2.12–5.2.17 and 5.3.0–5.3.8. That means essentially every PHP 5.x, 7.x and end-of-life 8.x install is affected and will get no upstream fix.

The fix

The patch changes php_log_err_with_severity() in main/main.c so that outside a fully initialised, active request, error log timestamps are formatted in UTC and request-local timezone state is left alone. One visible side effect: log lines written during startup may now show UTC times.

What to do

  1. Upgrade to 8.5.13, 8.4.28, 8.3.37 or 8.2.36 (or your distribution's patched package), then restart the PHP-FPM master and every worker, or Apache.
  2. If you can't upgrade yet, look in your PHP error log for warnings or deprecations logged at startup. Fix them — an invalid date.timezone, deprecated session settings — and restart the master process and all workers.
  3. Alternatively, send PHP errors somewhere that doesn't use the file-timestamp path, such as error_log = syslog, which avoids the demonstrated trigger.
  4. Don't rely on changing $_REQUEST or cookie settings. The advisory says that is not a complete mitigation, because the Apache cleanup path doesn't need them.

A quick check worth running on any server: restart PHP and see whether anything appears in the PHP error log before the first request. A clean startup log is good hygiene anyway, and here it also removes the precondition for this bug.


If you're stuck on PHP 5.x, 7.x or an end-of-life 8.x branch that won't receive this fix, RescuePHP can help audit your configuration for the trigger conditions, backport the patch to your build, or plan a safe upgrade path.