Chapter 26Down the Rabbit Hole: The TLS Packet Anyone Can Send Twice
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:
| Setup | Round trips before response | At 100 ms RTT |
|---|---|---|
| TCP + TLS 1.3, full handshake | 1 (TCP) + 1 (TLS) + 1 (request) | 300 ms |
| TCP + TLS 1.3, resumed with a ticket | same | 300 ms |
| TCP + TLS 1.3, 0-RTT | 1 (TCP) + 1 (request rides the first TLS flight) | 200 ms |
| QUIC 1-RTT | 1 (handshake) + 1 (request) | 200 ms |
| QUIC 0-RTT | 1 | 100 ms |
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.
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.
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.
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 MBThat'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.
| Protection | Runs of one request |
|---|---|
| None | 51 |
| Freshness window only | 51 |
| Freshness + one cache per server | 8 |
| Freshness + one shared cache | 1 |
| Freshness + cache, replay after window closes | 1 |
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".
attacker copies ClientHello
├──▶ zone A
└──▶ zone B
client ──▶ zone A (original)The attacker duplicates the ClientHello to zones A and B.
§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: 1is 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#
- RFC 8446, TLS 1.3 (§2.3, §4.2.10, §7.1, §8, Appendix E.5)
- RFC 8470, Using Early Data in HTTP
- RFC 9001 §9.2, Using TLS to Secure QUIC
- nginx ngx_http_ssl_module docs
- Trail of Bits, What application developers need to know about TLS early data
- Tim Taubert, The future of session resumption
- Fischlin and Günther, Replay Attacks on Zero Round-Trip Time (EuroS&P 2017)
- Aviram, Gellert, Jager, Session Resumption Protocols and Efficient Forward Security for TLS 1.3 0-RTT
- Krawczyk and Wee, OPTLS
- Abdul and Kondapalli, HQRT: Hybrid Quantum-Resistant Resumption for zero-RTT TLS 1.3 (2026)