fix(echcheck): do not attempt a TLS handshake when the TCP connect failed - #1817
Open
macintoshi-nakamoto wants to merge 1 commit into
Open
fix(echcheck): do not attempt a TLS handshake when the TCP connect failed#1817macintoshi-nakamoto wants to merge 1 commit into
macintoshi-nakamoto wants to merge 1 commit into
Conversation
macintoshi-nakamoto
force-pushed
the
bugfix/1728
branch
from
September 9, 2026 12:47
b2c9dea to
a1ee20f
Compare
…iled When the dial fails, conn is nil and tls.Client(nil, ...).HandshakeContext panics inside crypto/tls. This is what users saw with min-ng.test.defo.ie once its port 15443 stopped answering. Return the test keys after recording the failed TCP connect instead; that is the measurement. Adds a localhost regression test that dials a closed port with and without GREASE. It panics without the fix. Closes ooni#1728
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.
Checklist
Description
handshake()ininternal/experiment/echcheckdials the target and then callstls.Client(conn, ...).HandshakeContext()without checking whether the dial succeeded. When it did not,connis nil andcrypto/tlspanics while writing the ClientHello. This is the trace reported in #1725 and tracked in #1728: it shows up whenever a target stops answering on its port, asmin-ng.test.defo.ie:15443did.The change returns the test keys right after the failed TCP connect has been recorded, since that is the measurement: a
tcp_connectsentry with the failure and notls_handshakesentry, because no handshake was attempted. No shape ofTestKeyschanges.The regression test binds a port on localhost, closes it, and runs
startHandshakeagainst it with and without GREASE. Without the fix the test panics with the same nil pointer dereference as the issue; with the fix it passes. Verified withgo test -short ./internal/experiment/echcheck/.Small side observation, not addressed here to keep the diff minimal: the TLS conn is never closed after the handshake, so a successful handshake leaks the socket until the process exits. Happy to send that as a separate PR if you want it.