Repository navigation
reject non-ascii digits in content-length and chunk size - #750
rootvector2 wants to merge 1 commit into
Conversation
Long#parseLong accepts any Unicode decimal digit, and with radix 16 also fullwidth Latin letters, so a connection that decodes message heads with a charset such as UTF-8 parses a Content-Length of U+0661 U+0660 (Arabic-Indic "10") as 10 and a fullwidth 'A' chunk size as 10. RFC 9112 restricts these to 1*DIGIT and 1*HEXDIG. Reject non-ASCII values before parsing in MessageSupport#getContentLength and both chunk decoders.
|
@rootvector2 What good does that do exactly? |
|
On cost, it's one pass over the same short string |
@rootvector2 One needs to explicitly override the default configuration and force the use of By default the library uses ASCII for message elements and the check you re proposing is just a useless overhead. |
Long#parseLongaccepts any Unicode digit (and fullwidthA-Fin radix 16), so with a UTF-8CharsetDecoderMessageSupport#getContentLength,ChunkedInputStream#getChunkSizeandChunkDecoder#readChunkHeadreadContent-Length: ١٠as 10, a framing value RFC 9112 forbids and intermediaries reject, so reject non-ASCII values next to theisSignedOrEmptycheck from #729 (found by reviewing the #729 parse sites, reproduced over a socket, regression tests added).