Skip to content
Timezone cache use-after-free can lead to remote code execution

Timezone cache use-after-free can lead to remote code execution

Github • November 19, 2026

PHP can retain a reference to a freed timezone cache when a diagnostic is written to a PHP error log file during process startup. A later diagnostic during early request initialization can access the freed cache before it is reset. On affected configurations, a remote attacker can trigger memory corruption, cause a worker to crash, and potentially execute arbitrary code with the privileges of the PHP worker.

PHP formats file-based error log timestamps using the configured timezone. In a non-thread-safe build, a diagnostic emitted during module startup can cause PHP to allocate the timezone cache in temporary startup memory. That memory is released at the end of startup, but the internal reference to the cache remains until the date extension initializes the first request. An earlier diagnostic, such as the warning produced when request input exceeds max_input_vars , can therefore read or modify a freed hash table. The released memory may already contain attacker-controlled request data.

The startup diagnostic must occur late enough that subsequent initialization does not clear the cached reference. Confirmed examples include an invalid date.timezone value and a warning or deprecation caused by session configuration. The diagnostic must actually be written through PHP's file-based error_log path. FPM's own error log does not by itself meet this condition.

In FPM and Apache mod_php, workers can inherit the stale reference from the parent process. The vulnerable window lasts until a worker completes its first normal request. Newly created or recycled workers can encounter the same condition. A crafted HTTP request has been shown to crash an FPM worker using the default max_input_vars value and ordinary nginx header limits. The issue has also been reproduced with CGI.

A separate local FPM proof demonstrated native command execution with known runtime addresses. It uses early HTTP Basic credential decoding to replace the stale cache, then reuses request-data allocations and triggers their destruction while $_REQUEST is constructed. That particular chain requires additional configuration, including auto_globals_jit=0 and cookies in request_order , a suitable heap layout, and an Authorization header larger than nginx's default per-header limit. These are conditions of the demonstrated exploit, not general requirements of the underlying memory-corruption flaw. Other exploitation paths may be possible.

Native command execution has also been demonstrated in Apache mod_php. Besides the same GET/COOKIE chain, Apache has a separate path when request startup fails before the cache is reset. Request cleanup can destroy the forged cache and invoke an attacker-controlled destructor. The demonstrated variant uses a POST that exceeds a configured 2 MB PHP memory limit and requires known runtime addresses, a suitable heap layout, and a larger allowed Authorization header. It does not require cookies or changes to auto_globals_jit or request_order . ASLR remained enabled during these proofs. A remote ASLR bypass is plausible, although a complete independent bypass has not been demonstrated.

An unauthenticated remote attacker may be able to crash PHP workers or execute arbitrary code with their privileges on an affected deployment. The trigger requires a suitable startup diagnostic, PHP error logging to a file, and an early request diagnostic in a fresh worker. Code execution has been demonstrated locally in FPM and Apache mod_php with known addresses and additional configuration assumptions. Successful exploitation does not require application-level code execution or attacker control of PHP_VALUE or PHP_ADMIN_VALUE .

Upgrade to PHP 8.2.36, 8.3.37, 8.4.28, or 8.5.13 when the corresponding release is available. The fix formats error log timestamps in UTC outside a fully initialized active request, avoiding use of request-local timezone state at unsafe points in the lifecycle.

Until an update can be deployed, correct configuration errors and deprecated settings that produce startup diagnostics, then restart the PHP master process and all workers. Sending PHP errors to a suitable logging destination that does not use this file-timestamp path, such as syslog, also avoids the demonstrated trigger. Changing $_REQUEST or cookie settings is not a complete mitigation. The demonstrated Apache cleanup path does not require those settings.

Extracted Entities

Attack Types (1)

CWE Weaknesses (1)

Platforms (3)

Tools (1)