RouteHardenHire us
Back to Evasion
Evasion · Part 3 of 7·Anonymity Engineering··12 min read·advanced

TLS-in-TLS and Reality

TLS camouflage, secret-gated fallback, and why looking like HTTPS is harder than just using HTTPS.

After domain fronting receded in 2018-2019, the censorship-evasion ecosystem needed designs that didn't depend on cloud-CDN cooperation. The natural successor goal: make a circumvention server look indistinguishable from a legitimate HTTPS server. The clients should look like normal HTTPS clients; the server should respond like a normal HTTPS server; only with a secret should the proxy functionality activate.

This is harder than it sounds. "Use TLS" isn't enough — TLS alone exposes JA3/JA4 fingerprints, server-side TLS configurations, certificate chains, and behavioral patterns that distinguish a circumvention server from a real one. The HTTPT-style approach (covered in active-probing-methodology) addressed this with co-hosted real websites; REALITY (the Xray/sing-box implementation) takes a different approach: hijack a real website's TLS handshake.

This module covers the TLS-camouflage design space: TLS-in-TLS layering, REALITY's specific mechanism, naïveproxy's HTTP-server-emulation approach, and the ongoing arms race against censors who develop targeted detection. The full practical comparison between Reality and WireGuard already lives at xray-reality-vs-wireguard; this module focuses on the architecture.

Prerequisites

Learning objectives

  1. Explain why "use TLS" doesn't make a server look like a normal HTTPS server.
  2. Describe REALITY's mechanism: hijacking a real website's TLS handshake to provide credible cover.
  3. Compare REALITY's approach with naïveproxy's HTTP-server-emulation and HTTPT's co-hosted-website approach.
  4. Identify the ongoing detection vectors that even careful TLS camouflage doesn't fully address.

Why "use TLS" isn't enough

A proxy server that simply runs TLS isn't camouflaged as HTTPS — it's a TLS-using proxy. Specific things that distinguish it from a real HTTPS server:

TLS configuration. The TLS library and version produce a specific server-side fingerprint (JA4S). A proxy server's JA4S may not match what a real web server (Apache, nginx, Caddy) produces.

Certificate metadata. Real websites have certificates from common CAs (Let's Encrypt, DigiCert, etc.) with typical metadata. A proxy server with a freshly-issued cert from an unusual CA, or a self-signed cert, looks suspicious.

Co-hosting. Real domains usually have many subdomains, MX records, related infrastructure. A proxy on a fresh domain alone is unusual.

HTTP behavior. After TLS handshake, what does the server serve? A normal HTTPS server serves a real website; a proxy server typically doesn't serve anything meaningful for non-proxy clients.

Connection patterns. Real HTTPS sites have characteristic flow patterns (request bursts for resources, idle gaps, specific response sizes). A proxy server has different patterns.

Behavioral consistency. Active probes that test how the server responds to specific inputs reveal differences between proxy and legitimate behavior.

So "TLS camouflage" requires addressing all of these surfaces. The HTTPT-style answer (co-hosted real website) addresses many of them but requires running a real website. The REALITY-style answer takes a more aggressive approach: don't pretend to be a real website — hijack a real one.

REALITY: hijacking a real website's TLS

REALITY (developed by the Xray project) does something architecturally novel. Instead of running a website that pretends to be real, REALITY takes the TLS handshake from a real website (e.g., www.microsoft.com) and uses it as cover for proxy connections.

The mechanism (simplified):

Setup.

  • The REALITY server is configured with a target domain (the "cover" domain, e.g., www.microsoft.com).
  • The REALITY server has a public-private keypair distinct from the cover domain.
  • Clients are pre-configured with the REALITY server's address and the cover domain's name and the REALITY public key.

Connection flow.

  1. Client opens TCP to the REALITY server's IP, port 443.
  2. Client sends TLS ClientHello with SNI = www.microsoft.com (the cover domain).
  3. The REALITY server forwards the ClientHello to the real www.microsoft.com to get a real ServerHello + Certificate. (This happens server-side; the client doesn't see this fork.)
  4. The REALITY server returns the real ServerHello + Certificate to the client. The certificate is genuinely valid for www.microsoft.com because it came from www.microsoft.com.
  5. The client validates the certificate normally — it's a real, valid certificate.
  6. Client and server complete TLS handshake using the keys derived from the (legitimate) ServerHello.
  7. Client sends a special handshake message authenticated against the REALITY public key. If the message is valid, the REALITY server switches to proxy mode. If not, REALITY proxies the entire connection through to the real www.microsoft.com, so the client gets a normal Microsoft response.

For an active prober without the REALITY public key:

  • They connect to the REALITY server.
  • TLS handshake completes with a valid Microsoft certificate.
  • They send normal HTTP requests; the REALITY server proxies them to real Microsoft.
  • They receive real Microsoft responses.

The probe sees a fully-functional Microsoft website. The TLS handshake, the certificate, the response content — all real. The REALITY server is indistinguishable from "a server that hosts (or proxies to) Microsoft's site."

For an authenticated REALITY client:

  • They connect, complete the TLS handshake with the Microsoft cert.
  • They send the special authentication that uses the REALITY public key.
  • The server recognizes this and switches to proxy mode.
  • All subsequent communication is proxy traffic, not Microsoft traffic.

The cleverness: the cover domain's TLS handshake is used as actual TLS handshake, not as a simulation. The certificate validation succeeds for both legitimate and proxy clients. The difference is what happens after the handshake — and only authenticated clients trigger the proxy behavior.

Why REALITY is harder to detect than predecessors

Compared to obfs4 (per-bridge secret, but the bridge serves nothing without the secret), REALITY provides convincing fallback (the bridge serves real Microsoft to anyone without the secret). Compared to meek (relied on CDN cooperation), REALITY needs no third-party policy support — the TLS handshake material comes from the cover site, but the server is independent.

The detection difficulty for an adversary:

  • Passive observation. Sees a TLS handshake to Microsoft, with a real Microsoft certificate, followed by HTTPS-shaped traffic. Indistinguishable from real Microsoft browsing without per-flow content inspection.
  • Active probing. Probes the server with a real browser; gets a real Microsoft response. The server passes any probe that doesn't include the REALITY-specific authentication.
  • TLS fingerprint analysis. The server-side TLS config (JA4S) is from the cover site (Microsoft). Indistinguishable from real Microsoft.
  • Certificate analysis. Cert is valid for Microsoft. No CT-log anomaly.
  • Client TLS fingerprint. REALITY clients use uTLS to match real browser TLS fingerprints. Indistinguishable from a real browser.

What can detect REALITY:

  • Behavioral analysis. Real users browsing Microsoft have specific patterns (load page, fetch resources, idle, follow links). A REALITY user has continuous traffic without the typical browsing pattern. Statistical analysis can flag this.
  • IP-level analysis. REALITY servers are individual IPs; real Microsoft is a specific Microsoft IP space. Connections to "Microsoft" from a non-Microsoft IP are suspicious. Censors can identify suspect IPs through traffic patterns.
  • Connection patterns. REALITY connections may be longer-lived than typical browsing sessions.
  • Volume. A REALITY user's traffic to "Microsoft" may be much higher than a typical Microsoft visitor's.

These behavioral signals are softer than direct fingerprinting; they require statistical analysis over time and have higher false-positive rates than deterministic detection. China's GFW has reportedly developed REALITY-detection tools but with imperfect accuracy.

naïveproxy: an alternative HTTP-server emulation

naïveproxy (developed by klzgrad) takes a different approach: don't run a special TLS protocol; run an actual web server that happens to accept proxy requests over the same TLS endpoint.

The mechanism:

  • naïveproxy server runs on top of Caddy (a real web server).
  • Caddy serves a real (or seemingly-real) website on the domain.
  • naïveproxy intercepts certain HTTP requests (those bearing specific authentication) and treats them as proxy requests.
  • All other requests are served as normal website content.

The result: the server is genuinely a Caddy web server. Its TLS handshake is genuinely a Caddy TLS handshake (using uTLS to match Chrome's fingerprint). Its HTTP behavior is genuinely Caddy's. Only the authenticated proxy requests trigger different behavior.

The difference from REALITY:

  • naïveproxy hosts a real website (you must provide content); REALITY can hijack any external site's TLS material.
  • naïveproxy is genuinely Caddy underneath; REALITY is a custom-coded proxy.
  • naïveproxy depends on the specific Caddy/uTLS behavior; REALITY uses generic uTLS.

Both achieve high probe-resistance through different architectural patterns.

What detection still works

Even with REALITY or naïveproxy, certain detection patterns persist:

Statistical anomaly detection. Continuous-traffic patterns to "browser-like" destinations are unusual. ML classifiers can flag suspect connections without identifying the specific protocol.

Server-side IP analysis. If an IP claims to be Microsoft but isn't in Microsoft's announced address space, that's suspicious. Censors maintain databases of which IPs belong to which organizations.

Long-term behavioral observation. A user who connects to "Microsoft" for hours every day from a new IP raises flags.

Active probing variants. While REALITY's primary handshake is convincing, sophisticated probes that test edge cases (TLS extensions Microsoft doesn't usually include, specific request patterns Microsoft doesn't usually serve) can sometimes distinguish.

Aggregate traffic analysis. A user whose daily traffic to "Microsoft" is gigabytes is unusual.

These detection mechanisms have higher false-positive rates than the direct fingerprinting that earlier transports failed at. They flag suspicion rather than confirmation. Censors using them face a tradeoff: aggressive blocking has collateral damage; conservative blocking misses some circumvention.

Hands-on exercise

Secret-gated fallback pseudocode.

Tools: notes. Runtime: 10 minutes.

Sketch the REALITY server logic:

on tls_clienthello_received(client_socket, clienthello):
  cover_target = "www.microsoft.com"

  # Forward the ClientHello to the real cover site to get its ServerHello
  upstream = open_tls_to(cover_target, port=443)
  send(upstream, clienthello)
  serverhello = receive(upstream, "ServerHello+Certificate")

  # Return the real cover site's ServerHello to the client
  send(client_socket, serverhello)

  # Complete the TLS handshake using cover site's keys
  client_kex = receive(client_socket, "ClientKeyExchange+Finished")

  # Forward to upstream to complete; receive the Finished from upstream
  send(upstream, client_kex)
  upstream_finished = receive(upstream, "Finished")
  send(client_socket, upstream_finished)

  # Now both sides have a valid TLS session secured by cover site's certificate.

  # Read the first application data from the client
  first_data = receive(client_socket, application_data)

  # Check for the REALITY authentication marker
  if is_reality_authenticated(first_data, REALITY_PUBLIC_KEY):
    # Switch to proxy mode
    close(upstream)  # we don't need the cover site connection anymore
    handle_proxy_traffic(client_socket)
  else:
    # Normal client without REALITY auth — proxy through to the real cover site
    send(upstream, first_data)
    bidirectional_relay(client_socket, upstream)

Identify the key properties:

  • The TLS handshake is genuinely with the cover site's certificate (forwarded from the real cover site).
  • An active prober without the REALITY public key gets the real cover site's response.
  • Only authenticated clients trigger proxy behavior.

Camouflage strategy comparison.

StrategyIdentity to passive observerProbe response (no secret)Operational requirement
obfs4Random encrypted bytesNo useful responseBridge management; uTLS not required
meek (fronted)TLS to a major CDNThe CDN's normal responseCooperative CDN policy
HTTPTReal websiteReal website's normal responseRun a real co-hosted website
REALITYReal website (hijacked TLS)Proxy through to real cover siteuTLS; cover-site selection
naïveproxyReal Caddy serverCaddy serves real contentRun Caddy; provide website content

The pattern: each strategy addresses the "look like something real" problem with different operational tradeoffs. REALITY is the most architecturally clever; naïveproxy is the most operationally simple; HTTPT is the most academically pure.

Common misconceptions and traps

"REALITY is undetectable." REALITY is hard to detect with deterministic methods. Statistical and behavioral methods can still flag it with imperfect accuracy. Calling it undetectable overstates its security.

"Using uTLS makes a tool look like Chrome." uTLS makes the TLS handshake look like Chrome. The TCP fingerprint, HTTP/2 behavior, and traffic patterns can still differ from real Chrome. Multi-layer impersonation is hard.

"naïveproxy is just an HTTP proxy." It is, but with significant uTLS-based TLS impersonation, custom HTTP behavior to match Chrome's request patterns, and Caddy-based realistic web-server behavior. The "just" understates the integration.

"REALITY needs server-side cooperation from the cover site." It doesn't — REALITY uses the cover site's responses without involving the cover site as a partner. Microsoft doesn't know it's being used as a cover.

"REALITY is faster than obfs4." It depends. REALITY adds latency from the upstream-cover-site round-trip during handshake (the proxy server has to fetch the real ServerHello). After handshake, both can be fast.

"Once REALITY is detected, all REALITY users are exposed." The detection methods are statistical and probabilistic. A given REALITY user's risk depends on their individual traffic patterns, not just whether REALITY exists.

Wrapping up

TLS-in-TLS camouflage and the REALITY family of designs occupy the post-domain-fronting niche: provide HTTPS-camouflage for circumvention without depending on third-party CDN cooperation. REALITY's specific contribution is hijacking a real website's TLS handshake; naïveproxy and HTTPT achieve similar ends with different architectural choices.

These designs raise the cost of detection significantly. Active probes get convincing real-website responses; TLS fingerprints match popular browsers; certificate chains are genuinely valid. The remaining detection vectors (statistical, behavioral, IP-level) require more adversary effort and produce more false positives.

The arms race continues. Censors develop new detection techniques; designers update their tools. As of 2026, REALITY remains effective in many environments but is not a permanent solution — no design is.

The next module (hysteria-and-quic-based-transports — coming soon) covers QUIC-based circumvention, where the substrate change addresses different censor capabilities.

Further reading