Skip to content

gh-160499: Pause asyncio TLS reads when SSL replies pile up - #160500

Open
gpshead wants to merge 2 commits into
python:mainfrom
gpshead:scanfix-sslproto-rnwrq22w
Open

gpshead wants to merge 2 commits into
python:mainfrom
gpshead:scanfix-sslproto-rnwrq22w

Conversation

@gpshead

@gpshead gpshead commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

SSLProtocol read flow control only looked at the incoming BIO, so records OpenSSL writes on its own while processing a non-reading peer's input (TLS 1.2 renegotiation alerts, TLS 1.3 KeyUpdate replies) accumulated in the outgoing BIO without any bound. This counts that non-application output toward the read high-water mark and re-checks it from resume_writing(), so the transport stops reading from a peer that does not take the replies it solicits and resumes once it does. Application output is deliberately left out of the sum so that two peers which both write before they read cannot deadlock. The bound is coarse because the check runs after a whole transport read has been processed, so a single ~256 KiB read can still leave about 5.6 MB in the outgoing BIO before reads pause; resume_writing() now re-checks reading in every state rather than only from _do_read().

Fixes #160499

ANT-2026-RNWRQ22W

SSLProtocol read flow control only looked at the incoming BIO, so records
OpenSSL writes on its own while reading a non-reading peer (renegotiation
alerts, KeyUpdate replies) grew the outgoing BIO without bound.  Count that
non-application output toward the read high-water mark and re-check it when
writing resumes.

ANT-2026-RNWRQ22W
@gpshead gpshead added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 23, 2026
@gpshead gpshead self-assigned this Oct 23, 2026
@gpshead gpshead added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 23, 2026
@gpshead gpshead added the type-security A security issue label Oct 23, 2026
@gpshead gpshead added the sprint label Oct 23, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Oct 23, 2026
@gpshead
gpshead marked this pull request as ready for review October 23, 2026 21:34
@gpshead
gpshead requested a review from picnixz as a code owner October 23, 2026 21:34
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.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes sprint type-security A security issue

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

asyncio TLS server memory grows without bound for a peer that stops reading

1 participant