Commit ab7b3a2
Sjoerd Langkemper
Validate chunk extension in dechunk filter
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.
#21983
https://httpwg.org/specs/rfc9112.html#chunked.encoding1 parent 7c67283 commit ab7b3a2
2 files changed
Lines changed: 62 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1781 | 1781 | | |
1782 | 1782 | | |
1783 | 1783 | | |
1784 | | - | |
| 1784 | + | |
| 1785 | + | |
1785 | 1786 | | |
1786 | 1787 | | |
1787 | 1788 | | |
| |||
1820 | 1821 | | |
1821 | 1822 | | |
1822 | 1823 | | |
1823 | | - | |
| 1824 | + | |
1824 | 1825 | | |
1825 | 1826 | | |
1826 | 1827 | | |
| |||
1831 | 1832 | | |
1832 | 1833 | | |
1833 | 1834 | | |
1834 | | - | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
1835 | 1863 | | |
1836 | 1864 | | |
1837 | 1865 | | |
| |||
1915 | 1943 | | |
1916 | 1944 | | |
1917 | 1945 | | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1918 | 1952 | | |
1919 | 1953 | | |
1920 | 1954 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments