Skip to content

Commit a1622ae

Browse files
committed
3.3.0: close CVE-2026-129481, CVE-2026-129182 and CVE-2026-129474 (PHP 19 November advisories)
- clear ext/session's recorded start location at request end (8.3+) - clear the saved fatal-error backtrace at request end on every 8.5 - force fatal_error_backtraces to 0 and lock it on 8.5 before 8.5.13 (hp_uploadprogress_guard.disable_fatal_backtraces, default 1) - SimpleXML workaround limited to 8.4.27 and 8.5.12 (fixed in 8.4.28 / 8.5.13)
1 parent 1803db3 commit a1622ae

2 files changed

Lines changed: 145 additions & 16 deletions

File tree

‎README.md‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# hp_uploadprogress_guard
22

3+
**v3.3.0, 19 November 2026: three of today's critical PHP advisories closed by the module.** PHP released
4+
8.5.13, 8.4.28, 8.3.37 and 8.2.36 today. Three of the advisories published with them are use-after-free bugs
5+
the module can close from outside the engine, so v3.3.0 does, on every PHP of the affected branches, patched
6+
for php2shell or not:
7+
8+
* **CVE-2026-129481, interrupted session shutdown (8.3, 8.4, 8.5; critical).** A fatal error in a callback
9+
that runs while the session shuts down (a user stream wrapper's `stream_close()`, for example) leaves
10+
ext/session pointing at a script filename in freed memory, and a later request on the same worker frees it
11+
again. [GHSA-g3vh-838c-65v7](https://github.com/php/php-src/security/advisories/GHSA-g3vh-838c-65v7).
12+
**Closed:** the module clears that pointer at the end of every request, as the fixed release does at the next
13+
session start.
14+
* **CVE-2026-129182, fatal-error backtrace after shutdown (8.5; critical).** A fatal error while PHP restores
15+
INI settings after the request (a failed `max_memory_limit` restore, a `zlib.output_compression` /
16+
`output_handler` conflict) saves a backtrace that outlives the request's memory; an early warning in the next
17+
request reads it. [GHSA-2fjv-p558-g82m](https://github.com/php/php-src/security/advisories/GHSA-2fjv-p558-g82m).
18+
**Closed:** the module clears the saved backtrace at the end of every request.
19+
* **CVE-2026-129474, `__call()` / `__callStatic()` backtraces (8.5 before 8.5.13; critical, remote code
20+
execution demonstrated).** A fatal error (memory limit, time limit) while PHP enters a magic method can read
21+
freed arguments into the fatal-error backtrace. Laravel facades and Magento proxies reach such calls.
22+
[GHSA-8mjj-2r7p-4hg2](https://github.com/php/php-src/security/advisories/GHSA-8mjj-2r7p-4hg2). The bug is in
23+
the engine itself; **the module applies the advisory's own workaround**: `fatal_error_backtraces` forced to
24+
`0` and locked, so `.user.ini`, `.htaccess` and `ini_set()` cannot turn it back on. Fatal errors are still
25+
reported, without the stack trace 8.5 added to them. `hp_uploadprogress_guard.disable_fatal_backtraces = 0`
26+
keeps them.
27+
28+
The other four advisories of the release sit where a module cannot reach: the PHP-FPM master process
29+
(CVE-2026-129291, only with `catch_workers_output = yes`), the HTTP and FTP stream wrappers (CVE-2026-128064,
30+
mixed-case `HTTPS://`; CVE-2026-127960, folded response headers) and the 8.5 URI extension (CVE-2026-129438).
31+
Each advisory lists its workaround.
32+
33+
Today's releases also fix two of the three issues below: the SimpleXML crash (the module's workaround now
34+
applies to 8.4.27 and 8.5.12 only) and CVE-2026-115560 (session upload progress is now off by default). The
35+
`unserialize()` use-after-free is still not in a release; the module keeps covering it.
36+
337
**v3.2.7, 12 November 2026: three issues PHP has not fixed in a release yet, covered.** Since the php2shell
438
releases, three more problems have surfaced in current PHP. PHP has since fixed two of them in its source code,
539
but as of 12 November no PHP release contains any of the fixes: the latest are still 8.5.12, 8.4.27, 8.3.36 and
@@ -198,7 +232,33 @@ module closes their published attack routes (with the one difference noted under
198232
PHP ships the fix the wrapper still releases the table exactly once, so it is harmless.
199233
* **Switch.** `hp_uploadprogress_guard.simplexml_gc_fix = 1` (default; `PHP_INI_SYSTEM`). `php --ri
200234
hp_uploadprogress_guard` shows `SimpleXML GC double-free workaround (php-src#24488) => active` on the
201-
affected releases and `not needed (this PHP release)` elsewhere.
235+
affected releases and `not needed (this PHP release)` elsewhere, including 8.4.28 and 8.5.13 (since v3.3.0).
236+
237+
**v3.3.0** (19 November): three advisories of PHP's 19 November security release, see the top of this page.
238+
239+
* **CVE-2026-129481** (8.3 and later): the post-deactivate function, which runs after every extension's request
240+
shutdown and before the request's memory is released, clears ext/session's recorded start location
241+
(`session_started_filename`, `session_started_lineno`). The globals are found through ext/session's module
242+
entry, so the module still loads where ext/session is shared or missing. phpinfo: `session start location
243+
cleared at request end (CVE-2026-129481) => active`.
244+
* **CVE-2026-129182** (8.5): the same function now clears the saved fatal-error backtrace on every 8.5, not only
245+
on engines without the php2shell fix (8.5.12 clears it before the INI restore that can save it again).
246+
phpinfo: `fatal-error backtrace cleared at request end (CVE-2026-129182) => active`.
247+
* **CVE-2026-129474** (8.5.0 to 8.5.12): `fatal_error_backtraces` forced to `0` and locked at `PHP_INI_SYSTEM`,
248+
the same way as `session.upload_progress.enabled`. phpinfo: `fatal_error_backtraces forced to 0 and locked
249+
(CVE-2026-129474) => yes`; `not needed (this PHP release)` from 8.5.13. Switch:
250+
`hp_uploadprogress_guard.disable_fatal_backtraces = 1` (default; `PHP_INI_SYSTEM`).
251+
* The SimpleXML workaround (v3.2.1) now applies to 8.4.27 and 8.5.12 only: 8.4.28 and 8.5.13 carry the fix.
252+
253+
Tested with PHP's own reproducers for these advisories, in the official PHP-FPM images, reading the worker's
254+
memory after the triggering request. 8.5.12 and 8.4.26: after an interrupted session shutdown the worker kept a
255+
dangling `session_started_filename` without the module, and holds `NULL` with it. 8.5.12: after the
256+
`max_memory_limit` restore failure the saved backtrace survived the request without the module, and is cleared
257+
with it. 8.5.12 CLI, `__callStatic()` with an out-of-memory error: the backtrace showed wrong arguments read
258+
from stale slots without the module; with it `fatal_error_backtraces` reads `0`, `ini_set()` cannot change it
259+
and no backtrace is built. PHP's serialize, session, SPL and fiber suites give the same results as with 3.2.7 on
260+
8.3 and 8.5; on 8.5 the three `fatal_error_backtraces` tests now fail, as intended (they turn the setting on).
261+
ZTS 8.4 builds with `-Wall -Werror`.
202262

203263
**v3.2.7** (12 November): three fixes from a review by Vincent Schmalbach, thank you.
204264

@@ -357,6 +417,9 @@ Three things happen at process start. None of them is visible to an application:
357417
`var_destroy()` has already freed. See the v3.2.0 note above.
358418
6. **SimpleXML does not crash the garbage collector on 8.4.27 and 8.5.12** (since v3.2.1). See the v3.2.1
359419
note above.
420+
7. **Request state from the 19 November advisories is cleared at request end** (since v3.3.0): ext/session's
421+
recorded start location (8.3+) and the saved fatal-error backtrace (8.5); on 8.5 before 8.5.13
422+
`fatal_error_backtraces` is forced to `0` and locked. See the v3.3.0 note above.
360423

361424
Since v3.0.2 the module also writes the master value of `session.upload_progress.enabled` to `0` and locks
362425
the entry at `PHP_INI_SYSTEM`: `ini_get()` returns `"0"`, `phpinfo()` shows `Off => Off`, and `.user.ini`,

‎src/hp_uploadprogress_guard.c‎

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@
4444
* deferring publication; the window cannot run out of memory_limit here instead) and restored afterwards.
4545
* On 8.5 the saved fatal-error backtrace is cleared at request end as well.
4646
*
47+
* 19 November 2026 advisories, applied on every engine of the affected branches, patched or not:
48+
* CVE-2026-129182 (8.5): a fatal error while PHP restores INI settings after the executor shut down saves a
49+
* new backtrace that outlives the request heap; the post-deactivate function clears it on every engine.
50+
* CVE-2026-129481 (8.3+): a bailout inside session shutdown leaves ext/session's recorded start location
51+
* pointing into the freed request heap; the post-deactivate function clears it, as 8.5.13 does at the
52+
* next session init.
53+
* CVE-2026-129474 (8.5 before 8.5.13): a fatal error while PHP enters __call()/__callStatic() can read freed
54+
* arguments into the fatal-error backtrace. The fix is inside the engine; this module applies the
55+
* advisory's workaround instead: fatal_error_backtraces forced to 0 and locked (PHP_INI_SYSTEM), unless
56+
* hp_uploadprogress_guard.disable_fatal_backtraces=0.
57+
*
4758
* Engines carrying the official fix export a symbol the old ones lack: zend_handle_delayed_oom() (8.2+,
4859
* delayed out-of-memory handled at a safe point) or zend_mm_safe_error_ex() (the 7.4/8.0/8.1 "minimal
4960
* mitigation", where the allocator _exit()s on every memory exhaustion instead of bailing out). When either
@@ -73,6 +84,9 @@
7384
#if PHP_VERSION_ID >= 80100
7485
#include "zend_observer.h"
7586
#endif
87+
#if PHP_VERSION_ID >= 80300
88+
#include "ext/session/php_session.h"
89+
#endif
7690
#include <string.h>
7791
#include <stdarg.h>
7892
#ifdef PHP_WIN32
@@ -107,7 +121,7 @@ extern void hp_upg_sym_delayed_oom(void) __asm__("zend_handle_delayed_oom") __at
107121
extern void hp_upg_sym_safe_error_ex(void) __asm__("zend_mm_safe_error_ex") __attribute__((weak));
108122
#endif
109123

110-
#define HP_MPG_VERSION "3.2.7"
124+
#define HP_MPG_VERSION "3.3.0"
111125
#define HP_MPG_NAME "hp_uploadprogress_guard"
112126

113127
/* thread-safe (ZTS) builds, PHP 7+: per-thread globals cache (no-op on NTS) */
@@ -393,12 +407,42 @@ static PHP_RINIT_FUNCTION(hp_uploadprogress_guard)
393407
return SUCCESS;
394408
}
395409

410+
#if PHP_VERSION_ID >= 80300
411+
/* CVE-2026-129481: ext/session releases its recorded start location in its own request shutdown; a bailout
412+
* there skips that and the pointer outlives the request heap. Cleared without releasing, like the others
413+
* below: the heap goes away right after this. The globals come from the module entry, not the symbol, so
414+
* this module still loads where ext/session is shared or absent. */
415+
static void hp_upg_session_clear_started(void)
416+
{
417+
zend_module_entry *m = zend_hash_str_find_ptr(&module_registry, "session", sizeof("session") - 1);
418+
php_ps_globals *g;
419+
if (!m || !m->module_started) {
420+
return;
421+
}
422+
#ifdef ZTS
423+
g = ts_resource(*m->globals_id_ptr);
424+
#else
425+
g = m->globals_ptr;
426+
#endif
427+
g->session_started_filename = NULL;
428+
g->session_started_lineno = 0;
429+
}
430+
#endif
431+
396432
/* Runs after zend_deactivate() destroyed the executor: everything below is already freed, only the stale
397433
* pointers are replaced by what init_executor() will set anyway, exactly as the fix does in shutdown. */
398434
static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(hp_uploadprogress_guard)
399435
{
400436
int i;
401437
HP_UPG_TSRMLS_FETCH();
438+
#if PHP_VERSION_ID >= 80500
439+
/* CVE-2026-129182: also on engines with the php2shell fix, which clear it before the INI restore that
440+
* can save it again */
441+
HP_UPG_CLEAR_ZV(EG(last_fatal_error_backtrace));
442+
#endif
443+
#if PHP_VERSION_ID >= 80300
444+
hp_upg_session_clear_started();
445+
#endif
402446
if (hp_upg_php_patched) {
403447
return SUCCESS;
404448
}
@@ -407,9 +451,6 @@ static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(hp_uploadprogress_guard)
407451
EG(record_errors) = 0;
408452
EG(num_errors) = 0;
409453
EG(errors) = NULL;
410-
#endif
411-
#if PHP_VERSION_ID >= 80500
412-
HP_UPG_CLEAR_ZV(EG(last_fatal_error_backtrace));
413454
#endif
414455
HP_UPG_CLEAR_ZV(EG(user_error_handler));
415456
HP_UPG_CLEAR_ZV(EG(user_exception_handler));
@@ -473,15 +514,15 @@ static void hp_upg_force_memory_unlimited(void)
473514
/* Make the switch visible: set the MASTER value of session.upload_progress.enabled to 0 and lock the entry
474515
* to PHP_INI_SYSTEM, so ini_get()/phpinfo() report it Off and .user.ini / .htaccess / ini_set() cannot turn
475516
* it back on. The master value is written directly (not via zend_alter_ini_entry, which PHP would restore
476-
* at the end of the first request). Runs at MINIT after ext/session registered the entry. */
477-
static void hp_upg_force_ini_off(void)
517+
* at the end of the first request). Runs at MINIT after ext/session registered the entry. Also used for
518+
* fatal_error_backtraces (CVE-2026-129474). */
519+
static int hp_upg_force_ini_off(const char *name, size_t name_len)
478520
{
479-
const char name[] = "session.upload_progress.enabled";
480521
zend_ini_entry *e;
481522
HP_UPG_TSRMLS_FETCH();
482523
#if PHP_VERSION_ID < 70000
483-
if (zend_hash_find(EG(ini_directives), (char *) name, sizeof(name), (void **) &e) != SUCCESS) {
484-
return;
524+
if (zend_hash_find(EG(ini_directives), (char *) name, name_len + 1, (void **) &e) != SUCCESS) {
525+
return 0;
485526
}
486527
if (e->on_modify) {
487528
e->on_modify(e, "0", 1, e->mh_arg1, e->mh_arg2, e->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC);
@@ -491,9 +532,9 @@ static void hp_upg_force_ini_off(void)
491532
e->value = zend_strndup("0", 1);
492533
e->value_length = 1;
493534
#else
494-
e = zend_hash_str_find_ptr(EG(ini_directives), name, sizeof(name) - 1);
535+
e = zend_hash_str_find_ptr(EG(ini_directives), name, name_len);
495536
if (!e) {
496-
return;
537+
return 0;
497538
}
498539
{
499540
zend_string *zero = zend_string_init("0", 1, 1);
@@ -511,7 +552,7 @@ static void hp_upg_force_ini_off(void)
511552
}
512553
#endif
513554
e->modifiable = PHP_INI_SYSTEM;
514-
hp_upg_ini_forced = 1;
555+
return 1;
515556
}
516557
static int hp_upg_mbstring = 0;
517558
#if PHP_VERSION_ID < 70000
@@ -993,23 +1034,35 @@ static void hp_upg_sxe_unhook(void)
9931034
/* Releases carrying the GC change of GH-24050 (php-src#24488): 8.4.27 and 8.5.12 onward until fixed. */
9941035
static int hp_upg_sxe_affected(void)
9951036
{
1037+
/* introduced by 8.4.27 and 8.5.12, fixed in 8.4.28 and 8.5.13 */
9961038
if (strncmp(hp_upg_php_version, "8.4.", 4) == 0) {
997-
return php_version_compare(hp_upg_php_version, "8.4.27") >= 0;
1039+
return php_version_compare(hp_upg_php_version, "8.4.27") >= 0 && php_version_compare(hp_upg_php_version, "8.4.28") < 0;
9981040
}
9991041
if (strncmp(hp_upg_php_version, "8.5.", 4) == 0) {
1000-
return php_version_compare(hp_upg_php_version, "8.5.12") >= 0;
1042+
return php_version_compare(hp_upg_php_version, "8.5.12") >= 0 && php_version_compare(hp_upg_php_version, "8.5.13") < 0;
10011043
}
10021044
return 0;
10031045
}
10041046
#endif
10051047

1048+
#if PHP_VERSION_ID >= 80500
1049+
static int hp_upg_backtraces_forced = 0;
1050+
1051+
/* CVE-2026-129474: fixed in 8.5.13 */
1052+
static int hp_upg_backtrace_affected(void)
1053+
{
1054+
return strncmp(hp_upg_php_version, "8.5.", 4) == 0 && php_version_compare(hp_upg_php_version, "8.5.13") < 0;
1055+
}
1056+
#endif
1057+
10061058
PHP_INI_BEGIN()
10071059
PHP_INI_ENTRY("hp_uploadprogress_guard.mode", "parse", PHP_INI_SYSTEM, NULL)
10081060
PHP_INI_ENTRY("hp_uploadprogress_guard.allow_ips", "", PHP_INI_SYSTEM, NULL)
10091061
PHP_INI_ENTRY("hp_uploadprogress_guard.detach_upload_progress", "1", PHP_INI_SYSTEM, NULL)
10101062
PHP_INI_ENTRY("hp_uploadprogress_guard.force_unlimited_memory", "0", PHP_INI_SYSTEM, NULL)
10111063
PHP_INI_ENTRY("hp_uploadprogress_guard.unserialize_isolation", "1", PHP_INI_SYSTEM, NULL)
10121064
PHP_INI_ENTRY("hp_uploadprogress_guard.simplexml_gc_fix", "1", PHP_INI_SYSTEM, NULL)
1065+
PHP_INI_ENTRY("hp_uploadprogress_guard.disable_fatal_backtraces", "1", PHP_INI_SYSTEM, NULL)
10131066
PHP_INI_END()
10141067

10151068
static int hp_upg_client_allowed(void)
@@ -1108,8 +1161,13 @@ static PHP_MINIT_FUNCTION(hp_uploadprogress_guard)
11081161
}
11091162
}
11101163
if (hp_upg_detached) {
1111-
hp_upg_force_ini_off();
1164+
hp_upg_ini_forced = hp_upg_force_ini_off("session.upload_progress.enabled", sizeof("session.upload_progress.enabled") - 1);
1165+
}
1166+
#if PHP_VERSION_ID >= 80500
1167+
if (INI_BOOL("hp_uploadprogress_guard.disable_fatal_backtraces") && hp_upg_backtrace_affected()) {
1168+
hp_upg_backtraces_forced = hp_upg_force_ini_off("fatal_error_backtraces", sizeof("fatal_error_backtraces") - 1);
11121169
}
1170+
#endif
11131171
if (!hp_upg_php_patched) {
11141172
hp_upg_install_oom_hook();
11151173
hp_upg_orig_sapi_deactivate = sapi_module.deactivate;
@@ -1196,6 +1254,14 @@ static PHP_MINFO_FUNCTION(hp_uploadprogress_guard)
11961254
php_info_print_table_row(2, "SimpleXML GC double-free workaround (php-src#24488)", hp_upg_sxe_hooked ? "active"
11971255
: (hp_upg_sxe_wanted ? "pending (installed on first request)"
11981256
: (hp_upg_sxe_affected() ? (INI_BOOL("hp_uploadprogress_guard.simplexml_gc_fix") ? "n/a (SimpleXML not loaded)" : "off") : "not needed (this PHP release)")));
1257+
#endif
1258+
#if PHP_VERSION_ID >= 80300
1259+
php_info_print_table_row(2, "session start location cleared at request end (CVE-2026-129481)", HP_UPG_MODULE_LOADED("session") ? "active" : "n/a (session not loaded)");
1260+
#endif
1261+
#if PHP_VERSION_ID >= 80500
1262+
php_info_print_table_row(2, "fatal-error backtrace cleared at request end (CVE-2026-129182)", "active");
1263+
php_info_print_table_row(2, "fatal_error_backtraces forced to 0 and locked (CVE-2026-129474)", hp_upg_backtraces_forced ? "yes"
1264+
: (hp_upg_backtrace_affected() ? "off" : "not needed (this PHP release)"));
11991265
#endif
12001266
php_info_print_table_row(2, "unserialize() re-entrancy isolation (destructors during var_destroy)", hp_upg_unser_hooked ? (hp_upg_sdecode_fn ? "active (unserialize, session_decode, session_start, session_reset)" : "active (unserialize)") : "off");
12011267
php_info_print_table_end();

0 commit comments

Comments
 (0)