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
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
107121extern 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. */
398434static 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}
516557static 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. */
9941035static 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+
10061058PHP_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 )
10131066PHP_INI_END ()
10141067
10151068static 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