Repository navigation
Conversation
Every VLESS or AnyTLS proxy with client-fingerprint set got this and
nothing else:
client-fingerprint (uTLS) is not yet implemented, ignored for main-out
Reality connected and carried traffic, but the ClientHello was
recognisably rustls: no GREASE, no signed_certificate_timestamp, no ALPS,
and a cipher list that was exactly the suites rustls implements. That
separates it from a browser before a byte of application data moves,
which is the one thing Reality exists to prevent.
The mechanism is rustls ClientHelloProfile (Watfaq-legacy/rustls#11). What is
here is the browser table, taken from uTLS HelloChrome_133 rather than
from memory, and confined to one file.
chrome, edge, android, 360, qq Chrome 133
random, randomized rustls own hello, plus GREASE
anything else random, with a warning
That last line is deliberate. Firefox and Safari are real profiles that
are simply not modelled; substituting Chrome for them silently would be
worse than saying so, because a config asking for Firefox and getting
Chrome is a mismatch nobody would think to look for.
The Chrome profile sets the cipher list (fifteen suites in order, six of
which rustls cannot negotiate and advertises anyway - the count and order
are the fingerprint), GREASE across suites, groups, key shares and
versions, the group order that makes rustls derive Chrome's key share
pair on its own, Chrome's eight signature algorithms via a verifier
wrapper, and renegotiation_info, signed_certificate_timestamp and ALPS as
verbatim extensions. ALPN falls back to h2,http/1.1 only where the caller
has none: a transport that must negotiate h2 has a functional
requirement, and looking like a browser does not outrank it.
Two differences from Chrome remain, both deliberate rather than missed:
GREASE ECH, and compress_certificate - the latter needs rustls brotli
feature, which would change the hello for every TLS client in clash-rs
and not just fingerprinted ones. Both are noted in the PR.
Without client-fingerprint nothing moves, SCSV included, and there is a
test for it. TlsClient::new keeps its signature; the fingerprint goes
through new_with_fingerprint, so trojan, vmess, socks5 and websocket are
untouched.
Sixteen tests, eight of which read the bytes that actually left a
ClientConnection rather than the struct that produced them: a profile
correct in a struct and lost on the way to the socket would pass any
other kind of test.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CI runs cargo +nightly fmt --check and my code was not run through it. The rustls dependency temporarily points at the branch of Watfaq-legacy/rustls#11 so the build can actually happen - a PR that cannot compile is hard to review. Marked in Cargo.toml as not for merge; it goes back to Watfaq/rustls once that PR lands.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
The last extension separating the Chrome profile from Chrome. It carries random data, negotiates nothing, and its absence is as visible as any other missing extension - the extension set is what the common fingerprints hash. X25519, because that is the KEM browsers GREASE with and the KEM decides the length of the encapsulated key on the wire. Off without the aws-lc-rs feature: that is the only provider rustls ships HPKE for, and there is nothing to build the placeholder from otherwise. Needs the two ECH fixes in the rustls branch this depends on - the KEM was fixed to P-256 there, and GREASE mode pinned TLS 1.3 and so dropped TLS 1.2 from the hello. Two more tests reading the bytes: the placeholder is there with a 32 byte encapsulated key, and TLS 1.2 survived it.
EchGreaseConfig is only reachable with aws-lc-rs, and importing it at the top of the module left it unused everywhere else. With -D warnings that is an error, which is why mips, mipsel and freebsd went red - all three build with -F ring. Moved into the branch that uses it.
Chrome offers it, and without a decompressor rustls omits the extension
entirely. That was the single extension standing between the profile and
Chrome's - measured against tls.peet.ws, JA4 went from
t13d1515h1_8daaf6152771_fa2c1db240d0
to
t13d1516h1_8daaf6152771_d8a2da3f94cd
and the raw form - cipher list, extension list, signature algorithms -
became field for field what uTLS records for HelloChrome_133.
A separate commit because it is a separate decision and not a free one.
It applies to every TLS client in clash-rs, not only fingerprinted ones:
the default hello goes from eleven extensions to twelve, and a brotli
decompressor is linked in. Both are arguably improvements - smaller
handshakes, and a default hello marginally less unlike a browser's - but
dropping this commit is a supported outcome. It costs one extension out
of sixteen.
rustls ships HPKE only for aws-lc-rs, so on a ring build the placeholder is silently absent and the hello comes out one extension short of the profile it claims. Routers are the common case for ring - aws-lc-rs has no MIPS support - so this is not an exotic corner. Caught by reading the ClientHello off a GL-XE300 with tcpdump: fifteen extensions where x86 produced sixteen. The missing key exchange group already warned; this one did not.
The placeholder now comes from EchGreaseConfig::without_provider, so the ring builds - every MIPS and embedded target - get it too. Reading the ClientHello off a GL-XE300 was what turned this up: fifteen extensions where x86 sent sixteen, and encrypted_client_hello the one missing. Needs the matching change in the rustls branch, where GREASE no longer requires an HPKE implementation it has no use for. The key share test was written against aws-lc-rs and failed under ring for a real reason: no X25519MLKEM768 there, so no second share to pair with it. It now checks the property rustls actually guarantees - the share is for the group asked for first - and states the difference between the two providers rather than asserting one of them everywhere.
|
Closing — keeping this in a fork for now rather than asking for review time. Thanks. |
Why
Every VLESS or AnyTLS proxy with
client-fingerprintset gets this:Reality connects and carries traffic, but the ClientHello is recognisably rustls: no GREASE, no
signed_certificate_timestamp, no ALPS, and a cipher list that is exactly the fifteen-minus-six suites rustls happens to implement. That separates it from a browser before a byte of application data moves, which is the one thing Reality exists to prevent.What changed
client-fingerprintis now applied, for VLESS (Reality and plain TLS) and for AnyTLS.The numbers come from uTLS
HelloChrome_133, not from memory —clash-lib/src/common/tls_fingerprint.rsis the whole table, and it is the only file that knows anything about browsers.chrome,edge,android,360,qqrandom,randomizedrandomwith a warningThat last row is deliberate. Firefox and Safari are real profiles that are simply not modelled here; quietly substituting Chrome for them would be worse than saying so, because a config asking for Firefox and getting Chrome is a mismatch nobody would think to look for.
What the Chrome profile sets
renegotiation_info— rustls signals "no renegotiation" with the SCSV in the cipher list; browsers use the extension. Pinning the suite list removes the SCSV, so the extension takes its place.signed_certificate_timestampand ALPS (0x44cd, the codepoint Chrome 133 uses) as verbatim extensions.h2, http/1.1— only when the caller has none of its own. A transport that must negotiate h2 has a functional requirement, and looking like a browser does not outrank it.aws-lc-rsfeature: rustls only ships HPKE for that provider.compress_certificate— brotli, the only algorithm Chrome offers. See the note on thebrotlifeature below.Measured, not just asserted
The tests say the profile is assembled correctly. This says what actually left the socket, read back from
tls.peet.ws:t13d1011h1_61a7ad8aa9b6_f9531d972513client-fingerprintt13d1012h1_61a7ad8aa9b6_41631feb4e62client-fingerprint: chromet13d1516h1_8daaf6152771_d8a2da3f94cdThe middle row is the whole cost of the
brotlicommit, stated below: one extension more on every connection, and the cipher hash unchanged.1516is fifteen cipher suites and sixteen extensions, which are Chrome's counts.h1rather thanh2is the probe's own doing — it speaks HTTP/1.1 so it can read the reply, and JA4 records the ALPN it saw.The raw form is the part worth reading:
Cipher list, extension list and signature algorithms: field for field what uTLS records for
HelloChrome_133.On hardware, and what it changed
Flashed onto a GL-XE300 (
mips_24kc, OpenWrt 25.12.5) running podkop with a real VLESS+Reality outbound, and the ClientHello read back off the wire with tcpdump:Tunnel healthy throughout — 148, 155, 157 ms across three delay tests — and the
client-fingerprint (uTLS) is not yet implementedline is gone from the log.But the profile is provider-dependent, and routers get the reduced one. The MIPS targets build with
-F ring, and against x86 with aws-lc-rs the same code produced sixteen extensions and five groups. Two things are missing on ring, both for the same reason:encrypted_client_helloringhas no ML-KEMSo on a router the hello is
15 ciphers / 15 extensionsagainst Chrome's15 / 16, and the group list is X25519, P-256, P-384 where Chrome leads with the post-quantum hybrid.Neither is silent — the code says so:
Worth knowing before anyone assumes a router build gets the same disguise a desktop build does. Closing either gap means HPKE and ML-KEM for
ring, which is upstream rustls work, not this PR.The one line that touches everything else
Chrome offers brotli certificate compression. Without a decompressor rustls omits the extension entirely, and that was the single extension standing between
1515and1516.It is a separate commit because it is a separate decision, and not a free one: it applies to every TLS client in clash-rs, not only fingerprinted ones. The default hello goes from eleven extensions to twelve, and a brotli decompressor is linked in. Both are arguably improvements — smaller handshakes, and a default hello marginally less unlike a browser's — but dropping the commit is a supported outcome. The cost of dropping it is one extension out of sixteen.
No fingerprint, no change
Without
client-fingerprintnothing about the hello moves, SCSV included. There is a test asserting it, because a feature like this quietly altering every other connection would be a bad trade.TlsClient::newkeeps its signature; the fingerprint goes throughnew_with_fingerprint, so trojan, vmess, socks5, websocket and the rest are untouched.Tests
Nineteen, and eleven of them read the bytes that actually left a
ClientConnectionrather than the struct that produced them — a profile correct in a struct and lost on the way to the socket would pass every other kind of test:signed_certificate_timestamp, ALPS andrenegotiation_infopresent with the right bodiesrenegotiation_inforeplaced ith2, http/1.1compress_certificateoffers brotli and only brotlirandom, never to Chrome