An orange traffic cone with a white reflective band lies on its side on grey asphalt. Dark tyre marks curve across the surface around it.
The cone was not standing where the impact was planned.

I did not find CVE-2026-129496 by looking for it. After PHP2Shell, I wrote down what its two bugs have in common as a rule that a program can check: once a request is over, nothing that outlives it may still point into its memory. Two weeks after the PHP2Shell release, a run that was supposed to confirm a bug I already knew crashed in the wrong place, and the check for that rule named the variable at fault.

The vulnerability is a use after free (CWE-416) bug in the timezone cache in PHP's date extension. It is rated 9.2 out of 10 and can lead to remote code execution. PHP 8.2.36, 8.3.37, 8.4.28, and 8.5.13 fix it and were released today. If you run PHP, update.

PHP2Shell was a class of bugs, and a class can be written down as a rule

On 21 October 2026, the PHP project fixed two critical vulnerabilities that became known as PHP2Shell:

  • CVE-2026-109618 is about what running out of memory leaves behind: PHP abandons the request with a longjmp(), and the code that cleans up the request later reads whatever was half built at that moment.
  • CVE-2026-109619 is about global variables of the engine and its extensions that still point into the memory of a request after the request has ended, and about code that uses them before the next request has initialised them again.

My question after that release was whether this class of bugs can be found systematically instead of one instance at a time. The second advisory describes a property that every correct build of PHP has, and checking it requires no knowledge of where a bug is: at the end of a request, no word in the memory that survives the request may contain an address inside the request's heap, which PHP has just released.

A rule like this is a test oracle. It needs no expected output for any particular input. It needs a moment at which it must hold, and PHP has one after every request.

The tooling of php-src could not see the class

php-src has more than 20,000 test files, a fuzzing harness, and CI jobs that run the tests under AddressSanitizer (ASan). Before I built anything, I wrote down four assumptions about why none of them had reported a bug of this class. The runs I describe below bore each of them out.

Why the existing tooling of php-src did not report the PHP2Shell class
What the tooling does What that hides
The fuzzing harness runs one request per input, carries no state into a second request, and ends the iteration when memory runs out. A stale pointer does no harm until something follows it, and that takes a second request in the same process. Without follow-up requests, my runs found no case of the second advisory at all.
The ASan jobs in CI use debug builds, and one of them is thread-safe. A debug build never takes the fast shutdown path that production takes, and a thread-safe build keeps its globals somewhere else. On a debug build, the strongest case of the second advisory did not appear.
PHP's memory manager checks the memory limit only when it needs a new chunk or a huge block. A fuzzer that is guided by coverage rarely gets memory to run out at one particular allocation. Every case in my runs came from choosing the failing allocation explicitly.
The allocator that is used under ASan does not free what is left over at the end of a clean request. ASan cannot report a pointer into memory that was never freed. Once everything is freed at the end of the request, as PHP's own memory manager does in production, the stale pointers show up.

All four are differences between the process under test and the process in production. I will come back to that, because my own setup turned out to have a fifth.

Fail any allocation, then look at what the request left behind

The first thing I built makes one chosen allocation fail, the way PHP's own memory limit would, at any point between the end of one request and the end of the next. That includes the phases in which no script runs: the per-directory INI settings that a web server applies, request startup, and request shutdown. Afterwards, further requests go to the same process.

The second is a PHP extension that checks the rule. Just before PHP releases the heap of a request, the extension records the address and the size of every allocation that is still alive. After the release, it reads every 8-byte word in the writable data segments of PHP and its extensions and reports each word that contains an address inside one of those allocations. The debug information of the binary turns such a word into a name, for example executor_globals.last_fatal_error_backtrace. PHP also releases a heap once before the first request, at the end of module startup, and the extension checks there as well.

Such a report says that a global variable points into released memory. Whether anything ever follows that pointer is a separate question. To answer it, the extension can overwrite each stale word with the address of a memory page that must not be accessed, one page per word. If the next request follows the pointer, the process stops with a segmentation fault, and the address of the fault tells which variable it was.

On the known bugs, the rule told the vulnerable build from the fixed one

Before I trust a check to find something unknown, I want to see it find something known. Both techniques therefore ran against PHP 8.5.11 and 8.4.26, which have the two vulnerabilities, and against 8.5.12 and 8.4.27, which do not. The tooling was frozen before the runs, and the commits that fix the vulnerabilities were read only after the last run had finished. The design did know what the two advisories describe. The result therefore shows that the techniques can find these bugs, and it does not show that I would have designed them this way without that knowledge.

The check at the end of every request ran over the test suite of php-src, 16,403 tests on the 8.5 branch. Fourteen pointers were stale on the vulnerable build and not on the fixed build in the same test, and every one of them is a variable that the fix resets. On the 8.4 branch, it was twelve out of twelve.

The injected allocation failures found both vulnerabilities on both branches. On 8.5.11, 93,120 cases with a failure before or during request startup took 155 CPU hours on a machine with six cores and led to 13 distinct findings. The same campaign on 8.5.12 led to none. Every case behind these results was then replayed in Apache with mod_php or in php-fpm, on the vulnerable and on the fixed build.

The finding was a confirmation that failed with the wrong crash

One of those replays belonged to a case of the second advisory, in which the upload progress of the session extension follows a stale pointer. I expected a crash in the session decoder during the second request on PHP 8.5.11, and no crash on 8.5.12. In Apache, the process crashed during the first request, in the lookup of a key in a hash table, and it did so on 8.5.12 as well. Until then, every replayed case had been clean on the fixed build.

A crash that survives the fix for PHP2Shell had to be something else. The fault was at address 0x703480000010. The extension had reserved its inaccessible pages from 0x703480000000 on, so the process had followed the first stale pointer on the list and read 16 bytes into what it took for a hash table. The first entry on the list was date_globals.tzcache, recorded at the end of module startup, before any request. It was the only global variable that pointed into the heap that PHP had just released at that point.

Six words of the INI scanner's state were on the list too, pointing into memory that had been freed earlier during startup. Nothing followed them in these runs.

None of the campaigns had reported this crash. It appeared only in the replay in Apache, and I will get to the likely reason below.

A log line during startup leaves a pointer that the first request follows

The rest of the stack trace showed where the lookup came from: PHP was writing a line to its error log and needed the timezone for the timestamp. When PHP logs to the file that error_log names, each line starts with the local time, which php_log_err_with_severity() formats with php_format_date(). That call ends in php_date_parse_tzfile() of the date extension, which keeps the timezone data it has parsed in a hash table:

static timelib_tzinfo *php_date_parse_tzfile(const char *formal_tzname, const timelib_tzdb *tzdb)
{
    timelib_tzinfo *tzi;
    int dummy_error_code;

    if(!DATEG(tzcache)) {
        ALLOC_HASHTABLE(DATEG(tzcache));
        zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0);
    }

    if ((tzi = zend_hash_str_find_ptr(DATEG(tzcache), formal_tzname, strlen(formal_tzname))) != NULL) {
        return tzi;
    }

    tzi = timelib_parse_tzfile(formal_tzname, tzdb, &dummy_error_code);
    if (tzi) {
        zend_hash_str_add_ptr(DATEG(tzcache), formal_tzname, strlen(formal_tzname), tzi);
    }
    return tzi;
}

ALLOC_HASHTABLE() takes the memory for the table from the request heap, and DATEG(tzcache) is a global variable of the extension. The extension sets it back to NULL when a request begins:

PHP_RINIT_FUNCTION(date)
{
    if (DATEG(timezone)) {
        efree(DATEG(timezone));
    }
    DATEG(timezone) = NULL;
    DATEG(tzcache) = NULL;
    DATEG(last_errors) = NULL;

    return SUCCESS;
}

This is sound as long as the cache is only ever created while a request is running. A log line that is written during module startup breaks that assumption. The php.ini of the replay contained session.use_only_cookies=0, for which the session extension logs a deprecation while PHP starts. The timestamp of that line created the cache on the heap that PHP uses during startup, and php_module_startup() ends by releasing that heap:

module_startup = false;

/* Don't leak errors from startup into the per-request phase. */
clear_last_error();
shutdown_memory_manager(1, 0);

Nothing resets DATEG(tzcache) here, an incomplete cleanup (CWE-459). From this line on, it points to a hash table that no longer exists. The reset in PHP_RINIT_FUNCTION(date) would repair that, but in the first request it comes one line too late:

php_hash_environment();
zend_activate_modules();
PG(modules_activated)=1;

php_hash_environment() builds the superglobals from the input of the request, and zend_activate_modules() is what calls the RINIT functions of the extensions. Whatever PHP logs while it parses the input formats its timestamp with a cache that was freed before the request began.

The timezone cache is allocated and released during module startup and looked up in the first request before it is reset
Left, before the first request: a log line allocates the cache (green), and the end of module startup releases the heap it lives on (red). Right, in the first request: a log line during input parsing looks the cache up through the stale pointer (red), before the date extension resets it (blue).

In the replay, the log line of the first request came from the injected allocation failure. An ordinary request can cause one as well: with more input variables than max_input_vars allows, PHP logs a warning from the same place. The injection and the extension were therefore no longer needed. An unmodified ASan build of PHP, run the way the test runner of php-src runs it under ASan, reports the bug by itself:

ERROR: AddressSanitizer: heap-use-after-free on address 0x6d3136dfe690
READ of size 8 at 0x6d3136dfe690 thread T0
    #0 zend_hash_str_find_bucket  Zend/zend_hash.c:942
    #1 zend_hash_str_find         Zend/zend_hash.c:2922
    #2 zend_hash_str_find_ptr     Zend/zend_hash.h:962
    #3 php_date_parse_tzfile      ext/date/php_date.c:507
    #4 get_timezone_info          ext/date/php_date.c:574
    #5 php_format_date            ext/date/php_date.c:891
    #6 php_log_err_with_severity  main/main.c:991
    ...
    #12 php_default_treat_data    main/php_variables.c:583
    ...
0x6d3136dfe690 is located 16 bytes inside of 56-byte region
freed by thread T0 here:
    ...
    #2 zend_mm_shutdown           Zend/zend_alloc.c:2580
    #3 php_module_startup         main/main.c:2512
    ...
previously allocated by thread T0 here:
    ...
    #2 php_date_parse_tzfile      ext/date/php_date.c:503
    ...
    #11 OnUpdateUseOnlyCookies    ext/session/session.c:883
    ...
    #13 zm_startup_session        ext/session/session.c:3008

The read is 16 bytes into the freed table, the same 16 bytes as in the address of the crash in Apache. I reproduced this on PHP 8.5.12, 8.5.11, 8.4.27, and 8.4.26, and on the PHP-8.6 branch and master as of 4 November. A thread-safe build did not show it: there, php_log_err_with_severity() already formats the timestamp in UTC during module startup, which needs no timezone data.

My report ended at the use after free, and I had not assessed what an attacker can do with it. The PHP security team did. According to the advisory, the workers of php-fpm and of Apache with mod_php inherit the stale pointer from their parent process and keep it until they have completed their first normal request, and so does every worker that is started later. A crafted HTTP request crashes a fresh worker of php-fpm with the default value of max_input_vars. The released memory may by then hold data from the request, and the team demonstrated command execution in php-fpm and in mod_php, locally, with known memory addresses and under further conditions that the advisory lists.

My harness had the blind spot I had found in the tooling of php-src

The campaigns did not run Apache. To get through tens of thousands of cases, they ran a small program of mine that links against PHP and goes through the steps of a request in the order in which mod_php or php-fpm would. That harness starts PHP once, forks a child for every case, and sets error_log in the child. While the parent goes through module startup, no log file is configured. The deprecation goes to standard error without a timestamp, and nobody asks for the timezone. In the replays, Apache and php-fpm got error_log from php.ini, so it was in effect while PHP started.

This is the likely reason why the campaigns stayed silent, and I have not verified it. For a finding that has not been disclosed, I stop all work that the report does not need.

Earlier I listed four ways in which the process under test in php-src differs from the process in production. The moment at which my harness applied one INI setting was a fifth, in my own tooling, and if my explanation holds, it kept a vulnerability rated 9.2 out of every campaign. I had planned the replay in the real servers as a confirmation of results I already had. For this bug, it was the only step that could produce a result.

Update, and until then get rid of what PHP reports at startup

PHP 8.2.36, 8.3.37, 8.4.28, and 8.5.13 contain the fix. Outside a fully initialised request, PHP now formats the timestamps of its error log in UTC and leaves the timezone cache alone.

According to the advisory, the bug can be triggered when three things come together: PHP logs a suitable message during startup, PHP writes its error log to a file, and a fresh worker logs a message early in a request. The first is easy to overlook. The advisory confirms an invalid value for date.timezone and a warning or deprecation caused by the session configuration as examples, and PHP labels such messages with PHP Startup in the log. The error log of php-fpm itself does not count, only the file that PHP's error_log setting names.

If you cannot update today, the advisory names two interim measures. Correct the configuration errors and deprecated settings that PHP reports at startup, and then restart the master process and all workers. Or send PHP's errors to syslog, which does not go through the code that formats the timestamp. Changing the handling of $_REQUEST or of cookies, which the conditions of one demonstrated exploit may suggest, is not a complete mitigation.

A finder owes the project the method

I sent two mails to the PHP security team on 4 November. The first contained the write-up of the experiment on PHP2Shell and the source code of everything I have described here, with the question whether any of it is worth turning into something for the CI of php-src. The second reported the use after free and said that it had been found with the approach from the first. I think that is the right order.

In an interview in October, I said that finding vulnerabilities is getting cheaper, while the people who assess and fix them remain the bottleneck. With this finding, I am on the cheap side of that sentence. The report was mine, and the assessment of the impact, the fix, and the coordinated release of four versions fell to the security team, two weeks after it had shipped the fix for PHP2Shell. Whoever finds one bug of a class owes such a project the means to find the others, and not only the one instance.

Whether the project can take those means is a different question, and it is open. What I built is a prototype, with paths of my machine in its scripts. Running it for real means one more CI job with a release build under ASan, CPU time of the order I gave above for a single version, and somebody who reads what it reports and keeps it working while the engine changes. That somebody would come from the same small group that fixed this vulnerability. I am still discussing with the PHP team how the prototype can become something they can use.

Fuzzing is a topic I am currently exploring and researching. As part of that, I have built rattle, a fuzzer for PHP code, and with it I discovered GHSA-hwfg-qwvh-2wfx in Symfony. But that is a story for another time.