hp_uploadprogress_guard
Who needs this right now?
- Everyone still on PHP 8.1, 8.0, 7.x or 5.x. These versions are end-of-life and get none of PHP’s
19 November fixes. This module closes all seven critical advisories of that release on them, without
rebuilding PHP.
- Everyone on PHP 8.2 to 8.5 who cannot upgrade today: shared hosting, control panels, frozen production
servers.
- Everyone who already upgraded: keep it installed. It also covers the
unserialize() use-after-free
(php-src#24481), which PHP has fixed in its source but not shipped in a release yet.
Despite the name, this is no longer only an upload-progress fix. It started in October as the
php2shell mitigation and now closes nine CVEs and two memory-safety bugs: php2shell (CVE-2026-109618,
CVE-2026-109619), CVE-2026-115560, CVE-2026-129289, CVE-2026-129496, CVE-2026-126714, CVE-2026-129481,
CVE-2026-129182 and CVE-2026-129474, plus the SimpleXML double free and the unserialize() use-after-free.
Prebuilt for PHP 5.4 to 8.5 on Linux (x86_64, arm64) and Windows (x64, x86), for Sury, Remi, cPanel
EA4, DirectAdmin CustomBuild and the official Docker images. Free and open source. Where an official fix
is installed, the matching layer steps aside. Upgrading PHP remains the real fix wherever you can.
v3.3.1, 19 November 2026: all seven critical advisories of today’s PHP release covered. PHP released
8.5.13, 8.4.28, 8.3.37 and 8.2.36 today, with 17 advisories, seven of them critical. Six of those seven can
be closed from outside the engine, so v3.3.0 and v3.3.1 do, on every PHP of the affected branches (including
the end-of-life ones the module supports), patched for php2shell or not. The seventh, CVE-2026-115560, is
covered by the module since its first version.
- CVE-2026-129289, FastCGI request smuggling (5.6 to 8.5; critical, no memory corruption needed). When an
application opens
php://input without reading it to the end, PHP skips draining the rest of the request
body. On a kept FastCGI connection (nginx fastcgi_keep_conn on, Apache enablereuse=on) PHP-FPM then
reads the rest of the body as a new request: an attacker’s forged request with its own SCRIPT_FILENAME,
REMOTE_ADDR and PHP_ADMIN_VALUE, enough to run their own PHP code.
GHSA-qc49-hpvq-g2w6.
Closed: the module drains the unread body before the SAPI finishes the request, as the fix does.
- CVE-2026-129496, timezone cache use-after-free (all versions; critical). A warning written to a PHP
error log file during startup (an invalid
date.timezone, a deprecated setting) leaves ext/date’s timezone
cache pointing into freed startup memory, and the first warning of a worker’s first request (too many input
variables) uses it. GHSA-gr4f-wgx5-jpfv.
Closed: the module clears that pointer at the end of startup and of every request, before the memory it
points into is released.
- CVE-2026-126714, partially overwritten session files (all versions; critical; since v3.3.1). PHP’s
default
files session handler truncated a session file before writing only when the new data was shorter.
An interrupted longer write left the new data followed by the tail of the old session, which can unserialize
into objects neither session contained.
GHSA-fm2m-fjf5-v3cp.
Closed: the handler now truncates before every write, as in the fix.
- CVE-2026-129481, interrupted session shutdown (8.3, 8.4, 8.5; critical). A fatal error in a callback
that runs while the session shuts down (a user stream wrapper’s
stream_close(), for example) leaves
ext/session pointing at a script filename in freed memory, and a later request on the same worker frees it
again. GHSA-g3vh-838c-65v7.
Closed: the module clears that pointer at the end of every request, as the fixed release does at the next
session start.
- CVE-2026-129182, fatal-error backtrace after shutdown (8.5; critical). A fatal error while PHP restores
INI settings after the request (a failed
max_memory_limit restore, a zlib.output_compression /
output_handler conflict) saves a backtrace that outlives the request’s memory; an early warning in the next
request reads it. GHSA-2fjv-p558-g82m.
Closed: the module clears the saved backtrace at the end of every request.
- CVE-2026-129474,
__call() / __callStatic() backtraces (8.5 before 8.5.13; critical, remote code
execution demonstrated). A fatal error (memory limit, time limit) while PHP enters a magic method can read
freed arguments into the fatal-error backtrace. Laravel facades and Magento proxies reach such calls.
GHSA-8mjj-2r7p-4hg2. The bug is in
the engine itself; the module applies the advisory’s own workaround: fatal_error_backtraces forced to
0 and locked, so .user.ini, .htaccess and ini_set() cannot turn it back on. Fatal errors are still
reported, without the stack trace 8.5 added to them. hp_uploadprogress_guard.disable_fatal_backtraces = 0
keeps them.
Not covered, because a module cannot reach the code or the fix needs PHP’s own internals; each advisory lists
its workaround: CVE-2026-129291 (PHP-FPM master, only with catch_workers_output = yes), CVE-2026-128064
(mixed-case HTTPS:// / FTPS:// in the stream wrappers), CVE-2026-127960 (folded HTTP response headers),
CVE-2026-128090 (PHAR signatures), CVE-2026-129506 and CVE-2026-15353 (SOAP), CVE-2026-129501 (DOM),
CVE-2026-129538 (PHP-CGI PATH_INFO), CVE-2026-129292 (PHP-FPM status page) and CVE-2026-129438 (8.5 URI
extension).
Today’s releases also fix two of the three issues below: the SimpleXML crash (the module’s workaround now
applies to 8.4.27 and 8.5.12 only) and CVE-2026-115560 (session upload progress is now off by default). The
unserialize() use-after-free is still not in a release; the module keeps covering it.
v3.2.7, 12 November 2026: three issues PHP has not fixed in a release yet, covered. Since the php2shell
releases, three more problems have surfaced in current PHP. PHP has since fixed two of them in its source code,
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
8.2.35, from 21 October. This module covers all three, on patched and unpatched PHP alike, so keep it
installed after you upgrade.
-
CVE-2026-115560, session upload progress (announced 23 October). PHP’s security team recommends
session.upload_progress.enabled=0 until the next regular release
(informational advisory); no PHP release fixes it
yet. PHP rates it unlikely: it needs an application that changes session.serialize_handler at runtime,
with upload progress enabled. Covered by the module by default, on every PHP version, patched or not:
it detaches the upload-progress handler and forces session.upload_progress.enabled to 0, locked so an
application, .user.ini or ini_set() cannot turn it back on. That is exactly PHP’s mitigation, already in
place on every host running the module. Keep hp_uploadprogress_guard.detach_upload_progress = 1 (the default).
-
unserialize() use-after-free, in every current release. When unserialize() cleans up, it frees its
bookkeeping first and then runs object destructors; a destructor that calls unserialize() again works on
freed memory. This is the bug behind the “PHP 8.5.12 patch is incomplete” claims. Present in 8.5.12,
8.4.27, 8.3.36, 8.2.35 and older; reachable when an application unserializes attacker-controlled data, or
by code already running on the host. No CVE (PHP does not assign CVEs to unserialize() bugs):
php-src#24481, fixed in PHP’s source on 30 October, not in a
release yet. PHP has since found more routes to the same bug (destructors run by the garbage collector,
error handlers, __toString(), session_decode(), fibers: php-src#24674);
that fix is still under review and aimed at the next major version only.
Closed by the module since v3.2.0: such nested calls get their own state. Verified with Valgrind on all
five releases named here: freed-memory reads without the module, none with it. PHP’s own new tests for the
other routes give PHP’s expected results with the module, with no memory errors (since v3.2.6, see below).
-
SimpleXML crashes, introduced by 8.4.27 and 8.5.12. The security release changed the garbage collector,
and SimpleXML now frees its property table twice when an object converted with json_encode(), (array)
or get_object_vars() (the everyday json_decode(json_encode($xml), true)) is collected in a reference
cycle: zend_mm_heap corrupted, a crashed worker. Fixed in PHP’s source on 22 October, not released yet:
php-src#24488.
Fixed by the module since v3.2.1, by applying PHP’s approved fix from inside the module, only on those
two releases. On a staging host with 8.4.27, a plain SimpleXML script crashed before and completed after.
Nothing changes for applications: identical output with and without the module on every branch from 5.4 to
8.5, and PHP’s own serialize, session and SimpleXML test suites give the same results. Details and tests
further down.
What it is. A small PHP extension that mirrors the official fix for
CVE-2026-109618 / CVE-2026-109619 component by component, so that on an unpatched PHP every link of
the published attack chain is removed, without rebuilding PHP and without changing anything for the
applications on the host. Built by Hosted Power for its own fleet,
published for everyone. PHP 5.4 through 8.5; Sury, Remi, cPanel EA4, DirectAdmin CustomBuild, official
Docker images. Prebuilt for Linux x86_64 and arm64 (aarch64), every branch from 5.4 to 8.5, and for
Windows x64 (7.2 to 8.5, nts and ts), with checksums; one C source file for everything else. On a PHP that already carries the php2shell fix,
vendor backports included, its php2shell layers notice that and step aside; the two protections above stay on,
and so does the detached session upload-progress handler (see point 4 below).
Install the official PHP release (8.5.12, 8.4.27, 8.3.36, 8.2.35, and the PHP team’s backports
for 7.4, 8.0 and 8.1, which Sury extended down to 5.6); we recommend it without reservation. This
module protects an unpatched PHP for real. It mirrors the official fix component by component,
with one deliberate difference (memory running out while a script runs, see v3.1.0 below),
tested per branch and per SAPI (see the tests below), so a host that runs it is protected today,
whether its packages arrive tomorrow or never. After the upgrade its php2shell layers step aside on their
own, so there is nothing to undo, and the v3.2.0 unserialize() protection keeps running. Read the advisories:
GHSA-w8hw-w9fx-j79w and
GHSA-6wmf-4rv5-p3rp.
What the advisories say, in one paragraph. CVE-2026-109619: the session upload-progress handler runs
on every multipart request before the request is initialised and can consume state a previous request
on the same worker left behind; PHP’s own mitigation is session.upload_progress.enabled=0. Validated
RCE on mod_php and php-fpm. CVE-2026-109618: if PHP runs out of memory while the request is still
being set up, the engine longjmps out and request shutdown runs on half-initialised state; the
advisory lists three multipart ways to get there (a body without a usable Content-Length, a flood of
part headers, a flood of empty file controls that each still produce $_FILES arrays). Validated RCE
on mod_php, where shutdown runs after a failed startup. v3.0.0 removes the handler, carries the fixed
parser, and makes it impossible for the parser to run out of memory in the first place.
v3.0.0 also fixes v2.2.0 on PHP 7.0 to 7.4, where the carried parser rejected every multipart
request (Multipart body parts limit exceeded 0) because it read an ini setting that only exists from
8.0.28. If you installed v2.2.0 on a 7.x host, update.
v3.0.1 (same day): the v3.0.0 binaries for 8.2 to 8.5 were built on Debian 13 and required
GLIBC_2.38, so they did not load on Debian 12 or older (PHP Startup: Unable to load dynamic library;
PHP kept running without the guard). Every binary is now built on the oldest Debian that ships the
minor and build.sh refuses anything above GLIBC_2.14. Also in v3.0.1: requests on hosts with
mbstring.encoding_translation=On are handed to PHP’s own parser (mbstring’s multibyte hooks are
file-static and cannot be mirrored; the callback detach still applies), the 8.0 to 8.3 copies no longer
depend on max_multipart_body_parts existing (it was added mid-branch, so a stale 8.0.x/8.1.x/8.2.0-2
install hit the 7.x failure), the parser copies no longer export PHP’s own symbol names, mode is
case-insensitive, any PHP newer than 8.6 counts as patched, and cd src && phpize && ./configure && make
works again (config.m4 picks the parser copy for the PHP it is built against).
v3.0.2 (same day): session.upload_progress.enabled now reads as Off. The handler detach already
made the setting meaningless, but ini_get() and phpinfo() kept reporting On, which confused
scanners and customers. The module now writes the master value to 0 at startup and locks the entry at
PHP_INI_SYSTEM, so ini_get() returns "0", phpinfo() shows Off => Off, and .user.ini,
.htaccess or ini_set() cannot change it. No other behaviour changed; binaries rebuilt for 5.6 to 8.5
with the same glibc floor.
v3.1.0 (same day, evening): the rest of the official fix, mirrored. v3.0 covered the multipart
parser; v3.1 covers what the patch does outside it. Nothing changes for applications: uploads, forms, error handlers and warnings behave as
before. In detail:
- Out-of-memory exit. If memory still runs out while no script is executing (request startup or
shutdown: PHP’s own parser in
native mode or the mbstring.encoding_translation case, a genuine
out-of-memory from the operating system), the process ends with _exit(137) after unlinking the
upload temp files it registered, instead of staying alive with half-cleaned state. That is what the
official hard memory limit does, and what the PHP team chose for every memory exhaustion in the
backports. php-fpm already discards a worker whose request startup failed; this matters for mod_php,
LiteSpeed, FrankenPHP and any other SAPI that keeps the process. Not covered: memory running out
while a script runs. The module leaves that to PHP’s normal fatal error and bailout, after which the
request is shut down in full; the official fix also changes that case (8.2 and later handle it at a
safe point, the 7.4 to 8.1 backports end the process). The published attack routes run out of memory
before the script starts, which the parser guard and this exit cover.
- Request state cleared at request end. The patch writes safe values over a set of pointers the
engine leaves behind at shutdown (user error and exception handlers, recorded errors, the object
store, the superglobals, the
request_info strings, on 8.5 the saved fatal-error backtrace), so that
a warning raised before the next request’s executor starts (an invalid php_value in .htaccess,
a PHP_VALUE from the web server) finds nothing stale. The module writes the same values, a few
steps later, in its post-deactivate function and in a wrapper around the SAPI’s deactivate callback.
- OPcache’s compile window cannot run out of memory (8.1 and later). The one part of the patch
without a module equivalent is OPcache’s deferred publication of class-cache slots in shared memory,
which guards against a bailout while OPcache stores a freshly compiled script. The module keeps that
window from bailing out instead:
memory_limit is lifted while OPcache compiles and stores a script
and restored right after, and the lift is visible in --ri.
- Fix detection by symbol, not by version number. Engines that carry the fix export a symbol the
old ones lack (
zend_handle_delayed_oom on 8.2 and later, zend_mm_safe_error_ex in the backports).
The module checks for them through weak references (no dlsym, no glibc dependency), so vendor
backports that keep their version number are recognised too. Verified on Sury’s packages of
21 October for 5.6, 7.0, 7.3, 7.4, 8.1 and 8.3: the module reports the fix and steps aside. Sury ships
fixed packages for every branch from 5.6 to 8.5.
hp_uploadprogress_guard.force_unlimited_memory = 1, opt-in: the advisories’ memory_limit=-1
mitigation, written as master value and locked at PHP_INI_SYSTEM. No memory-limit bailout can
then start anywhere; bound the process with the operating system instead (cgroup MemoryMax).
php-fpm pool directives for memory_limit are applied after the module starts and take precedence;
phpinfo() and --ri show the effective value when that happens.
- Also: on 5.6 and 7.0, where a timeout can interrupt request startup, it is treated like memory
exhaustion;
--ri reports every mechanism and its state; binaries rebuilt for 5.6 to 8.5 with the
same glibc floor, zero compiler warnings.
Build fixes, same evening (source only, binaries unchanged): the 7.4 and 8.0 parser copies build on
patch releases older than 7.4.14 / 8.0.1 again (#6), and config.m4 picks the 5.6 parser copy for
PHP 5.4 and 5.5 (#5).
22 October: on the follow-up reports in the press. Two further PHP bug reports circulated on 21 and
22 October. One is the unserialize() use-after-free described at the top: it is real, it is present in
8.5.12, and v3.2.0 closes it. The other is a double free demonstrated with the Zend memory manager switched
off; the PHP team reviewed that responsibly disclosed report and stated it is “an unrelated issue with no
connection to the two vulnerabilities mitigated today” and “not urgent in any way”. Neither touches the
multipart parser, session state, OPcache or the memory-limit bailout: the two critical vulnerabilities,
CVE-2026-109618 and CVE-2026-109619, are fixed in the released PHP versions, and on unpatched engines this
module closes their published attack routes (with the one difference noted under v3.1.0).
v3.2.0 (22 October): unserialize() re-entrancy isolation, details below.
- The bug. While an
unserialize() call is active, a nested unserialize() or session_decode() (since
v3.2.7 also session_start() and session_reset(), which decode the stored session) shares
its state (BG(unserialize)); PHP needs that for exactly one thing, a Serializable::unserialize() method
the engine calls during parsing, whose own unserialize() must resolve the outer back-references. At the
end of the outer call var_destroy() frees the back-reference chunks and then drops the deferred values
(objects replaced by duplicate keys, the return value of __wakeup(), the argument of __unserialize())
without holding serialize_lock. A destructor that runs at that moment and calls unserialize() reads and
writes the freed chunks.
- The fix. The module wraps
unserialize() and session_decode() (and, since v3.2.7, session_start()
and session_reset()). A nested call keeps sharing state only
when it comes from an engine-invoked Serializable::unserialize() with no destructor or generator in
between; every other nested call runs exactly like a top-level call, with its own state, and the outer
state is restored afterwards (also when the inner call ends in a fatal error). That is the behaviour the
reporter proposes for PHP itself, applied from outside the engine, on every branch from 5.4 to 8.5. On
PHP 8.1 and later the state is also kept per fiber (since v3.2.6), as PHP’s pending fix does.
- What changes for applications. Nothing on any normal path: top-level calls,
Serializable nesting with
shared back-references, __wakeup()/__unserialize() that unserialize, autoloaders, sessions, enums,
fibers and generators behave exactly as before (identical output on all 14 branches, see the tests). Two
cases change, both from broken to correct: a destructor that unserializes its own data with a
back-reference during an outer call’s cleanup got false or the wrong object from stock PHP, and gets the
right result now; an exception it catches around such a call escaped as an uncaught fatal error on stock
PHP, and is caught now.
- Cost. No measurable difference on normal calls; about 50 ns extra per nested call inside the
deprecated
Serializable::unserialize().
- Scope.
unserialize(), session_decode(), session_start() and session_reset(). Extensions that
unserialize with PHP’s serializer internally (APCu, Memcached or Redis with the php serializer) are not
wrapped, nor are the legacy unserialize() methods of SPL’s classes (ArrayObject, SplObjectStorage,
…), which PHP itself calls during parsing and which must share state there; reaching the bug through
them needs attacker-controlled cache contents and such a destructor. On PHP 5.x the reproducers take a
different path and do not reach the bug; the isolation is active there too.
- Switch.
hp_uploadprogress_guard.unserialize_isolation = 1 (default; PHP_INI_SYSTEM). php --ri hp_uploadprogress_guard shows unserialize() re-entrancy isolation ... => active (unserialize, session_decode, session_start, session_reset). Unlike the php2shell layers it does not step aside on patched PHP, because no PHP release
contains a fix.
v3.2.1 (22 October): SimpleXML garbage-collector double free on 8.4.27 and 8.5.12.
- The bug. The fix for GH-24050 in 8.4.27 and 8.5.12 lets the garbage collector put the table an
object’s
get_gc handler returns into its buffer. SimpleXML returns its own properties table there and
frees it in sxe_object_free_storage() with zend_hash_release(), which leaves the buffer slot behind;
the collector then frees the table a second time. Reached whenever a SimpleXML object whose properties
were materialized (json_encode(), an (array) cast, get_object_vars()) is collected as part of a
reference cycle. Reported as php-src#24488 (Status:
Verified); 8.4.26, 8.3.36 and 8.2.35 do not have it.
- The fix. The approved upstream fix releases the table with
zend_array_release(), which removes it
from the collector’s buffer first. The module wraps SimpleXML’s free_obj handler to do exactly that: it
takes the table off the object, lets SimpleXML free the rest, and releases the table with
zend_array_release(). Installed on the first request, only on 8.4 from 8.4.27 and 8.5 from 8.5.12; once
PHP ships the fix the wrapper still releases the table exactly once, so it is harmless.
- Switch.
hp_uploadprogress_guard.simplexml_gc_fix = 1 (default; PHP_INI_SYSTEM). php --ri hp_uploadprogress_guard shows SimpleXML GC double-free workaround (php-src#24488) => active on the
affected releases and not needed (this PHP release) elsewhere, including 8.4.28 and 8.5.13 (since v3.3.0).
v3.3.1 (19 November): CVE-2026-126714, the last critical advisory of PHP’s 19 November release.
- The
files session handler decides whether to truncate a session file before writing by comparing the new
data with the size it read (st_size in its private ps_files struct). The module gives the handler a copy
of the files module whose write function sets that size to INT_MAX first, so PHP’s own check truncates
before every write: the official fix, done by PHP’s own code. The copy replaces the original in ext/session’s
current and default handler at request start and in session_start(); SessionHandler subclasses use it
too. Redis, Memcached and user handlers are untouched.
ps_files is private to PHP. Its three layouts (5.4 to 5.6, 7.0 to 8.1, 8.2 to 8.5) are the same in every
release of each group, checked on the first and last release of every branch. A worker only touches it after
it has seen the mirrored file descriptor and size match a real session file; until then, and on any build
where they do not match, PHP behaves as before.
- phpinfo:
session file truncated before every write (CVE-2026-126714) => active (or active (layout checked at this worker's first session write) before that). Switch: hp_uploadprogress_guard.session_files_truncate = 1 (default; PHP_INI_SYSTEM).
Tested on 8.5, 8.4, 8.1, 7.4, 7.0 and 5.6: a 200 KB session overwritten with 300 KB under a 100 KB file-size
limit (the write stops part way, as when a worker is killed) left 102,388 bytes of new data followed by
97,612 bytes of the old session without the module, and only the new data with it (also through a
SessionHandler subclass). Shrinking and growing sessions, session_regenerate_id(), read_and_close, lazy
write and SessionHandler subclasses give identical results with and without the module; 40 parallel PHP-FPM
requests on one session keep an exact counter.
v3.3.0 (19 November): five advisories of PHP’s 19 November security release, see the top of this page.
-
CVE-2026-129289 (5.6 and later): the wrapper around the SAPI’s deactivate callback, so far installed only
on engines without the php2shell fix, is now installed on every engine. When PHP did not read the whole
request body, it drains the rest there (sapi_read_post_block()), before the SAPI finishes the request:
PHP skips that when php://input was opened. phpinfo: unread request body drained before the SAPI finishes (CVE-2026-129289) => active.
-
CVE-2026-129496 (all versions): the same wrapper clears ext/date’s timezone cache pointer. It runs at the
end of startup, after the last startup warning and right before startup memory is released, and at the end
of every request, after ext/date dropped its cache. phpinfo: timezone cache cleared before startup and request memory is released (CVE-2026-129496) => active.
-
CVE-2026-129481 (8.3 and later): the post-deactivate function, which runs after every extension’s request
shutdown and before the request’s memory is released, clears ext/session’s recorded start location
(session_started_filename, session_started_lineno). The globals are found through ext/session’s module
entry, so the module still loads where ext/session is shared or missing. phpinfo: session start location cleared at request end (CVE-2026-129481) => active.
-
CVE-2026-129182 (8.5): the same function now clears the saved fatal-error backtrace on every 8.5, not only
on engines without the php2shell fix (8.5.12 clears it before the INI restore that can save it again).
phpinfo: fatal-error backtrace cleared at request end (CVE-2026-129182) => active.
-
CVE-2026-129474 (8.5.0 to 8.5.12): fatal_error_backtraces forced to 0 and locked at PHP_INI_SYSTEM,
the same way as session.upload_progress.enabled. phpinfo: fatal_error_backtraces forced to 0 and locked (CVE-2026-129474) => yes; not needed (this PHP release) from 8.5.13. Switch:
hp_uploadprogress_guard.disable_fatal_backtraces = 1 (default; PHP_INI_SYSTEM).
-
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.
Tested in the official PHP-FPM images. 8.5.12, 8.4.26 and 7.4.33, one kept FastCGI connection, a POST body
larger than post_max_size that the script reads only partly through php://input, with a forged FastCGI
request after the part it read: without the module the forged request ran (with its own REMOTE_ADDR), with it
the body is drained and nothing else runs. 8.5.12 and 8.4.26 with an invalid date.timezone and a PHP error
log file: a fresh worker started with the timezone cache pointing into freed startup memory without the module,
and was NULL with it. With PHP’s own reproducers for the other three, reading the worker’s
memory after the triggering request: 8.5.12 and 8.4.26: after an interrupted session shutdown the worker kept a
dangling session_started_filename without the module, and holds NULL with it. 8.5.12: after the
max_memory_limit restore failure the saved backtrace survived the request without the module, and is cleared
with it. 8.5.12 CLI, __callStatic() with an out-of-memory error: the backtrace showed wrong arguments read
from stale slots without the module; with it fatal_error_backtraces reads 0, ini_set() cannot change it
and no backtrace is built. PHP’s serialize, session, SPL and fiber suites give the same results as with 3.2.7 on
8.3 and 8.5; on 8.5 the three fatal_error_backtraces tests now fail, as intended (they turn the setting on).
ZTS 8.4 builds with -Wall -Werror.
test/fcgi-keepconn.py, contributed by Ming Tsay (#30), checks the same fix with two requests on one kept
connection and enable_post_data_reading = 0: request 2 never completes on 8.5.12 and 8.4.26 without the
module, and does with it (and on 8.5.13).
v3.2.7 (12 November): three fixes from a review by Vincent Schmalbach, thank you.
-
No more 413 for a small form on a busy worker (PHP 8.1 and later). The allocator keeps memory from
earlier requests cached and counts it in the usage figure the headroom guard reads. After a few requests
that used most of memory_limit, the guard refused even a tiny form (413), which stock PHP served from
that cache. The guard now has PHP release the cached memory before it decides, through PHP’s own
zend_set_memory_limit() (asked for a lower limit, it frees cached chunks; the limit is restored at once).
On 7.x and 8.0, whose allocator cannot release the cache this way, nothing changes.
-
A dropped form no longer survives in filter_input(). When the memory-headroom guard stops a request
(413), $_POST and $_FILES were emptied, but ext/filter keeps its own copy of every form field, so
filter_input(INPUT_POST, ...), filter_has_var() and filter_input_array() still returned the fields
parsed before the stop. That copy is now emptied too. Only requests the guard stops are affected.
-
session_start() and session_reset() get their own unserialize() state when they run inside
another unserialize() (from a destructor, an error handler, __toString()), like unserialize() and
session_decode() since v3.2.0. Before, they decoded the stored session with the outer call’s state:
they could see its back-references, the precondition for the use-after-free above.
-
The README now says plainly that memory running out while a script runs is left to PHP (see v3.1.0),
and that the headroom guard’s margin can stop a request stock PHP would just have parsed (point 3 under
“What it does, silently”).
Tested on 8.3.35 (Apache, memory_limit=128M): after four requests of about 120 MB, a tiny form got 413
with 3.2.6 and gets 200 now, a 40 MB body is still refused, and memory_limit stays exactly 128M (also on
7.4 and 8.0, right after a refusal). On 8.3.35 and 5.6 (Apache, NTS) and 5.6 ZTS (Apache mpm_event): after a 413, filter_input(),
filter_has_var() and filter_input_array() return nothing, GET data and normal forms are unchanged, and
the concurrency test passes. Nested session_start() / session_reset() no longer see the outer state,
while a normal session_start() and Serializable back-references behave as before. PHP’s serialize,
session, SPL and fiber suites give the same results as with 3.2.6 on 8.3 and 8.5.
v3.2.6 (2 November): the unserialize() protection now keeps its state per fiber. Upgrade if your
applications use fibers (PHP 8.1 and later); nothing else changes.
- PHP keeps one
unserialize() state per thread, not one per fiber. When application code suspended a fiber in
the middle of an unserialize() (for example from Serializable::unserialize()) while another fiber also
unserialized, the module could restore a state that the other fiber had already freed: a use-after-free
that stock PHP does not have in that case. Found by running PHP’s new tests for
php-src#24674 against the module. The state is now saved
and restored per fiber, which is also what PHP’s pending fix
(php-src#24751) does. As a side effect, one fiber no longer
sees another fiber’s back-references, which stock PHP still allows.
- PHP 5.4 to 8.0 have no fibers and are unchanged.
Tested: Valgrind clean with the module on 8.1, 8.4 (NTS and ZTS) and 8.5 for the fiber case. The six tests
from php-src#24751 report no memory errors, and the five memory-safety ones (garbage-collector destructor,
error handler, __toString(), session_decode(), fibers) give PHP’s expected output. The sixth concerns
allowed_classes in a nested call from __wakeup(), which the module does not change; stock PHP behaves
the same. PHP’s own serialize, session, SPL and fiber test suites give the same results as with 3.2.5 on 8.1,
8.4 NTS and ZTS, and 8.5.
v3.2.5 (24 October): parser fixes contributed by
NewEraCracker (#25), thank you. Thread-safe builds with threaded Apache
should upgrade; NTS builds (php-fpm, CGI, CLI, every prebuilt .so, the nts DLLs) were not affected by the
first point.
- The parser’s stop flag (“memory headroom exhausted, stop this request”) was one variable per process. On
thread-safe PHP under threaded Apache, a concurrent request could reset it, so a refused upload could continue
and its truncated value be processed. Measured on PHP 5.6 ZTS under Apache mpm_event: 1 of 40 refused
uploads went through with 3.2.4, 0 of 40 with 3.2.5. The flag is now per thread.
- A field whose read was stopped is no longer processed at all (PHP 8.2’s own fix, backported to the 5.4 to
8.1 parser copies).
- Character classification gets an
unsigned char in every parser copy, the oversized-boundary check of PHP 8.1
and Sury’s backports is applied to 5.4 to 8.0 (a boundary over 5116 bytes is refused; browsers use at most
70), and “maximum number of file uploads exceeded” is logged once per request instead of once per extra file.
Tested: build matrix 5.4 to 8.5 NTS plus thread-safe 5.6, 7.0, 7.4, 8.1 and 8.4 without warnings; identical
$_POST/$_FILES to PHP’s own parser on 16 builds (high-bit bytes, folded headers, quoted and 5116-byte
boundaries, empty and too many files); the out-of-memory tests on 5.6, 7.4, 8.3 and 8.5.
v3.2.4 (23 October): status and documentation fixes reported in #17, #18 and #19, no change in what
is protected. phpinfo’s mbstring.encoding_translation requests row now follows the setting instead of
only whether mbstring is loaded (#19). When an extension loaded before this one already cleared the session
upload-progress handler, session.upload_progress.enabled is now forced to 0 and locked as when the
module detaches it itself (#18). The README now states that the upload-progress detach stays on on patched
PHP, by design (#17).
v3.2.3 (22 October, evening): thread-safe SAPIs ran PHP’s parser, not ours. PHP keeps the table of
POST handlers in per-thread SAPI globals, and every new thread starts from PHP’s default entries. The
module registered its multipart handler once, at startup, so on a thread-safe build with a threaded SAPI
(Apache mod_php with mpm_winnt, worker or event; the Windows ts DLLs are exactly that case) the request
threads kept PHP’s own parser, mode=block could not refuse anything, and --ri still said “handler
replaced => yes” because that was a flag set at startup. Reported privately after #14 (thank you). Now the
handler is installed in every thread before its first request, and the status rows read the live table.
The other layers (upload-progress detach, out-of-memory exit, request-state reset, unserialize()
isolation) are process-wide hooks and were active on those threads all along. Not affected: NTS builds
(php-fpm, php-cgi, CLI, all prebuilt .so files and the nts DLLs) and prefork mod_php. Verified with
Apache mpm_event + a thread-safe PHP 8.4: before, concurrent uploads passed on every worker thread; after,
every one is refused in mode=block, and phpinfo on each thread reports the live state.
v3.2.2 (22 October): PHP 5 thread-safe builds. The PHP 5 code paths used engine globals from functions
without a thread context, so a ZTS build of 5.4 to 5.6 (Linux --enable-maintainer-zts, Windows TS) did not
compile (#12, #13); the Windows symbol probe also named a PHP 7 function. Fixed: compiles, loads and passes
the behaviour suite on 5.4 and 5.6 ZTS (Linux), the multipart flood is handled on ZTS as on NTS. No change
in behaviour on NTS builds; the prebuilt files are rebuilt from the same source so they carry the version.
22 October, later: Windows DLLs for PHP 5.6 (VC11, x64 and x86, nts and ts), built and load-tested in CI
against the official 5.6.40 VC11 builds; see Windows.
22 October: arm64 and Windows. Prebuilt .so files for aarch64 (all branches 5.6 to 8.5, same old-glibc
images as x86_64) and Windows x64 DLLs for 7.2 to 8.5, nts and ts, built by the Windows build workflow with
the PHP team’s php-windows-builder and loaded into a stock Windows PHP in the same run. The source needed
only portability changes (no behaviour change); x86_64 files are unchanged. See Install.
What it does, silently
Three things happen at process start. None of them is visible to an application: uploads, forms,
$_POST and $_FILES behave exactly as before. The only feature that disappears is
session.upload_progress, which browsers replaced with native upload progress a long time ago.
- The session upload-progress handler is taken out of the multipart parser. The advisory for
CVE-2026-109619 names this handler as a confirmed way for stale request state to be consumed, and
gives
session.upload_progress.enabled=0 as the official partial mitigation. The module does the
same thing one level lower, by removing the handler from the parser’s callback pointer, so no
.user.ini, .htaccess or ini_set() can switch it back on.
- The multipart parser runs with the official hardening. The module carries a copy of
main/rfc1867.c from the patched releases, one per PHP branch (8.2 to 8.5 from the release tags,
7.4/8.0/8.1 from the PHP team’s backport branches, 7.0 to 7.3 and 5.6 with the same changes applied
by hand). It keeps only the two part headers PHP uses and ignores duplicates, which removes the
header memory-amplification path of CVE-2026-109618, and it enforces post_max_size on the bytes
actually read, which closes the no-Content-Length bypass (on every branch since v3.0.0; v2.2.0 had
it on 8.2 and later only). In this copy the callback of point 1 is compiled out entirely.
- The parser cannot run out of memory. This is what v3.0.0 adds, and it is the part of the
official fix a module could not carry as-is. The patched engine answers a memory-limit failure with
a delayed, graceful out-of-memory at the next safe point instead of a
longjmp; the carried parser
uses the same checkpoints the PHP team put into rfc1867.c (every ZEND_HAS_OOM() and fallible
allocation of the patch), but behind them it asks a different question: would this step cross
memory_limit? It compares the allocator’s own figure (zend_memory_usage(1), the number the limit
check uses) with the size the client is about to make it allocate, before every new part, every
growth of a form-field value and every header line, and keeps an eighth of the limit (at least
4 MB) plus one allocator chunk free for request startup and the script. If a step would not fit,
parsing stops at that checkpoint with everything cleanly released, what was parsed is dropped,
$_POST, $_FILES and ext/filter’s copy (filter_input(), since v3.2.7) are empty, the response
code is 413, the script still runs, and one line goes to the error log. The
engine is never asked for memory it does not have, so the longjmp of CVE-2026-109618 cannot start
inside the parser. A single part header is additionally capped at 64 KB. The margin is deliberate:
a request that comes within an eighth of memory_limit is stopped even where stock PHP would just
have parsed it. A worker also keeps memory cached from earlier large requests, which PHP counts
against memory_limit; since v3.2.7 the guard has PHP release that cache before it decides (PHP 8.1
and later; 7.x and 8.0 cannot release it), so a small form is no longer refused because of what the
worker served before. The default post_max_size=8M against memory_limit=128M never comes near the
line.
- It steps aside on a patched PHP. At startup the module reads
PHP_VERSION (8.5.12, 8.4.27,
8.3.36, 8.2.35 or later) and, since v3.1.0, looks for the symbols only a fixed engine exports, which
also recognises vendor backports that keep their version number. On such an engine it leaves PHP’s
own parser in place and switches its v3.1 mechanisms off. One deployment covers patched and
unpatched hosts, and nothing has to be undone after the upgrade. The upload-progress detach stays on
by design: the session upload-progress handler writes request data into the session from HTTP alone,
the route the published attack used, and no PHP release needs it to be on. So on a patched engine too,
session.upload_progress.enabled reads 0 and is locked. Hosts that rely on upload progress set
hp_uploadprogress_guard.detach_upload_progress = 0. Since v3.2.4 the same holds when another
extension loaded earlier already cleared the handler: the ini is forced to 0 and locked as well, and
phpinfo says so.
- Nested
unserialize() calls cannot reach freed memory (since v3.2.0, on every engine, patched or
not). A nested unserialize(), session_decode(), session_start() or session_reset() from a destructor, a generator or anything else
outside PHP’s Serializable nesting runs with its own state, so it cannot work on the bookkeeping
var_destroy() has already freed. See the v3.2.0 note above.
- SimpleXML does not crash the garbage collector on 8.4.27 and 8.5.12 (since v3.2.1). See the v3.2.1
note above.
- Session files are truncated before every write (since v3.3.1), as in PHP’s fix for CVE-2026-126714.
- Request state from the 19 November advisories is cleared at request end (since v3.3.0): the unread
request body is drained (5.6+), ext/date’s timezone cache pointer is cleared (also at the end of startup),
and so are ext/session’s recorded start location (8.3+) and the saved fatal-error backtrace (8.5); on 8.5
before 8.5.13
fatal_error_backtraces is forced to 0 and locked. See the v3.3.0 note above.
Since v3.0.2 the module also writes the master value of session.upload_progress.enabled to 0 and locks
the entry at PHP_INI_SYSTEM: ini_get() returns "0", phpinfo() shows Off => Off, and .user.ini,
.htaccess or ini_set() cannot turn it back on. That makes scanners and customers see what the detach
already enforces.
Why you still install the official packages
The one thing the module does not do is replace the engine. The patched release changes the memory allocator and OPcache from the inside;
a module can mirror what those changes achieve, and since v3.1.0 it does so for the attack paths the
advisories describe, but it remains a layer around the engine rather than the engine itself, and it
leaves memory running out while a script runs to PHP (see v3.1.0). We recommend the official packages, and the module says so itself when it finds them. Until
they are installed, and on installs where they never will be, this is protection you can rely on
rather than a stopgap; afterwards it costs nothing to leave in place.
On memory_limit=-1 the headroom guard has nothing to guard and is inert; with the module loaded a
finite memory_limit is fine, so you do not need the advisories’ memory_limit=-1 workaround unless
you want the belt-and-braces of force_unlimited_memory.
Two implementation notes. The stop flag is kept per thread (since v3.2.5), so on thread-safe builds
concurrent requests cannot reset or inherit each other’s decision.
And php-fpm reads at most CONTENT_LENGTH bytes of body on its own, so the no-Content-Length strategy
never reaches the parser through FPM; that one is mod_php’s (Apache hands the parser a chunked body
whole), and it is the strategy the advisory’s confirmed exploit used.
Install
extension=hp_uploadprogress_guard.so
That is the whole configuration; the defaults are everything described above, and
force_unlimited_memory is the only opt-in. Prebuilt NTS x86_64
binaries per PHP minor are in dist/ with SHA256SUMS; build.sh rebuilds them from the official
Docker images; src/ has the one C file and the per-branch parser copies. Verify with
php --ri hp_uploadprogress_guard: it reports whether the handler is detached, whether the carried
parser is active, and whether the running PHP already carries the official fix.
Optional: emergency switch
hp_uploadprogress_guard.mode = block refuses every multipart/form-data request before PHP reads
the body (415, empty $_POST/$_FILES; allow_ips lists clients that are still parsed). It costs
all uploads and multipart forms, so it is only for an environment under active attack that cannot
patch yet. All settings are PHP_INI_SYSTEM.
src/: one C file plus config.m4, and src/rfc1867/ with the per-branch parser copies.
dist/: prebuilt NTS x86_64 .so per PHP minor with SHA256SUMS.
build.sh: rebuilds dist/ from the official php:<X.Y>-cli images.
test/: oom-test.sh + oomclient.php + mem-probe.php (the three OOM strategies of the advisory,
without and with the module: docker run --rm -v $PWD/dist:/out:ro -v $PWD/test:/t:ro php:8.4-cli bash /t/oom-test.sh),
test-modes.sh (parse vs block, detach), run-builtin-server.sh, fcgi-probe.py, fcgi-lie.py, probe.php.
ansible/: the task files and ini templates Hosted Power deploys (Debian/Sury, cPanel EA4, DirectAdmin).
Tests, v3.0.0, 21 October 2026, official php:<X.Y>-cli images, built-in server with
memory_limit=32M post_max_size=64M. Each of the advisory’s strategies reproduces the out-of-memory
bailout without the module and ends in a 413 drop with it, after which the same server serves a normal
upload: a 40 MB form field, 20 MB of continuation lines in one part header, and 150 000 empty file
controls with nested names (Allowed memory size exhausted without; 413 post=0 files=0 and one
hp_uploadprogress_guard: multipart body dropped log line with), on 8.4, 8.1, 7.4 and 5.6 in full and
on 7.0 to 7.3, 8.0, 8.2, 8.3 and 8.5 for the field and header cases. No false positives: an 8 MB field
on memory_limit=128M is a normal 200 post=1, and so is a 40 MB field on memory_limit=-1. Normal
uploads (two fields and a 100 KB file) parse identically with and without the module on all twelve
versions. mod_php, php:8.4-apache (prefork, the SAPI the advisory validated its exploit on): a
chunked 40 MB body without Content-Length against post_max_size=1M memory_limit=32M is a startup
out-of-memory fatal (HTTP 500) without the module and a 200 with the body cut at 1 MB and the
Actual POST length does not match Content-Length warning with it. php-fpm, php:8.4-fpm with a
FastCGI client declaring CONTENT_LENGTH=1000 and streaming 40 MB: FPM stops reading at 1000 bytes
with or without the module.
Tests, v2, 21 October 2026: parse mode behaves identically to PHP’s parser on 8.4 (nested fields,
unicode, awkward filenames, file arrays, checksum of the uploaded file, malformed body); block mode
gives 415 with empty $_POST/$_FILES, urlencoded 200, GET 200, ini_set cannot override; builds
and loads on 5.6 to 8.5; live on cPanel EA4 (8.1 to 8.4) and DirectAdmin CustomBuild (8.2 to 8.4)
staging hosts, block mode exercised end to end on DirectAdmin (multipart 415, urlencoded 200, GET 200,
then back to parse: 200).
The sections below describe v1 (the detach alone) and why it was built. They are kept for the
record; read the table above for what applies now.
Why we built it
Timeline. On 20 October 2026 the PHP security team pre-announced two critical vulnerabilities
(CVSS v4.0 9.2 each) with a fix release scheduled for 21 October 14:00 UTC, details withheld. During
the night technical details leaked, and a researcher who reproduced both placed them in the
session extension’s upload-progress handler, the code that runs on every multipart/form-data
request before any application code. Reports put the affected range at every PHP release since 5.4.
Our situation. A managed hosting fleet with roughly 640 hosts declaring PHP, 14 distinct minor
versions from 5.4 to 8.5 side by side, about 200 hosts carrying at least one branch that is end of
life. Three platforms: Debian/Ubuntu with Sury packages, cPanel EA4, DirectAdmin CustomBuild. Several
hundred customer applications we do not control.
Why the usual advice was not enough for us.
- Wait for the packages. Supported branches would get them within hours (Sury even backports to
7.4/8.0/8.1), but 5.6 to 7.3 never will, and panel vendors lag by days.
- Block multipart at the web server. Breaks every upload form, every media library, Contact Form 7
submissions. Not an option on shared infrastructure.
- Set
session.upload_progress.enabled = Off. Correct target, wrong lever: it is a per-directory
ini setting any customer can flip back from .user.ini, .htaccess or ini_set(), and the
check lives inside the vulnerable function rather than in front of it. See
Why this beats the ini setting.
We wanted something that makes the affected code unreachable, on every SAPI, for every
installed version, that customers cannot undo, that keeps uploads working, and that can be
verified per process rather than per config file. The extension does that.
How it works
Everything below refers to the PHP-8.3 branch of php-src; the same structure exists from 5.4 to
master.
-
The multipart parser (main/rfc1867.c) talks to interested extensions through one global
function pointer, declared NULL:
PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra) = NULL; /* rfc1867.c:52 */
Every one of its seven call sites is guarded: if (php_rfc1867_callback != NULL) { ... }
(rfc1867.c:759, 861, 883, 957, 1007, 1076, 1259). A NULL pointer means “nobody is listening”,
and the parser just parses.
-
The session extension installs its handler into that pointer at module init
(PHP_MINIT_FUNCTION(session), session.c:2901-2902):
php_session_rfc1867_orig_callback = php_rfc1867_callback;
php_rfc1867_callback = php_session_rfc1867_callback;
and takes it out again at module shutdown (session.c:2928-2932).
-
hp_uploadprogress_guard declares an optional module dependency on session
(ZEND_MOD_OPTIONAL("session")), so the engine starts it after session. Its MINIT then does:
if (php_rfc1867_callback != NULL) {
php_rfc1867_callback = NULL;
hp_upg_detached = 1;
}
From that moment the parser’s NULL checks skip the session extension on every multipart
event. php_session_rfc1867_callback is never entered again in that process.
-
MINFO reports what happened, so php --ri hp_uploadprogress_guard (or phpinfo()) shows
rfc1867 (session.upload_progress) callback detached => yes in the running build.
That was the whole extension in v1, and it is still the core: one pointer write at process start. v2
added the carried parser, v3 the memory-headroom guard, v3.1 the out-of-memory exit, the request-state
reset and the OPcache compile window described in the release notes above. There are still no opcode
changes and no per-request cost worth measuring.
Effect
|
Before |
After |
File uploads, $_FILES, $_POST, multipart forms |
work |
work, unchanged |
Sessions, session_start(), save handlers |
work |
work, unchanged |
session.upload_progress feature ($_SESSION["upload_progress_<name>"] filled while a file is uploading) |
works |
off, nothing is written |
ini_get('session.upload_progress.enabled'), phpinfo() |
1 |
0 / Off, locked (since v3.0.2) |
| Process restart needed |
|
php-fpm / mod_php once; cgi and cli pick it up on the next start |
The upload-progress feature is the only casualty. Browsers have reported upload progress natively
(XMLHttpRequest.upload.onprogress) since 2012, and every mainstream application uses that, so in
practice the feature is dormant. An application that still polls $_SESSION for progress simply
sees no entry: the upload itself completes normally.
Why this beats the ini setting
session.upload_progress.enabled = Off is what every advisory suggests. It targets the same code,
so it is not wrong. It is weaker in four concrete ways.
1. The ini can be re-enabled from below you; the guard cannot.
session.upload_progress.enabled is declared ZEND_INI_PERDIR with a compiled-in default of 1
(session.c:849-850). PERDIR means every per-directory layer may set it: a .user.ini in any
customer docroot (CGI/FastCGI), php_flag in .htaccess (mod_php), php_value in a pool file. An
=Off in conf.d is silently undone by one line in one site. The only ini form that locks it is
php_admin_flag in every FPM pool, which still leaves CLI, CGI and mod_php uncovered. The guard
writes NULL into a C function pointer at module init. No ini layer, no ini_set(), no application
code has a way to write that pointer back.
2. The ini gate sits inside the handler; the guard sits in front of it.
With the ini off, the parser still calls into the session extension on every multipart event, and
the handler returns early after consulting the flag (session.c:3103-3108: it first forwards to a
chained callback, then if (!PS(rfc1867_enabled)) return retval;). Any code before that check, or a
future change that moves the check, still runs. With the guard, the parser’s own NULL test skips
the call: the session extension never sees a multipart event at all.
3. One mechanism covers every SAPI and every installed version.
phpenmod -s ALL (Debian), a php.d drop-in (EA4), a php.conf.d drop-in (CustomBuild) loads the
guard into fpm, cli, cgi and apache2 for every discovered version, including a phpMyAdmin-only one.
The ini equivalent is a mix of php_admin_flag per pool, conf.d for CLI, php_admin_flag in
Apache vhosts for mod_php, each with its own way to be missed.
4. It is verifiable per process, not per config file.
php --ri hp_uploadprogress_guard reports whether the callback was actually detached in the
running build, and grep hp_uploadprogress_guard /proc/<fpm-master-pid>/maps shows it is mapped in
the live master. An ini value only tells you what one file says, not what won after all layers were
merged.
The ini setting stops at that handler. The module started there in v1 and, release by release, took on
the rest of what the official fix does: the hardened parser, the memory headroom, the out-of-memory
exit, the request-state reset and the OPcache compile window. That is the difference in coverage, on
top of the difference in mechanism.
Compatibility
- PHP versions: 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5 (one source
file, no per-version patches). 5.4 and 5.5 use the 5.6 parser copy, which
config.m4 and config.w32
pick automatically; their prebuilt files are made by build-legacy.sh, which compiles PHP 5.4.45 /
5.5.38 from the php.net source archives (no official Docker image exists) and builds the module against
them, with the same tests and the same glibc gate as the others. Old patch releases of a branch (7.4
before 7.4.14, 8.0.0) build too: the parser copies carry a compat define for the temp-file flag those
releases lack.
- ABI: a PHP extension’s ABI is the Zend module API number of the minor version plus the NTS/ZTS
flavour (checked at load time). The prebuilt files are NTS x86_64 and load on any NTS build of that
minor: Sury, Remi, cPanel EA4, DirectAdmin CustomBuild, the official Docker images. ZTS builds need
a rebuild from source.
- Thread-safe SAPIs (Apache
mod_php with mpm_winnt, worker or event; the Windows ts DLLs): the
multipart handler is installed per thread since v3.2.3; earlier versions only covered the startup thread
there, which phpinfo did not show. On a threaded SAPI, check phpinfo through the web server, not php --ri.
- Other extensions that replace the POST handlers (Suhosin, and anything that registers post entries
from a Zend-extension startup hook): they install after every module’s MINIT and therefore win, in any
load order; the module does not fight that. Suhosin’s own multipart parser then handles the body with
Suhosin’s limits,
--ri/phpinfo reports “handler replaced => no (another extension installed its own
handler in this thread)”, and the other layers stay active. Measured with the NewEraCracker Suhosin fork
on PHP 5.6 (#14).
- CPU architecture: prebuilt files for x86_64 and aarch64 (arm64), both built on the same old-glibc
images (
build.sh, ARCHS="x86_64 aarch64", aarch64 under QEMU). Highest glibc symbol version required:
GLIBC_2.3 on x86_64 (memcpy is bound to its original symbol version in src/hp_glibc_compat.h, so
CentOS 6, Debian 6 and anything newer load the files; verified against the stock PHP 5.4.16 of CentOS 7),
GLIBC_2.17 on aarch64 (that architecture’s baseline, EL7 aarch64 and newer). The code has nothing
architecture-specific. Windows x64 DLLs come from the CI workflow (dist/windows/).
- libc: since v2 the binaries carry the multipart parser and therefore do import versioned glibc
symbols. They are built on the oldest Debian image that ships each minor (stretch for 5.6 to 7.3,
buster for 7.4 to 8.1, bullseye for 8.2 to 8.4, bookworm for 8.5) and
build.sh refuses any file
that needs more than GLIBC_2.14 (objdump -T), so they load on Debian 8+, Ubuntu 14.04+ and EL 7+.
Do not rebuild them on a glibc 2.38+ host without that check: strtoll then binds to
__isoc23_strtoll@GLIBC_2.38 and the file refuses to load on anything older.
Install
Every version is published as a GitHub Release
with one download: hp_uploadprogress_guard-<version>.zip (or .tar.gz, same content), holding every Linux .so
and Windows DLL, the ini files, the source, install_guard.sh and an INSTALL.txt with the steps per platform,
all covered by a SHA256SUMS inside. The single files are also in dist/ on main. Watch the repository with
“Custom > Releases” to be notified of new versions.
Build from source (any PHP, any flavour)
cd src && phpize && ./configure && make
# -> modules/hp_uploadprogress_guard.so ; `make install` drops it in extension_dir
If make stops with libtool: Version mismatch error (PHP 5.x phpize ships older libtool macros than the
system libtool, seen on Gentoo, #13), regenerate the build files once after phpize:
libtoolize --copy --force && aclocal && autoreconf --force --install, then ./configure && make again.
Prebuilt (Linux)
dist/ holds one NTS build per PHP minor and CPU architecture, with SHA256SUMS:
- x86_64:
dist/hp_uploadprogress_guard-<X.Y>.so
- arm64 (aarch64, e.g. Graviton, Ampere, Raspberry Pi OS 64-bit):
dist/hp_uploadprogress_guard-<X.Y>-aarch64.so
Pick the file for your minor version and uname -m, copy it to php -n -r 'echo PHP_EXTENSION_DIR;' as
hp_uploadprogress_guard.so, and add an ini with extension=hp_uploadprogress_guard.so to the scan dir of every
SAPI (the snippets below do exactly that; on arm64 add -aarch64 to the file name). The Ansible task files pick
the architecture from ansible_facts['architecture'].
Windows
dist/windows/ holds a DLL per PHP minor (5.4, 5.6, 7.2 to 8.5), thread safety and compiler, with SHA256SUMS:
php_hp_uploadprogress_guard-<X.Y>-<nts|ts>-<vc9|vc11|vc15|vs16|vs17>-<x64|x86>.dll, 64-bit and 32-bit. The 7.2 to
8.5 files are built by the Windows build workflow in this repository with the PHP team’s
php-windows-builder; in the same run the x64 nts ones are loaded
into a stock Windows PHP and every x86 one into the official windows.php.net x86 build of its branch
(--ri output in the job log). The 5.6 files (VC11, x64 and x86, nts and ts) come
from the Windows build PHP 5.6 (VC11) workflow: Visual Studio 2012 Express is installed on the runner from
Microsoft’s ISO, PHP 5.6.40 is built in-tree with the extension as a shared module, and every DLL is loaded
into the official 5.6.40 VC11 zip from windows.php.net before it is published. The 5.4 files (VC9, x86, nts and
ts; PHP 5.4 on Windows was only ever released as x86) come from the Windows build PHP 5.4 (VC9) workflow: the
Visual C++ 2008 compiler and Windows SDK 6.0A are unpacked from Microsoft’s Visual Studio 2008 Express ISO,
PHP 5.4.45 is built in-tree, and every DLL is loaded into the official 5.4.45 VC9 x86 zip. A 5.4.45 build loads
into every 5.4.x (same extension API).
php -i | findstr /C:"PHP Version" /C:"Thread Safety" /C:"Compiler" /C:"extension_dir"
# e.g. 8.3.x, Thread Safety => disabled (nts) or enabled (ts), Compiler => Visual C++ 2019 (vs16)
copy dist\windows\php_hp_uploadprogress_guard-8.3-nts-vs16-x64.dll "C:\php\ext\php_hp_uploadprogress_guard.dll"
# then in php.ini: extension=hp_uploadprogress_guard and restart IIS / Apache
# PHP 5.6 takes the file name only: extension=php_hp_uploadprogress_guard.dll (the bare name needs 7.2+)
php --ri hp_uploadprogress_guard
The compiler tag must match your PHP build (php -i prints it): vc15 for 7.2 to 7.4, vs16 for 8.0 to 8.3, vs17
for 8.4 and 8.5, which are also the builds windows.php.net ships. Thread safety must match too (IIS FastCGI uses
nts, Apache mod_php uses ts); 5.4 is vc9 (x86 only), 5.6 is vc11, and php -i shows Architecture => x86 or x64. PHP 7.0/7.1 on
Windows are not provided; those build from source with the PHP SDK: phpize && configure --enable-hp-uploadprogress-guard && nmake from
the repository root (config.w32 picks the parser copy; PHP 5.x has no phpize on Windows, build in-tree as the
5.6 workflow does). PHP 5.x thread-safe builds compile since v3.2.2.
Debian / Ubuntu with Sury packages
install_guard.sh does the steps below for every PHP version under /etc/php (or the ones you name with
--php X.Y), x86_64 or arm64. It downloads the module for each version, checks it against SHA256SUMS,
loads it in a separate PHP process first, swaps the .so in atomically, and installs the ini only if none
is there yet, so a mode or allow_ips you set survives updates. Without --reload it touches no running
service: the module is active for the CLI at once and for PHP-FPM / Apache after their next reload. With
--reload it runs php-fpmX.Y -t / apache2ctl -t, reloads gracefully, and then checks that the running
master really has the module loaded. Re-run it to update; --remove undoes everything. The checksum
catches a broken download, not a compromised source: read the script, and pin --ref to a commit you
reviewed.
curl -fsSLO https://raw.githubusercontent.com/HOSTED-POWER/php_uploadprogress_guard/main/install_guard.sh
less install_guard.sh
sudo bash install_guard.sh --reload # or: --php 8.3, --ref <commit>, --remove
Run from an unpacked release bundle, it installs the files next to it and downloads nothing (servers without
internet access): tar xzf hp_uploadprogress_guard-<version>.tar.gz && sudo bash hp_uploadprogress_guard-<version>/install_guard.sh --reload.
By hand, per version:
V=8.3
install -m 0644 dist/hp_uploadprogress_guard-$V.so "$(php$V -n -r 'echo PHP_EXTENSION_DIR;')/hp_uploadprogress_guard.so"
install -m 0644 ansible/mods-available-hp_uploadprogress_guard.ini /etc/php/$V/mods-available/hp_uploadprogress_guard.ini
phpenmod -v $V -s ALL hp_uploadprogress_guard # the ini is just "; priority=20" + "extension=hp</version></version></commit></x64></vc9></nts></x></x></x></version></fpm-master-pid></name></x></x>
> README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。
评论