[php-src] PR #22036: Validate chunk extension in dechunk filter
| From: | Sjord | Date: | Wed, 13 May 2026 11:57:48 +0000 |
| Subject: | [php-src] PR #22036: Validate chunk extension in dechunk filter | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36116@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22036
Author: Sjord
Chunked transfer encoding has a chunk-size field that can be optionally
followed by a chunk-ext field. This was already skipped by php_dechunk,
by skipping anything that was not a hex character. This changes
php_dechunk to be a little bit more strict in what it considers a
chunk-ext, and treat it as an error and stop decoding if the extension
does not start with optional whitespace and a semicolon.
The dechunk filter is used in some filter chain attacks as an oracle
that determines whether a string starts with a hex character. Anything
after the hex character would be interpreted as the chunk-ext. This
change make that a bit more narrow, also requiring a semicolon, thus
reducing the usefulness of the dechunk filter for attackers.
This only changes behavior on invalid chunked encoding; the happy flow
for valid chunked encoding remains unchanged.
The state CHUNK_SIZE_EXT is renamed to CHUNK_MAYBE_EXT, where the size
of the chunk is read and maybe followed by a chunk-ext. In
CHUNK_VALID_EXT we have detected the semicolon and just skip the rest of
the line.
https://github.com/php/php-src/issues/21983
https://httpwg.org/specs/rfc9112.html#chunked.encoding