Skip to content

gh-160520: Apply asyncio ssl_shutdown_timeout after peer EOF - #160521

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:scanfix-sslproto-81hubbj7
Oct 25, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:scanfix-sslproto-81hubbj7

Conversation

@gpshead

@gpshead gpshead commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

SSLProtocol._on_shutdown_complete() cancelled the shutdown timer, or had none if the peer sent EOF before close(), and then called the non-aborting close() of the underlying transport, so a peer that half-closed and stopped reading kept the connection open with no time limit. The timer is now kept (or started) on the success path and cancelled by connection_lost() as before, so _check_shutdown_timeout() aborts the transport if its write buffer has not drained in time.

One behaviour change to be aware of: a peer that half-closes and then needs longer than ssl_shutdown_timeout to read the data still queued for it is now cut off with TimeoutError, as a peer that does not half-close already is.

Fixes #160520

ANT-2026-81HUBBJ7

@gpshead gpshead added 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.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 23, 2026
@gpshead
gpshead marked this pull request as ready for review October 23, 2026 22:03
@gpshead
gpshead requested a review from picnixz as a code owner October 23, 2026 22:03
@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 draft October 23, 2026 22:50
@gpshead

gpshead commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

leave as a draft while working out the windows testing issue

Keep the SSL shutdown timer running until connection_lost(), and start
it when the peer shuts down first, so that a peer which sends EOF but
does not read cannot keep a closed transport open indefinitely.
@gpshead
gpshead force-pushed the scanfix-sslproto-81hubbj7 branch from 6d52b93 to e5239db Compare October 24, 2026 07:10
@gpshead
gpshead marked this pull request as ready for review October 25, 2026 05:51
@gpshead
gpshead merged commit ffe1315 into python:main Oct 25, 2026
55 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@github-project-automation github-project-automation Bot moved this from Todo to Done in Sprint Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160639 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160640 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 25, 2026
@gpshead
gpshead deleted the scanfix-sslproto-81hubbj7 branch October 25, 2026 05:56
gpshead added a commit that referenced this pull request Oct 25, 2026
…H-160521) (#160640)

gh-160520: Apply asyncio ssl_shutdown_timeout after peer EOF (GH-160521)

Keep the SSL shutdown timer running until connection_lost(), and start
it when the peer shuts down first, so that a peer which sends EOF but
does not read cannot keep a closed transport open indefinitely.

ANT-2026-81HUBBJ7
(cherry picked from commit ffe1315)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gpshead added a commit that referenced this pull request Oct 25, 2026
…H-160521) (#160639)

gh-160520: Apply asyncio ssl_shutdown_timeout after peer EOF (GH-160521)

Keep the SSL shutdown timer running until connection_lost(), and start
it when the peer shuts down first, so that a peer which sends EOF but
does not read cannot keep a closed transport open indefinitely.

ANT-2026-81HUBBJ7
(cherry picked from commit ffe1315)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

asyncio SSL transport ignores ssl_shutdown_timeout after the peer sends EOF

1 participant