Skip to content

fix(ech): draw the GREASE ECH payload length like BoringSSL - #430

Open
fabifont wants to merge 1 commit into
refraction-networking:masterfrom
fabifont:fix/grease-ech-payload-length
Open

fabifont wants to merge 1 commit into
refraction-networking:masterfrom
fabifont:fix/grease-ech-payload-length

Conversation

@fabifont

Copy link
Copy Markdown

BoringSSL draws the payload length of its GREASE ECH extension on every connection: 32 bytes times a random integer in [4, 7], plus the AEAD tag, so Chrome sends 144, 176, 208 or 240 bytes (ssl/encrypted_client_hello.cc, setup_ech_grease). NSS instead pads a fake inner hello from the SNI once and sends that length every time (tls13_MaybeGreaseEch, tls13_PadChInner). Captured locally: Chromium 153 sends all four lengths across 18 hellos; Firefox 157 sends 240 bytes on every one of 40 hellos with hostnames up to 100 characters, and 272 beyond that, with the AEAD alternating between AES-128-GCM and ChaCha20.

uTLS sends one fixed length in two cases where BoringSSL varies:

  • A GREASEEncryptedClientHelloExtension with no CandidatePayloadLens, which is what a JSON spec or a hand-written spec gets unless it calls BoringGREASEECH(), picks 128 and so sends 144 bytes every time.
  • A spec fingerprinted from a Chrome capture replays the capture's one length on every connection.

The HPKE suite half of this mismatch was CVE-2026-27017 (#375): the Chrome parrots now keep AES, as BoringSSL keeps its hardware choice. The length half was not reported.

This change shares BoringSSL's four lengths between BoringGREASEECH() and the default for an empty CandidatePayloadLens, and makes FromRaw replay a captured GREASE ECH with BoringSSL's draw when the capture carries RFC 8701 GREASE values, which BoringSSL sends and NSS does not. A capture without them keeps its one length, as Firefox does. The length alone cannot tell the stacks apart, since Firefox's 240 is one of BoringSSL's four. The extension's own Write still records the captured length faithfully, and the Firefox parrots are unchanged.

Tests cover the zero-value default, Write() on an AES and a ChaCha20 capture, and a fingerprint-and-replay round trip through ApplyPreset: a GREASE-bearing hello with a 208-byte payload must vary over the four lengths, and a GREASE-free hello with a 240-byte payload must send 240 every time.

Verified with Go 1.27.3: go test ./..., go test -race on the ECH tests, go vet, gofmt -s, go fix -diff, staticcheck and golangci-lint report nothing.

Refs #375

BoringSSL draws the payload length of its GREASE ECH extension on every
connection, 32 bytes times a random integer in [4, 7] plus the AEAD tag,
so Chrome sends 144, 176, 208 or 240 bytes. NSS pads a fake inner hello
once from the SNI and sends that length every time: Firefox 157 sends
240 bytes on every connection. uTLS sent one fixed length where
BoringSSL varies: an extension with no CandidatePayloadLens picked 128
and so sent 144 bytes every time, and a spec fingerprinted from a Chrome
capture replayed the capture's one length on every connection. The
suite half of this mismatch was CVE-2026-27017.

Share BoringSSL's four lengths between BoringGREASEECH() and the default
for an empty CandidatePayloadLens, and make FromRaw replay a captured
GREASE ECH with BoringSSL's draw when the capture carries RFC 8701
GREASE values, which BoringSSL sends and NSS does not. A capture without
them keeps its one length, as Firefox does; the length alone cannot tell
the stacks apart, since Firefox's 240 is one of BoringSSL's four. The
Firefox parrots are unchanged.

Refs: refraction-networking#375
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