Skip to content

fix(echcheck): do not attempt a TLS handshake when the TCP connect failed - #1817

Open
macintoshi-nakamoto wants to merge 1 commit into
ooni:masterfrom
macintoshi-nakamoto:bugfix/1728
Open

fix(echcheck): do not attempt a TLS handshake when the TCP connect failed#1817
macintoshi-nakamoto wants to merge 1 commit into
ooni:masterfrom
macintoshi-nakamoto:bugfix/1728

Conversation

@macintoshi-nakamoto

@macintoshi-nakamoto macintoshi-nakamoto commented Sep 9, 2026

Copy link
Copy Markdown

Checklist

Description

handshake() in internal/experiment/echcheck dials the target and then calls tls.Client(conn, ...).HandshakeContext() without checking whether the dial succeeded. When it did not, conn is nil and crypto/tls panics 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, as min-ng.test.defo.ie:15443 did.

The change returns the test keys right after the failed TCP connect has been recorded, since that is the measurement: a tcp_connects entry with the failure and no tls_handshakes entry, because no handshake was attempted. No shape of TestKeys changes.

The regression test binds a port on localhost, closes it, and runs startHandshake against 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 with go 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.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant