Repository navigation
Port the fork onto metacubex/utls v1.9.0-alpha.1 - #6
Merged
Merged
Conversation
After ClientFinished, the REALITY server may remain silent where the configured target emits TLS 1.3 post-handshake records. Learn target post-handshake record lengths asynchronously per destination, SNI, ALPN mode and cipher suite, then emit matching encrypted application-data records before marking the handshake complete. Probe failures preserve existing behavior, probes are coalesced and rate-limited, and RealityConfig clones share the cache. Client-side REALITY behavior is unchanged. (cherry picked from commit 0eed8b0)
A target whose first flight holds a full-size TLS 1.3 record (16384 bytes of plaintext, up to 16645 bytes on the wire) exceeded the 16 KiB buffer and the REALITY handshake was aborted. Use 17 KiB like XTLS/REALITY#33 (Xray v26.9.8). (cherry picked from commit 1a98a45)
Add RealityConfig.Mldsa65Seed, the 32-byte seed of Xray's "mldsa65Seed". When set, the server uses a temporary certificate whose first extension (OID 0.0) carries an ML-DSA-65 signature, as XTLS/REALITY does: the HMAC over the ed25519 public key keyed with the auth key is continued over the raw ClientHello and the raw ServerHello, and its digest is signed deterministically with an empty context. Xray clients configured with "mldsa65Verify" require this signature. Keys come from github.com/metacubex/mldsa (crypto/mldsa backported to Go 1.20). Test vectors generated with cloudflare/circl, which Xray uses, prove that seeds expand to the same public keys and produce the same signatures. RealityMldsa65Verify returns the "mldsa65Verify" value for a seed. (cherry picked from commit ebc62b0)
Add RealityConfig.RequireX25519MLKEM768 (default off). When set, a ClientHello is only considered for REALITY authentication if it carries exactly one X25519MLKEM768 key share placed before an optional X25519 key share; anything else is forwarded to the target. This mirrors Xray's rule from XTLS/REALITY@8cdf7bf, which rejects outdated or unusual ClientHellos. The key share selection moves to realityClientPeerPub; without the flag it behaves as before (X25519, else the X25519 part of X25519MLKEM768). (cherry picked from commit 37238a1)
(cherry picked from commit 5ad21de)
UConn.MarshalClientHello ignored the error from computeAndUpdateOuterECHExtension. With ECH configured and a ClientHelloSpec that cannot carry ECH (e.g. no ECH extension), the handshake went on and wrote a ClientHello without a sealed inner hello. Return the error so nothing is sent. (cherry picked from commit 3a71ed0)
…onVerify The callback is documented to verify the ECH provider certificate, but it was called before peerCertificates was set, so ConnectionState.PeerCertificates was always empty (same as upstream Go, golang/go#75242). Set the peer certificates before calling it. (cherry picked from commit d00159d)
MinVersion documents TLS 1.2 as the default minimum, but with the tls10server GODEBUG knob stubbed out the server side kept accepting TLS 1.0 and 1.1 when MinVersion was 0. Apply the default to servers as in crypto/tls; an explicit MinVersion still allows older versions. (cherry picked from commit 9f70311)
ClientHelloSpec.UnmarshalJSON dereferenced nil cipher_suites, compression_methods or extensions when they were missing; it now returns an error, and the ClientHelloSpecJSONUnmarshaler accessors are nil-safe. ImportTLSClientHello sliced key_share in 4-byte steps without checking the length, panicking on truncated input, and read only the low byte of each key_exchange length. Reject input that is not a whole number of entries and use the full 16-bit length. (cherry picked from commit a3a2a55)
Roller.Dial moved on to the next ClientHelloID without closing the connection whose handshake had failed, leaking one socket per attempt. (cherry picked from commit 2b28146)
decompressCert allocated the peer-declared uncompressed_length (up to 16 MiB) before any check. Reject lengths above maxHandshakeCertificateMsg, the limit already applied to uncompressed Certificate messages. It also used a single Read, which can return less than the full message (zlib returns 32 KiB chunks), failing valid certificates over that size; use io.ReadFull. (cherry picked from commit 22b73c4)
The ML-KEM code ignored errors from crypto/rand.Read. Since Go 1.24 that call crashes on failure, but this module supports older Go, where it returns the error and the seed or encapsulation message would stay all-zero. Read through a helper that panics on failure, matching the fatal behaviour of Go's own ML-KEM DRBG. (cherry picked from commit 5f40e26)
internal/mlkem moved to mlkem and internal/hpke became the hpke package with a different API. Point the REALITY key share code at mlkem and build the ECH test config list from RFC 9180 identifiers.
hkdf.Expand and hkdf.Key panicked on a negative length or one above 255 hash blocks; check both and return an error, as crypto/hkdf does. ConnectionState.ExportKeyingMaterial panicked on a negative length and, in TLS 1.3, on a label longer than HkdfLabel allows or a length beyond the HKDF limit (lengths over 65535 would also have been truncated in the HkdfLabel). Return errors instead; signatures are unchanged. (cherry picked from commit fe273b2)
Using a single cursor, reject malformed encodings and esnure that each outer extension is copied at most once. Fixes CVE-2026-97031 For golang/go#81855 Fixes golang/go#81915 Change-Id: I5b09f2b6275d42f7701fae4e583eb3a2caeaa44d Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/5320 Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/6160 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/847105 Auto-Submit: Gopher Robot <gobot@golang.org> TryBot-Bypass: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Neal Patel <nealpatel@google.com> (cherry picked from commit e798688)
…andshake Port of Go commit b6432317a (release-branch.go1.26). After the handshake, KeyUpdate messages reset the non-advancing record counter, so a peer could keep sending them and force key derivation indefinitely. Only application data, and handshake messages before the handshake completes, now count as state-advancing. (cherry picked from commit c4444fe)
Go 1.26 on Linux and Windows with go vet, the minimum Go 1.20 on Linux, and a race detector run. Replaces the upstream matrix of 30 jobs. (cherry picked from commit b0d9724)
The client goroutine in testUtlsHandshake assigned the ApplyPreset result to the named return err, which the test goroutine also writes, and returned without sending on errChan when it failed. (cherry picked from commit 42cb40a)
(cherry picked from commit a6af36b)
A write of more than one record sent every record with its own write to the connection, and the network stack is paid per write. The records of one write are now encrypted in place one behind the other and written together, up to eight full-sized records (about 128 KiB) at a time. Nothing is held back: all of it is written before the call returns. (cherry picked from commit b76689d)
…anged (cherry picked from commit 5b1b53d)
(cherry picked from commit bc98cb6)
(cherry picked from commit 9c481dd)
Port the Chrome 155 profile from refraction-networking/utls 6ebdceb ("Add Chrome 155 fingerprint verified against a fresh browser capture"), verified there against Chrome 155.0.8059.40. Compared with Chrome 133 the ClientHello gains a GREASE value and the three ML-DSA schemes (0x0904/0x0905/0x0906) in signature_algorithms and the trust_anchors extension (0xca34) with 28 Chrome Root Store IDs. - HelloChrome_155 and its spec; HelloChrome_Auto now points to it, as upstream does. HelloChrome_133 is unchanged. - TrustAnchorsExtension (typed, JSON, Fingerprinter via ExtensionFromID). - GREASE in signature_algorithms drawn from its own BoringSSL seed slot; the internal seed grows to 8 slots while GetBoringGREASEValue keeps its [5]uint16 signature. - MLDSA44/65/87 SignatureScheme constants and dicttls names. Unlike upstream (go 1.27 sync) this fork does not implement ML-DSA, so the codepoints are only advertised. - Upstream tests and the captured ClientHello fixture. Not ported: the ML-DSA handshake test (needs crypto/mldsa) and the preset ownership test (needs upstream's ClientHelloSpec.clone). (cherry picked from commit 540608d)
slices is not in the Go 1.20 standard library; use reflect.DeepEqual and a loop instead. (cherry picked from commit a3a3d53)
v1.9 clones the ClientHelloSpec in ApplyPreset, so the preset ownership test from refraction-networking/utls 6ebdceb can now be ported: neither the reusable spec nor other connections may see per-connection changes, including the nested trust anchor IDs.
The v1.9 port lives on dev-1.9 next to dev; test pushes and pull requests there too. go.mod still says go 1.20, so the matrix keeps Go 1.20 and 1.26.
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.
Ports the fork's commits (
v1.8.8..dev, a6dee38) onto metacubex/utlsv1.9.0-alpha.1(go1.26 crypto/tls base).dev-1.9was created at the v1.9.0-alpha.1 tag (89a07ad).Commit classification
internal/mlkem->mlkem)mlkem/go.ymlremoved as ondevNew commits:
port: follow the v1.9 mlkem and hpke package layout: REALITY key share imports and the ECH build test (theinternal/hpkeconstants are gone).test: check that ApplyPreset keeps the Chrome 155 preset unshared: v1.9 clones the spec inApplyPreset, so the preset ownership test from refraction 6ebdceb that was left out before is now ported.ci: run on dev-1.9.go.mod still says
go 1.20(v1.9.0-alpha.1 keeps the Go 1.20 minimum), so the CI matrix stays Go 1.20 + 1.26.Tests
go build ./...,go vet -loopclosure=false ./...,go test -count=1 ./...with Go 1.26.1 on Windows: passgo test -count=1 ./...with Go 1.20 (golang:1.20, CGO off): passgo test -race -count=1 ./...with Go 1.26.10 (golang:1.26): pass