Skip to content

[3.14] gh-150743: Limit trailer lines and interim responses read by http.client#150749

Draft
gpshead wants to merge 2 commits into
python:3.14from
gpshead:gh-150743-http-client-line-reading-limits-314
Draft

[3.14] gh-150743: Limit trailer lines and interim responses read by http.client#150749
gpshead wants to merge 2 commits into
python:3.14from
gpshead:gh-150743-http-client-line-reading-limits-314

Conversation

@gpshead
Copy link
Copy Markdown
Member

@gpshead gpshead commented Jun 2, 2026

http.client read chunked-response trailer lines and skipped interim (1xx)
responses in unbounded loops, so a server streaming either forever would
hang the client even with a socket timeout set (data keeps arriving, so
the timeout never fires).

Trailer lines are now limited to max_response_headers (100 by default)
and interim responses to 100; HTTPException is raised past either limit.

Follow-up to gh-88188 for CVE-2021-3737, which bounded header lines
within an interim response but not these two sibling loops.


This issue was reported to us via GHSA-w4q2-g22w-6fr4

gpshead added 2 commits June 2, 2026 03:02
A server could stream syntactically valid trailer lines forever after
the final chunk of a chunked response, so reading the response would
never return.  Socket timeouts cannot interrupt this because data
keeps arriving within every timeout window.  Trailer lines are now
counted against the same limit as response headers (100 by default)
and HTTPException is raised when the limit is exceeded.

(cherry picked from commit 752bef5047e54e21af0e48a339b54fbae2a6c831)
HTTPResponse.begin() skipped 100 Continue responses in an unbounded
loop, so a server streaming them forever would hang getresponse()
regardless of any socket timeout.  At most 100 interim responses are
now skipped before HTTPException is raised.

(cherry picked from commit 508e86d8811e8e17350bf2c6fb23d3bb2d3ff795)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant