On this page
Facts
What it is
Disguise layer in front of another proxy, usually Shadowsocks
Since, by
2022, ihciah (shadow-tls, written in Rust)
Transport
TCP only
Encryption
None of its own; v3 adds HMAC tags
To the network it looks like
TLS to a popular site, with that site's real certificate
Usual port
443
Comes as
No common link; sing-box JSON or a mihomo plugin
License
MIT
Latest release
shadow-tls v0.2.25, December 13, 2023
In Veli
Not supported
Versions and history
- Aug 2022
v1
The relay passes the handshake to a real site and watches for its end, so only TLS 1.2 works; after it the proxy's bytes go raw.
- Oct 2022
v2
shadow-tls 0.2.0. The client puts an 8-byte HMAC over everything the server sent in front of its first data, data goes in TLS records, and TLS 1.3 works. Connections without the tag stay with the real site.
- Feb 2023
v3
The ClientHello carries an HMAC, the relay proves itself by tagging the real site's records, and every data record has a 4-byte HMAC. Strict mode allows only handshake sites with TLS 1.3. The handshake idea comes from restls.
- 2023
“Chasing Shadows” at FOCI
Researchers from the University of Colorado Boulder and elsewhere find v1 relays by three probes, about 15,000 suspects on the Internet. Their fix went into v0.2.3.
- Dec 2023
shadow-tls 0.2.25
The last release of the original program so far. The protocol lives on in sing-box (v3 since 1.2) and mihomo.
How ShadowTLS works
On the server there are three parties: the ShadowTLS relay on port 443, a handshake site you pick (a popular one, such as a large company's domain) and the data server, usually Shadowsocks on the same machine. In v3 a connection goes like this:
- 1
ClientHello with a signature
The client starts TLS with the handshake site's name in SNI. The last 4 bytes of its 32-byte session ID are an HMAC of the ClientHello, keyed with the password.
- 2
The real site answers
The relay checks the HMAC. Without it, the connection is simply relayed to the real site, so a probe or a browser meets that site. With it, the handshake is still forwarded, and the real site answers with its own certificate.
- 3
The relay proves itself
The relay alters the real site's Application Data records: XOR with SHA-256 of the password and ServerRandom, plus a 4-byte HMAC. The client recognises them. If they don't match, someone is in the middle, and the client sends a decoy HTTP request and closes.
- 4
The switch
The client sends its first data record with an HMAC; the relay stops talking to the real site and joins the stream to the data server.
- 5
Data
Each record is TLS Application Data with a 4-byte HMAC inside, keyed separately for each direction. A bad tag gets a TLS alert, as a real TLS server would send.
v1, v2 and v3: what each version changed
Both sides must speak the same version. In sing-box version defaults to 1, so a v3 config has to say "version": 3; the original program takes --v3 on both sides. The v3 document explains the move from v2: a man in the middle could tamper with data, split records or take over the connection, and the server had no quiet way to prove who it was.
TLS of the handshake site
v1 (2022)1.2 only
v2 (2022)1.2 or 1.3
v3 (2023)1.3 in strict mode, 1.2 allowed otherwise
Client proves itself
v1 (2022)No
v2 (2022)8-byte HMAC in its first data
v3 (2023)HMAC in the ClientHello session ID
Relay proves itself
v1 (2022)No
v2 (2022)No
v3 (2023)HMAC on the real site's records
Data after the handshake
v1 (2022)Raw proxy bytes
v2 (2022)In TLS records
v3 (2023)In TLS records, 4-byte HMAC each
Known problem
v1 (2022)Found by probes and passive analysis
v2 (2022)Open to a hijacked connection
v3 (2023)No published attack known to us
A sing-box client config, field by field
{
"outbounds": [
{
"type": "shadowtls",
"tag": "st",
"server": "203.0.113.10",
"server_port": 443,
"version": 3,
"password": "Wq7vK2pTz9",
"tls": {
"enabled": true,
"server_name": "www.example.com",
"utls": { "enabled": true, "fingerprint": "chrome" }
}
},
{
"type": "shadowsocks",
"tag": "ss",
"server": "203.0.113.10",
"server_port": 443,
"method": "2022-blake3-aes-128-gcm",
"password": "q3Vx0dK2mY7cL1pN9sT4wA==",
"udp_over_tcp": true,
"detour": "st"
}
],
"route": { "final": "ss" }
}shadow-tls --v3 server --listen 0.0.0.0:443 --server 127.0.0.1:8388 --tls www.example.com --password Wq7vK2pTz9The same in sing-box: a shadowtls inbound with handshake, users and strict_mode, whose detour names a shadowsocks inbound.
- server, server_port of
shadowtls: your server, on 443 like a real site. - version: 3 and password: must match the server.
- tls.server_name: the borrowed site, not yours. The client sees its real certificate.
- utls: Chrome's ClientHello instead of Go's. The FOCI 2023 paper found the original client's ClientHello unique; sing-box's docs now mark uTLS as not recommended, as it has been fingerprinted before.
- detour: st: Shadowsocks goes through the ShadowTLS outbound. Its own
serverandserver_portare then ignored: ShadowTLS connects where it is told. - udp_over_tcp: ShadowTLS carries TCP only, so UDP rides inside Shadowsocks by sing-box's own protocol; the server must be sing-box or mihomo for that.
- route.final: ss: without it sing-box takes the first outbound, and ShadowTLS alone carries nothing useful.
ShadowTLS, Reality and AnyTLS
ShadowTLS v3 (February 2023) and Reality (Xray 1.8.0, March 2023) came out within weeks of each other and solve the same problem: a server that shows a popular site's name without a domain of its own. They do it differently, and AnyTLS, often named next to them, deals with another part of the traffic.
Who completes the TLS handshake
ShadowTLS v3The real site; the relay passes it on
RealityYour server, as the chosen site
AnyTLSYour server, with your certificate
Own domain
ShadowTLS v3Not needed
RealityNot needed
AnyTLSNeeded for a real certificate
Encryption after the handshake
ShadowTLS v3None of its own; Shadowsocks inside
RealityThe TLS 1.3 session with your server
AnyTLSThe TLS session with your server
A probe without the key
ShadowTLS v3Relayed to the real site
RealityForwarded to the chosen site
AnyTLSClosed, or a fallback web server
TLS inside TLS
ShadowTLS v3Not padded
RealityPadded by VLESS's Vision flow
AnyTLSFirst writes padded
Where
ShadowTLS v3sing-box, mihomo, shadow-tls
RealityXray, sing-box, mihomo
AnyTLSsing-box, mihomo
What a censor sees
On the wire: a ClientHello with the borrowed site's name, that site's genuine ServerHello and certificate chain, then TLS Application Data. Nothing in the handshake is fake. What doesn't fit is the address: the site's name resolves to its own servers, not to your VPS. The FOCI 2023 authors looked at redirecting such connections to the “right” address and judged it likely to break legitimate traffic.
That paper, “Chasing Shadows: A security analysis of the ShadowTLS proxy” (Gaukas Wang, Jackson Sippe, Hai Chi, Eric Wustrow and an anonymous co-author, FOCI 2023), tested v1 (shadow-tls 0.1.4). Its client's TLS fingerprint was absent from a university network's dataset; a plain HTTP request to port 443 got a bare FIN, as from 17% of servers; random bytes after the handshake were silently ignored, as by 0.14% of 30 million TLS hosts; a corrupted data record got no alert, as from 0.12%. Combined, only 0.05% of hosts, about 15,000, behaved this way. The fix, forwarding anything unauthenticated to the real site, went into v0.2.3, and v3 keeps it.
The traffic after the handshake is another matter. In the USENIX Security 2024 study by Diwen Xue and colleagues, the classifier recognised 83% of Shadowsocks-over-ShadowTLS flows by the browser's TLS handshake showing through: ShadowTLS doesn't pad, and multiplexing was off, as by default. The paper doesn't say which version it tested.
What isn't known: we found no published measurement of v3 against a national filter, and none of an attack on v3's own design.
Strengths and weaknesses
Strengths
- Shows a real popular site's handshake and certificate, no domain needed
- v3 sends probes and unauthenticated connections on to the real site
- v3 notices a hijacked connection and backs off with a decoy request
- Works in front of any TCP proxy; Shadowsocks 2022 is the usual pair
Weaknesses
- No padding: TLS inside TLS shows through, 83% detected in a 2024 study
- TCP only; UDP needs udp-over-tcp inside Shadowsocks
- Two protocols to configure, and no common share link
- The server's address doesn't belong to the borrowed site's name
- The original shadow-tls hasn't had a release since 2023 and has no Windows build
Where it works
Programs and servers from our comparison tables that list this protocol.
Clients
- Hiddify
- NekoBox for Android
Servers and panels
- S-UI
Sources
- shadow-tls repository (ihciah)
- ShadowTLS protocol design: v1 and v2
- ShadowTLS v3 protocol
- sing-box docs: ShadowTLS outbound
- sing-box docs: ShadowTLS inbound
- FOCI 2023: Chasing Shadows, a security analysis of the ShadowTLS proxy
- USENIX Security 2024: Fingerprinting obfuscated proxy traffic (Xue et al.)
- REALITY repository (XTLS)