← Back to all chapters

Chapter 26Down the Rabbit Hole: The TLS Packet Anyone Can Send Twice

7 min read
rabbit-holesecuritynetworkingtls

Imagine tapping "Pay". Your phone fires one encrypted packet. A stranger on the cafe wifi can't read it or change it, but can copy it and send it again. And TLS 1.3's 0-RTT mode has no built-in way to say "this is the second copy".

That sounded wrong to me. So I read RFC 8446 properly, and §2.3 says it outright: for early data, "there are no guarantees of non-replay between connections".

The round trip everyone wants back#

On a 100 ms path, time until the first response byte:

SetupRound trips before responseAt 100 ms RTT
TCP + TLS 1.3, full handshake1 (TCP) + 1 (TLS) + 1 (request)300 ms
TCP + TLS 1.3, resumed with a ticketsame300 ms
TCP + TLS 1.3, 0-RTT1 (TCP) + 1 (request rides the first TLS flight)200 ms
QUIC 1-RTT1 (handshake) + 1 (request)200 ms
QUIC 0-RTT1100 ms
  • TCP + TLS 1.3, full300 ms
  • TCP + TLS 1.3, resumed300 ms
  • TCP + TLS 1.3, 0-RTT200 ms
  • QUIC 1-RTT200 ms
  • QUIC 0-RTT100 ms
Time to first response byte on a 100 ms path.

The second row surprised me: resuming with a ticket skips certificates and key exchange but saves no round trip. 0-RTT removes the wait by sending the request in the first flight, glued to the ClientHello. "Zero round trip" is a slight misnomer: it saves exactly one. That's the whole prize.

Where the early key comes from#

In a normal handshake both sides add fresh randomness (ECDHE shares, Random values), so every connection's keys are unique and a recorded message is useless elsewhere.

To send before the server says anything, the client must encrypt under something both already know: the pre-shared key from the ticket. Per §7.1, the early traffic secret comes from the resumption secret, through the PSK and Early Secret, mixed with the hash of the ClientHello. Nothing the server sends today appears in it.

Where the early-data key comes from, and what that costs. Click a box.

That gives both weaknesses at once. No fresh server input: the flight can be replayed. Key from the PSK alone: whoever later gets the server's ticket-encryption key can decrypt recorded early data. What the attacker can't do matters just as much: read, alter or forge early data. They can only duplicate it.

My mental model is a coffee shop. You slide a membership card and a sealed order slip across the counter and the barista starts your flat white. Nobody can read or forge the slip, but anyone can photocopy both and hand them in again, and to the barista the copy is perfect.

ClientAttackerServerClientHello + early datacopies the bytessame bytes, sent againno fresh server input in the key, so the copy looks like the original
Why a copy is perfect: the early flight carries nothing fresh from the server (schematic).

Defense one: remember#

The server keeps notes. RFC 8446 §8's main defense is a replay cache of a fingerprint of each ClientHello it accepted early data from (the PSK binder works). A second sighting means "refuse 0-RTT".

Refusing is gentle. Per §8.2 the server must reject the early data but must not abort: it finishes a normal 1-RTT handshake, discards the early records, and the client resends safely. Only the round trip is lost. So a Bloom filter is allowed: no false negatives, and its only error is wrongly refusing a legitimate client, the safe kind of mistake.

Defense two: forget on schedule#

A cache that remembers forever is unbounded, so there's also a freshness check. The client reports how long it has held the ticket, but not in the clear, since a stable age would let an observer link connections. The server picks a random 32-bit ticket_age_add per ticket:

client:  o  = (a + age_add) mod 2^32
server:  a' = (o - age_add) mod 2^32
 
expected arrival  E = T_issued + RTT_estimate + a'
accept 0-RTT iff  |E - now| <= W        (W about 10 s for Internet clients)

"The client says this ticket is an hour old. I issued it an hour ago, plus one trip. This should land about now. If not, it's old or replayed." It never compares clocks, only clock rates.

expected arrival EE - WE + Woriginalreplaylate replayrejectedthe window limits when, only a cache limits how many times
The freshness window accepts anything that lands near the expected time (schematic, W is about 10 s).

Payoff is memory: entries need to live only about 2W.

Sizing the cache
M = accepts_per_second * 2W * bytes_per_entry
  = 10,000 * 20 s * 32 B
  = 6.4 MB

That's 10,000 early-data accepts a second with a 32-byte hash per entry. A Bloom filter for the same 200,000 entries at one-in-a-thousand false positives is about 360 KB with around 10 hash functions. RAM is not the problem.

The failure: fleets#

It breaks in coordination, not memory. The RFC's MUST-level guarantee is "at most once per server instance", which "limits the number of replays to the number of server instances". Eight servers with their own caches: the attacker replays to all eight, each accepts once.

The dive's standard-library simulator: one captured flight, the age arithmetic above, eight servers, a ±10 s window, 50 replay attempts one second after the original.

ProtectionRuns of one request
None51
Freshness window only51
Freshness + one cache per server8
Freshness + one shared cache1
Freshness + cache, replay after window closes1
  • No protection51
  • Freshness window only51
  • Freshness + cache per server8
  • Freshness + shared cache1
  • Replay after window closes1
Times one captured request ran (simulator, 8 servers, 50 replay attempts).

Freshness alone does nothing against a prompt replay: it narrows when, not how many times. With per-server caches, fleet size is your replay count. A shared cache gets you to one, but global consistent state costs latency, the thing 0-RTT was saving. So deployments commonly settle for "at most once per node or zone".

1/3Duplicate
attacker copies ClientHello
      ├──▶ zone A
      └──▶ zone B
client ──▶ zone A (original)

The attacker duplicates the ClientHello to zones A and B.

The RFC's own two-zone example: retries, not replays. Step through it.

§8 says this second class, retries rather than replays, "cannot be prevented at the TLS layer and MUST be dealt with by any application".

Smaller sharp edges
  • A freshly restarted server has an empty cache, so §8.2 says it should reject 0-RTT while its recording window overlaps startup.
  • If the ticket-encryption key is compromised, every recorded early-data flight becomes readable. Tim Taubert's 2017 write-up reported Apache, nginx and HAProxy of that era didn't rotate ticket keys automatically; I didn't re-check current defaults.

So it's the application's problem#

The attacker can only duplicate, so the question is: is this request safe to run twice? TLS can't answer that. Your application can.

RFC 8446 §8: clients "MUST only send early data which they deem safe to be replayed". RFC 8470 adds the HTTP plumbing: an intermediary forwarding an early-data request sets Early-Data: 1, a server that can't safely process it answers 425 Too Early, and the client retries without early data.

ssl_early_data on;
proxy_set_header Early-Data $ssl_early_data;     # origin sees "1" for early-data requests
# off by default because it breaks resumption on OpenSSL:
# ssl_conf_command Options AntiReplay;

nginx has had this since 1.15.3. ssl_early_data is off by default, and OpenSSL's built-in anti-replay is also off by default because it breaks resumption. Turning on 0-RTT doesn't turn on the defenses.

Trail of Bits' trap: "GET only" isn't enough. A GET that bumps a counter or triggers an action is safe by HTTP spec and unsafe here. And if any hop forgets to set or check the header, protection silently vanishes.

So 0-RTT is a real latency win for reads and a real double-charge risk for writes, and the line is drawn by your application. For payments, the cleanest fix is an idempotency key the server dedupes, so "ran twice" is harmless whatever the transport did.

What I'm left wondering#

The spec-level story looks settled: RFC 8446 and 8470 in 2018, RFC 9001 for QUIC in 2021, which says endpoints "MUST implement and use the replay protections described in [TLS13], however it is recognized that these protections are imperfect."

  • The signal. Early-Data: 1 is advisory; the origin must check it and every hop must set it. Whether safety should be opt-in by the application is still argued.
  • Practice. I found no measurement of how many deployments share any replay state, and no public incident of a CDN replaying a non-idempotent request through 0-RTT. Maybe it hasn't happened; maybe nobody wrote it up.
  • Post-quantum tickets. HQRT (2026) adds hybrid X25519 + ML-KEM-768 encapsulation to ticket issuance to resist harvest-now-decrypt-later. How that interacts with replay caches and QUIC's amplification limits, I couldn't find a verified answer.
  • Forward secrecy. Puncturable-PRF constructions have existed on paper since 2019, with no mainstream deployment that I could find.

Sources#

© 2026 Bharat Kaurav. Built with Next.js & Tailwind.

>_ bk@netherwatcheresc to close

Welcome, reader. Type help to see what this shell can do.