Skip to content

TLS 1.3 0-RTT — when the latency win is worth the replay risk

A decision guide for TLS 1.3 0-RTT (Early Data): how it works, what an attacker can replay, the application invariants required to use it safely, and the Nginx and HAProxy controls.

An engineer reads that TLS 1.3 0-RTT cuts a full round-trip off the handshake for returning clients and turns it on globally on the front-door reverse proxy. Six weeks later, an unrelated mobile network blip causes a returning user’s POST to a “claim coupon” endpoint to be silently replayed three times because the carrier retried the connection and the gateway accepted the early data each time. This article frames 0-RTT not as a feature to enable but as a contract to negotiate — which requests are safe to send as early data and which are not, with the configuration controls in Nginx and HAProxy.

How to verify

# Test whether the server accepts 0-RTT
openssl s_client -connect example.com:443 -servername example.com -tls1_3 \
  -sess_out /tmp/sess.pem -ign_eof < /dev/null

# Second connection sending early data
echo -e 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
  openssl s_client -connect example.com:443 -servername example.com -tls1_3 \
  -sess_in /tmp/sess.pem -early_data /dev/stdin

# What Nginx reports for the request — TLS-Early-Data header
curl -v -H 'Early-Data: 1' https://example.com/ 2>&1 | grep -i early

# HAProxy stats for 0-RTT acceptance
echo 'show info' | socat /var/run/haproxy.sock - | grep -i ssl

The presence of Early data was accepted in the OpenSSL output (or a 200 OK response from the early-data request) confirms the server is honoring 0-RTT. Absence does not mean it’s disabled — could be the session was not resumable.

What’s happening

TLS 1.3 0-RTT lets a returning client send application data in its first flight, alongside the ClientHello, using a pre-shared key (PSK) derived from a previous session. The server decrypts the early data using that PSK and returns the response without an extra round trip. For a returning user on a high-latency connection, this can save 50-200ms of perceived latency on the first request.

The cost is structural: the early data is not protected against replay. A network attacker who captures the first flight can resend it later, possibly to a different server in the cluster, and that server will accept and process the same request again. TLS 1.3 mandates anti-replay defenses on the server (track recently-seen PSK identities and refuse duplicates), but those defenses are necessarily best-effort across distributed front-ends — a request sent to gateway A and a replay sent to gateway B in the same cluster may both succeed if the replay cache isn’t shared, or if it expires.

The application-level contract is the part that matters. 0-RTT is safe to use for:

  • Idempotent GETs whose response can be served from cache or from a read-only data path.
  • Requests whose effect is naturally idempotent (e.g. a PUT setting a flag to the same value).

0-RTT is unsafe to use for:

  • Any POST that creates a new resource (the replay creates a duplicate).
  • Any request that increments a counter, charges money, or sends a notification.
  • Any request whose authorization includes a timestamp or nonce that the application doesn’t check for freshness.
  • Any request that mutates state where idempotency hasn’t been explicitly designed.

The mental model: 0-RTT is a TLS-layer feature with an application-layer contract. The TLS layer can tell you whether data was early; the application has to decide what to do with that signal.

The decision

  1. Decide at the route level, not the server level. A blanket ssl_early_data on accepts early data for every request including POSTs. The Nginx Early-Data header forwarded to the upstream is the application’s only signal to gate on. Use it:

    server {
      listen 443 ssl http2;
      ssl_protocols TLSv1.3;
      ssl_early_data on;
    
      location / {
        proxy_set_header Early-Data $ssl_early_data;
        proxy_pass http://backend;
      }
    }

    The upstream must inspect Early-Data: 1 and either accept the request (if the route is idempotent) or return 425 Too Early to instruct the client to retry over a fully-established connection.

  2. Reject early data on mutating routes. In the upstream application or at a reverse-proxy ACL:

    # Block early data on anything that mutates
    location ~ ^/(api/checkout|api/cart|api/auth|admin) {
      if ($ssl_early_data) {
        return 425;
      }
      proxy_pass http://backend;
    }

    425 Too Early is the standard response (RFC 8470) telling the client to retry over a full handshake. Compliant clients (recent browsers, curl 7.79+) will retry transparently.

  3. Limit the early-data quota. Both Nginx and HAProxy let you cap the bytes accepted as early data. The default is 16 KiB; for an API that only needs to accept small requests early, reduce it:

    # In http context
    ssl_session_ticket_key /etc/nginx/ssl/ticket.key;
    # Smaller cap — anything larger forces a full handshake
    ssl_early_data on;

    HAProxy:

    bind :443 ssl crt /etc/haproxy/site.pem alpn h2,http/1.1 allow-0rtt
    http-request set-header Early-Data 1 if { ssl_fc_has_early }
    http-request deny status 425 if { ssl_fc_has_early } METH_POST
  4. Ensure the anti-replay cache is shared if you operate multiple front-ends. Default Nginx and HAProxy track PSK identities per process. If you run a cluster of front-ends behind round-robin DNS or a load balancer, an attacker can replay to a different front-end and the per-process cache won’t catch it. Either:

    • Pin a session to a single front-end via sticky load balancing (sacrifices some failover behavior).
    • Share session tickets across the fleet and disable session caching so all front-ends use the same ticket encryption key (then rotate the key on a known cadence).
    • Use a shared session store (memcached/Redis) with a TTL tighter than the ticket lifetime.
  5. Measure the actual gain before keeping it on. 0-RTT helps only returning clients on the same connection. Run a one-week sample of ssl_session_reused rates. If under 30% of connections benefit, the security cost is paid for a small wins; consider disabling.

Common pitfalls

  • Trusting that “no POST” guards everything. GETs can mutate state too if the application is sloppy. The contract is “this request is idempotent and safe to replay,” not “this request is a GET.”
  • Forgetting the Early-Data header on the upstream. Nginx accepts early data and forwards the request without any flag the upstream can see, unless you explicitly set the proxy header. The upstream then has no way to discriminate and may process replays as new requests.
  • Confusing 0-RTT with session resumption. Session resumption (PSK) without 0-RTT is safe and cuts one round trip without replay risk. 0-RTT cuts the round trip but allows replay. Many “TLS performance wins” are actually just session resumption — verify what’s enabled.
  • Enabling on a multi-front-end fleet without sharing replay state. Per-process anti-replay caches give you false confidence. Either share, or limit 0-RTT to a single front-end behind a CDN that handles the replay protection.
  • Allowing early data through to a vulnerable WAF or rate-limiter. Some WAFs and rate-limiters treat replays as fresh requests and may incorrectly count or block based on apparent volume. Test the full request path with deliberate replays before declaring success.

Stack Harbor configures 0-RTT per route based on application contract, not per server, and runs the replay-cache topology that prevents cross-fleet replays from succeeding — so the latency win on returning visitors is captured without the operational footgun. See our managed operations service for how TLS topology is reviewed alongside the application onboarding.