Skip to content

reality: carry #7 and the client root re-check onto dev-1.9 - #8

Merged
Miroshka000 merged 3 commits into
dev-1.9from
port/reality-replay-1.9
Dec 5, 2026
Merged

Miroshka000 merged 3 commits into
dev-1.9from
port/reality-replay-1.9

Conversation

@Miroshka000

Copy link
Copy Markdown

Carries the commits of dev that #6 did not bring to dev-1.9:

  • 10f33b9 reality: 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*.go differs from dev only in the mlkem import path.
  • 91e09df fix: 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 inside if len(dnsName) > 0: a session resumed with InsecureServerNameToVerify: "*" skipped the root check, and with InsecureSkipTimeVerify an expired leaf was never resumed. The server side and anyValidVerifiedChain are upstream's and stay as they are.
  • 96d756e test: TestUTLSResumptionChecksRootsWithoutHostName and TestUTLSResumptionSkipTimeVerify, TLS 1.2 and 1.3. They fail before 91e09df and pass after it, and on dev.

Every other commit of dev is on dev-1.9 already, 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 ./... and go 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_name in 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. dev sends no acknowledgement and works with such a target.

Miroshka000 and others added 3 commits December 5, 2026 22:54
…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
Miroshka000 merged commit 0f1b5e1 into dev-1.9 Dec 5, 2026
4 checks passed
@Miroshka000
Miroshka000 deleted the port/reality-replay-1.9 branch December 5, 2026 21:15
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).
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.

2 participants