Skip to content

gh-150751: validate http.client Content-Length and chunk-size#150752

Open
metsw24-max wants to merge 1 commit into
python:mainfrom
metsw24-max:httpclient-strict-length-parsing
Open

gh-150751: validate http.client Content-Length and chunk-size#150752
metsw24-max wants to merge 1 commit into
python:mainfrom
metsw24-max:httpclient-strict-length-parsing

Conversation

@metsw24-max
Copy link
Copy Markdown

@metsw24-max metsw24-max commented Jun 2, 2026

Noticed begin and _read_next_chunk_size derive the response body framing from int(length) and int(line, 16), but int also accepts a leading sign, underscores, surrounding whitespace and an 0x prefix that RFC 9112 forbids for Content-Length (1DIGIT) and chunk-size (1HEXDIG). So +5, 5_0 or a negative chunk size parse cleanly here while a strict front end frames the response differently. This matches both tokens against the grammar before converting.

RFC 9112 defines Content-Length as 1*DIGIT and chunk-size as 1*HEXDIG, but int() also accepts a sign, underscores, surrounding whitespace and an 0x prefix, so malformed framing values were parsed instead of rejected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant