Skip to content

gh-150743: Limit trailer lines and interim responses read by http.client#150741

Open
gpshead wants to merge 4 commits into
python:mainfrom
gpshead:http-client-line-reading-limits
Open

gh-150743: Limit trailer lines and interim responses read by http.client#150741
gpshead wants to merge 4 commits into
python:mainfrom
gpshead:http-client-line-reading-limits

Conversation

@gpshead
Copy link
Copy Markdown
Member

@gpshead gpshead commented Jun 1, 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 and was determined not to be high enough severity to handle privately.

gpshead added 2 commits May 30, 2026 04:34
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
(max_response_headers, 100 by default) and HTTPException is raised
when the limit is exceeded.
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.
@gpshead gpshead self-assigned this Jun 1, 2026
@gpshead gpshead added the type-security A security issue label Jun 1, 2026
@gpshead gpshead changed the title gh-XXXXXX: Limit trailer lines and interim responses read by http.client gh-150743: Limit trailer lines and interim responses read by http.client Jun 1, 2026
@gpshead gpshead added 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 needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 1, 2026
@gpshead gpshead marked this pull request as ready for review June 2, 2026 01:49
@gpshead gpshead requested a review from sethmlarson June 2, 2026 01:49
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32946995 | 📁 Comparing 7c5757b against main (27ebd9a)

  🔍 Preview build  

2 files changed
± library/http.client.html
± whatsnew/changelog.html

@gpshead gpshead removed 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 needs backport to 3.14 bugs and security fixes labels Jun 2, 2026
@gpshead
Copy link
Copy Markdown
Member Author

gpshead commented Jun 2, 2026

3.14 and earlier backport in #150749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.15 pre-release feature fixes, bugs and security fixes type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants