Repository navigation
HelloRetryRequest as uTLS answers it: one key share, the cookie's place, padding per flight (stacked on #256) - #258
Merged
Conversation
A HelloRetryRequest broke a uTLS-shaped hello in three ways (OpenSSL 3.5's s_server, on main before #252 as on #256): the second ClientHello kept the GREASE key share next to the one the server asked for, which OpenSSL and Go's crypto/tls refuse with illegal_parameter; a cookie could not be placed, so the second ClientHello was never built; and the padding kept the first flight's target. Pins shaped-rustls ca91d48c (aimalygin/shaped-rustls claude/hrr-retry-shaping): a retry that names a group gets rustls's single key share, without the plan's raw and GREASE shares, and ClientHelloPaddingPlan::boringssl(offset) applies BoringSSL's rule to every ClientHello. Here: - The cookie: HelloDraws draws its place as uTLS's p.Intn(len(Extensions) - 2), and planned_extensions puts 0x002c there in the hello's extension list (the drawn order plus an ALPN extension the http/1.1 override appends); the order and the GREASE positions read that one list. shaped-rustls drops the entry from a ClientHello carrying no cookie, so first-flight bytes are unchanged. - Padding: boringssl(offset) with offset = 2 x the suites the provider filters - 7 for the supported_versions rustls adds to a TLS-1.2-era hello. utls_unpadded_len, which modelled the server name, the ALPN list and the ECH draw for the first flight, goes: the fork measures each ClientHello. Tests: a scripted HelloRetryRequest server (a group: the requested share alone; a cookie: echoed at every place but the last two over 512 retries, the key shares unchanged; Chrome 120 padded per flight); the offset against all 30 committed uTLS hellos; the BoringSSL sweep on the per-flight mode. Live, ignored: OpenSSL s_server -groups P-256, and Xray-core's TLS inbound held to P-256. Docs and CHANGELOG describe the retry.
aimalygin
changed the base branch from
claude/xray-v26-11-9-ech-grease-length
to
main
November 10, 2026 16:18
aimalygin
pushed a commit
that referenced
this pull request
Nov 10, 2026
… into claude/finalmask-udp-direct
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.
Stacked on #256 (base:
claude/xray-v26-11-9-ech-grease-length); the coordinator retargets it tomainonce #256 is merged. It pins shaped-rustls ca91d48c from aimalygin/shaped-rustls#1. On 2026-11-10 the owner allowed changing the fork to fix this in 0.10.0. Merging needs the owner's word, together with the fork PR.What broke
A uTLS-shaped hello mishandled a HelloRetryRequest. Against OpenSSL 3.5.9's
s_server, results on main before #252 (7b58fa5) and on #256 alike:-groups P-256). Every Chrome profile's second ClientHello kept the GREASE key share next to the P-256 one. RFC 8446 §4.1.2 asks for the requested share alone. OpenSSL answeredillegal_parameter, and Go's crypto/tls server refuses the same.uTLS keeps the requested share alone, inserts the cookie at
p.Intn(len(Extensions) - 2), anywhere but the last two places, and pads by the second ClientHello's length (handshake_client_tls13.go). It takes a server sharing no key share group with the profile, or one sending a cookie, to ask for a retry; for the Chrome profiles that means neither X25519 nor X25519MLKEM768. A server held to P-256, such as a FIPS-only one, broke every Chrome-shaped handshake.Changes
ClientHelloPaddingPlan::boringssl(offset)applies BoringSSL's rule to each ClientHello as it is encoded.HelloDrawsdraws the cookie's place as uTLS'sp.Intn(n - 2)does.planned_extensionsputs0x002cthere in this hello's extension list: the drawn order plus the ALPN extension thehttp/1.1override appends.boringssl(offset)withoffset = 2 × (suites the provider filters) − 7 for the supported_versions rustls adds to a TLS-1.2-era hello. Every other extension is as long as uTLS's.utls_unpadded_len, which modelled the server name, the ALPN list and the ECH draw, is gone: the fork measures each ClientHello.Tests
tests/utls_hello_retry_tests.rs, a scripted server sending hand-built HelloRetryRequests:chrome, 133, 131, 120 and 120_pq: the second ClientHello carries the P-256 share alone.chrome, 133, andrandomizednoalpnwith thehttp/1.1override (which appends ALPN):0..n-2;utls_shaping:the_padding_offset_brings_our_hellos_to_utls_lengths: our unpadded length plus the offset equals uTLS's, for all 30 committed oracle hellos, each ECH length and thehttp/1.1override's shapes included;the_padding_offset_counts_filtered_suites_and_the_added_supported_versions;s_server -groups P-256(ignored test,XRAY_HRR_OPENSSL):chrome, 133, 131 and 120 complete. Before the fix every Chrome profile gotillegal_parameter.curvePreferences: ["CurveP256"](new ignored test; the HelloRetryRequest comes from Go itself): 16 flows each forchrome, 133, 131 and 120.s_server -statelessis not used. It is the onlys_servermode that sends a cookie, but it closes the connection after its HelloRetryRequest for OpenSSL's owns_clienttoo, so it cannot judge the cookie path. The scripted test covers that path.-D warningsare clean. The full workspace test against the fork commit passes: 143 test binaries, 3830 tests, none failed.Docs
config-compatibility.md: the padding paragraph now describes the per-flight rule. Chrome ECH GREASE length per connection, padding as BoringSSL pads #256's HelloRetryRequest paragraph becomes how a retry is answered.CHANGELOG.md: new entry.🤖 Generated with Claude Code