Repository navigation
tls: close the TLS socket in _TLSAutomaton.destroy() - #5294
Open
glaziermag wants to merge 1 commit into
Open
glaziermag wants to merge 1 commit into
glaziermag wants to merge 1 commit into
Conversation
Automaton.destroy() does not close the TCP socket of a TLS automaton. When test_tls_client() stops the server after a client failure (the invalid ServerKeyExchange signature test from secdev#5248), the server can stop before close_session runs; the accepted socket is then garbage collected during a later test, and its ResourceWarning in the captured stderr fails that test. AI-Assisted: yes (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5294 +/- ##
==========================================
+ Coverage 80.06% 80.66% +0.60%
==========================================
Files 375 375
Lines 98775 98779 +4
==========================================
+ Hits 79083 79680 +597
+ Misses 19692 19099 -593
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since #5248 added a test where the client aborts, the TLS 1.3 tests of
tlsclientserver.utsfail on master with(False, "...ResourceWarning: unclosed <socket.socket ... laddr=('127.0.0.1', 4433), raddr=...>")(15 of the 21 completedScapy unit testsruns on master since then), e.g. https://github.com/secdev/scapy/actions/runs/43394327187/job/131781532428 and https://github.com/secdev/scapy/actions/runs/43394327187/job/131781532621. On that pathtest_tls_client()callsatmtsrv.stop(wait=False)(tlsclientserver.uts#L335-L349), the server can stop beforeclose_sessionruns, andAutomaton.destroy()(automaton.py#L1615-L1634) does not close the socket accepted at automaton_srv.py#L299, so itsResourceWarningis written to the stderr captured by a later test.This closes the socket in
_TLSAutomaton.destroy()and checks it intest_tls_client(). Delaying the server's reads makes the race deterministic; without the change toautomaton.py, tests 19 and 29 then fail on the new check:This message was written with the help of AI (Claude Opus 5.5).
🤖 Generated with Claude Code