Repository navigation
reality: carry #7 and the client root re-check onto dev-1.9 - #8
Merged
Merged
Conversation
…ead of the first client Two ways a REALITY server told itself apart from its target. A recorded ClientHello could be sent again for as long as its time stayed valid (MaxTimeDiff, forever with none). The server answered the copy itself: whoever replays cannot finish that handshake, but the server's behaviour towards it is its own and not the target's. The server now remembers the ClientHellos it accepted, by their random, for both sides of the time check (an hour with no check), in two bounded generations shared with clones, and hands a second copy to the target like any stranger's, so the copy gets the target's own answer. The target's post-handshake records were learned by a probe that the first client of each (target, SNI, ALPN, cipher suite) started and did not wait for, so that client got none of the records the target sends, unlike every client after it. Now the patterns of the usual handshakes (each server name, h2, each TLS 1.3 suite) are learned on the first connection of any kind; the probe of another key starts as soon as the target's ServerHello names the suite; a client whose pattern is still being learned waits for it, until two seconds after the probe began, so a probe that hangs holds up only the clients of its first moments; and a probe ends once the target has been quiet for 400 ms, or for as long as its own dial and handshake took, instead of always sitting out the five-second window. (cherry picked from commit 313357d)
Port of Go's GO-2026-4337 fix (crypto/tls: check verifiedChains roots when resuming sessions). Session ticket keys are shared between a Config and its clones (Clone, GetConfigForClient), so a session established under one ClientCAs/RootCAs could be resumed under another. On resumption the client and server now require at least one stored verified chain to be unexpired and rooted in the current RootCAs/ClientCAs; the Clone doc warns that VerifyPeerCertificate does not run on resumed connections. (cherry picked from commit 865a03c) On v1.9 most of it is already in from Go: the server checks, anyValidVerifiedChain and the regression tests (1dcb033, 6d07980), and the Clone doc (fd5128b). resumption_trust_test.go would declare those tests a second time, so only the client hunk is carried. uTLS's merge of Go 1.26 (ec54fa8) ran the client check only when a host name is verified, and against the clock: with InsecureServerNameToVerify "*" a session resumed under roots that no longer trust its chain, and with InsecureSkipTimeVerify the session of an expired chain, which a full handshake accepts, never resumed. The check now runs for every verified session, at the leaf's NotAfter under InsecureSkipTimeVerify, as the full handshake does.
…hain Go's regression tests for GO-2026-4337 cover neither uTLS option that changes how the client verifies a chain, and v1.9 got both wrong until the previous commit. With InsecureServerNameToVerify "*" a session has to stop resuming once its root leaves RootCAs; with InsecureSkipTimeVerify the session of an expired chain, which the full handshake accepted, has to resume. Both run over TLS 1.2 and 1.3.
Miroshka000
added a commit
to Miroshka000/mikan
that referenced
this pull request
Dec 6, 2026
getmikan/utls#8, merged into dev-1.9 as 0f1b5e1e, puts there what the utls of Citrus beta.4 lacked: #7, with which REALITY takes a ClientHello once and learns the target's records ahead of the first client, as the nodes have had it since 0245022, and the client-side re-check of a resumed session's roots. Citrus needs the same pin. Checked: go build, vet, the core's tests in internal/node (REALITY targets, the strict names), internal/proto, internal/sub/mihomo, cmd/mikan (TestDepsLinkNoCore) and cmd/mikan-node; the PR's CI (race, Go 1.20, Go 1.26 on ubuntu and windows).
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.
Carries the commits of
devthat #6 did not bring todev-1.9:10f33b9reality: accept a ClientHello once, and learn the target's records ahead of the first client (reality: accept a ClientHello once, and learn the target's records ahead of the first client #7, cherry-picked as is). It hooks into the same places on v1.9;reality*.godiffers fromdevonly in the mlkem import path.91e09dffix: re-check verified chains against the current roots on resumption (the client side of 865a03c). v1.9 has Go's own fix (1dcb033, 6d07980), but only insideif len(dnsName) > 0: a session resumed withInsecureServerNameToVerify: "*"skipped the root check, and withInsecureSkipTimeVerifyan expired leaf was never resumed. The server side andanyValidVerifiedChainare upstream's and stay as they are.96d756etest:TestUTLSResumptionChecksRootsWithoutHostNameandTestUTLSResumptionSkipTimeVerify, TLS 1.2 and 1.3. They fail before91e09dfand pass after it, and ondev.Every other commit of
devis ondev-1.9already, from #6 or from upstream v1.9 (Firefox 148, Safari 26.3, the server-side root re-check).Checked:
go build ./...,go vet -loopclosure=false ./...andgo test ./...on Go 1.26.11 (Windows); the REALITY tests, 38 of them; the resumption tests on Linux (golang:1.26.11). Not checked here: Go 1.20 and-race, left to CI.Found while porting, not fixed here: on v1.9 the REALITY server always acknowledges
server_namein EncryptedExtensions, so its EE is 10 bytes. With a target whose EE is empty (no ALPN chosen, no SNI acknowledgement) the padding goes negative (padding: -4) and every authenticated handshake fails.devsends no acknowledgement and works with such a target.