Repository navigation
Conversation
With a custom ClientHelloSpec and an ECH config list, MarshalClientHello built the ClientHelloInner with makeClientHello, from the Config's defaults, and copied the outer's key shares, signature algorithms, session ID and groups into it. A server that accepts ECH negotiates with the inner hello, so it saw three cipher suites and Go's extension set instead of the browser's: no GREASE, no ALPS, no compress_certificate and, since the inner's ALPN came from Config.NextProtos, no ALPN unless the application set one. Parroting a browser with real ECH gave the origin a Go fingerprint. Build the inner hello from the spec's extensions as BoringSSL derives Chrome's from one configuration: the outer's GREASE and TLS 1.3 cipher suites; server_name with the configured name, the inner ECH marker and supported_versions with TLS 1.3 only, uncompressed and first, in outer order; the TLS 1.2-only extensions, padding and pre-shared keys left out; everything else the outer's, compressed, in one run after them. Config.NextProtos still replaces the spec's ALPN in the inner only. The inner is marshaled from the extension objects and parsed back, so the handshake's checks see the bytes the server does, and its encoded form is derived from those bytes. A HelloRetryRequest rebuilds it from the outer's updated extensions, keeping the inner random. That path also refreshed the outer's key share from the outer hello instead of the retried one, so ECH with a HelloRetryRequest failed on the custom path; it completes now with ECH accepted and the retried group. The inner hello offers psk_key_exchange_modes as the browser's does, so servers issue tickets to these connections; testECHSpec opts out of loading them, since resumption with a custom ECH ClientHello is still unsupported.
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.
With a custom
ClientHelloSpecandConfig.EncryptedClientHelloConfigListset,UConn.MarshalClientHellobuilt the ClientHelloInner withmakeClientHello, that is from theConfig's defaults, and copied the outer's key shares, signature algorithms, session ID and groups into it. A server that accepts ECH negotiates with the inner hello, so it saw three cipher suites and Go's extension set instead of the browser's: no GREASE, no ALPS, nocompress_certificate, and, since #383 routed the inner's ALPN throughConfig.NextProtos, no ALPN at all unless the application set one. Parroting a browser with real ECH therefore produced a Go fingerprint at the origin.This change builds the inner hello from the spec's extensions the way BoringSSL derives Chrome's from one configuration (
ssl_add_clienthello_tlsext_innerandssl_write_client_cipher_listinssl/):server_namewith the configured name,encrypted_client_hellowith the inner marker, andsupported_versionswith the outer's GREASE values and TLS 1.3 only: these differ from the outer's and come first, uncompressed, in outer order;renegotiation_info,extended_master_secret,session_ticket,ec_point_formatsandnext_protocol_negotiationare TLS 1.2-only and left out, as are padding and pre-shared keys;ech_outer_extensions.Config.NextProtos, when set, still replaces the spec's ALPN in the inner hello only, uncompressed, so #383's use case keeps working; otherwise the inner carries the spec's ALPN, compressed, as Chrome's does.The inner hello is marshaled from the extension objects and parsed back into a
clientHelloMsg, so the handshake's checks on the accepted hello see the same bytes the server does, and the encoded form is derived from those bytes rather than from Go's field marshaller, which cannot express the spec's extensions. A HelloRetryRequest rebuilds the inner from the outer's updated extensions, keeping the inner random. That path also had a bug: the outer's key share was refreshed fromhs.hello, the outer, instead of from the hello the retry regenerated, so ECH with a HelloRetryRequest failed on the custom path with "illegal parameter" or "invalid server key share". It now completes, with ECH accepted and the retried group negotiated.Tests run the Chrome and Firefox specs with real ECH against a Go server holding the ECH key, record the inner hello it negotiates with, and compare it to the rules applied to the outer hello actually built, with and without a HelloRetryRequest, plus the
NextProtosoverride. The inner hello now offerspsk_key_exchange_modesas the browser's does, so servers issue tickets to these connections;testECHSpecopts out of loading them, since resumption with a custom ECH ClientHello is still unsupported.Verified with Go 1.27.3:
go test ./...,go test -raceon the ECH tests,go vet,gofmt -s,go fix -diff, staticcheck and golangci-lint report nothing.