TExcelTAD

What TLS Does Not Protect

"It's over HTTPS, so it's secure" is one of the most common sentences in design reviews, and one of the least precise. TLS protects the bytes in transit between two endpoints against reading and tampering by the network, and it authenticates the server's name (and optionally the client). Everything else is outside its scope. A defender needs to know the outside as well as the inside, because that is where attackers go.

What TLS does protect

  • Confidentiality of application data and, in TLS 1.3, of most of the handshake (the certificate is encrypted).
  • Integrity: any modified, reordered, replayed or truncated record is detected (except 0-RTT replay, see the handshake lesson).
  • Server authentication to a name, if the client validates the chain and the host name.
  • Forward secrecy for recorded traffic with (EC)DHE.

What it leaves visible: metadata

A passive observer on the path still sees:

  • IP addresses and ports of both ends, and therefore often the organisation and the service.
  • The server name (SNI) in the ClientHello, in cleartext, unless Encrypted Client Hello (ECH) is used. The lab capture shows it:
bash · try it yourself
tshark -r $SAMPLES/pcap/tls.pcap -Y 'tls.handshake.type == 1' -T fields \
  -e ip.src -e ip.dst -e tcp.dstport -e tls.handshake.extensions_server_name -e tls.handshake.extensions_alpn_str -e frame.len
10.10.0.5	10.10.0.10	443	lab.test	h2,http/1.1	268
  • DNS lookups, unless DNS over HTTPS/TLS is used.
  • Timing, direction and sizes of records. AEAD ciphertext is as long as the plaintext plus a fixed overhead, so the length of a response reveals the length of the page.

The last point is enough to learn content in many applications. The toy below models a lab health portal (synthetic sizes) and what an observer sees for one response: a TLS 1.3 record is 5 bytes of header, the plaintext, 1 byte of content type and a 16-byte tag.

python · try it yourself
# Synthetic: sizes of pages on a lab health portal (bytes of HTTP response body)
PAGES = {"/": 18_204, "/login": 6_310, "/results/normal": 9_877, "/results/positive": 14_562, "/billing": 11_049}
TAG, TYPE, HEADER = 16, 1, 5                    # TLS 1.3 record overhead per record (AES-GCM)

def records(size, pad_to=None, max_record=16_384):
    out = []
    while size > 0:
        chunk = min(size, max_record)
        padded = chunk if pad_to is None else -(-chunk // pad_to) * pad_to
        out.append(HEADER + padded + TYPE + TAG)
        size -= chunk
    return tuple(out)

observed = records(14_562)                      # what a passive observer sees on the wire for one request
print("observed record lengths:", observed)
print("guess:", [p for p, s in PAGES.items() if records(s) == observed])
padded = {p: records(s, pad_to=16_384) for p, s in PAGES.items()}
print("with padding to 16 KiB :", sorted(set(padded.values())))
print("candidates for", padded["/results/positive"], ":", [p for p, r in padded.items() if r == padded["/results/positive"]])
observed record lengths: (14584,)
guess: ['/results/positive']
with padding to 16 KiB : [(16406,), (16406, 16406)]
candidates for (16406,) : ['/login', '/results/normal', '/results/positive', '/billing']

A 14,584-byte record identifies the "positive result" page exactly. Padding every response up to 16 KiB makes four of the five pages indistinguishable; the home page, larger than one record, still stands out. Real attacks of this kind identified pages on HTTPS health and tax sites (Chen, Wang, Wang and Zhang, 2010), search queries from autocomplete sizes, spoken phrases from encrypted VoIP packet sizes, and websites behind Tor. TLS 1.3 supports record padding, but few applications use it; defences belong in the application (constant-size responses, batching, padding).

What it doesn't protect: the endpoints

  • Data at rest: once decrypted on the server, data is in logs, databases, caches and backups. TLS says nothing about them; use encryption at rest and access control.
  • The other hops: TLS ends at the load balancer, CDN or API gateway. Traffic from there to the backend may be cleartext, and the CDN sees everything. Re-encrypt internally (mTLS) and treat the terminator as part of the trust boundary.
  • The application: SQL injection, XSS, broken access control and leaked tokens travel perfectly well inside TLS (Web Application Security).
  • Compromised endpoints: malware on the client reads data before encryption; a breached server reads it after.
  • Users who click through warnings, and clients that don't verify certificates.

Interception that TLS allows by design

  • Enterprise TLS inspection: a proxy with its own CA, installed on managed devices, terminates and re-encrypts every connection. It is legitimate on company devices with policy and notice, but it concentrates risk: the proxy must validate upstream certificates correctly (several products didn't, accepting invalid ones or downgrading), and its CA key can sign for any site. Studies of HTTPS interception (Durumeric et al., 2017) found that most inspection products weakened connection security.
  • Mis-issued certificates from any trusted CA, detectable through CT (CT and ACME).
  • Session data reuse: tickets and resumption secrets kept too long.

How gaps are detected

  • Data-flow diagrams that mark where TLS terminates and what each hop sees; threat modelling per hop.
  • Traffic analysis of your own services (in scope): do responses with different sensitive content have distinct sizes? Are there internal hops in cleartext (tcpdump -nn port 80 on internal segments of your lab)?
  • Endpoint and proxy reviews: TLS inspection appliances' upstream validation settings, trusted CAs on managed devices, SSLKEYLOGFILE and debug proxies left configured.
  • DNS and SNI exposure: which names leak to the network and to resolvers.

How it is fixed or reduced

  • End-to-end protection where the terminator shouldn't see data: application-layer encryption (encrypted fields, HPKE, end-to-end messaging protocols) on top of TLS.
  • mTLS for internal hops; encryption at rest with key management (Key Management).
  • Metadata: ECH and DNS over HTTPS where supported; response padding or bucketing for sensitive endpoints; avoid revealing secrets through sizes (e.g. compressing secrets together with attacker-controlled data, the CRIME and BREACH attacks).
  • Limit and audit TLS inspection: exclude sensitive categories, keep its CA key in an HSM, make sure it validates upstream strictly.

Pitfalls

  • "Encrypted in transit and at rest" without saying who holds which keys: the cloud provider, the CDN and the vendor's support team may all be able to read the data.
  • Compressing HTTP responses that mix secrets (CSRF tokens) with reflected user input: BREACH recovers the secret from compressed sizes despite TLS.
  • Assuming TLS hides who you talk to.

Practice

1. A clinic portal's "your test result" page has two versions with clearly different sizes. What can a network observer learn, and what are two mitigations?

Which result a patient received, from the response size alone. Mitigations: pad both versions to the same size (or a fixed bucket), or load the result through a constant-size response with the details fetched separately; also avoid distinct follow-up requests that reveal the outcome.

2. Traffic from users to a CDN uses TLS 1.3; the CDN connects to the origin over HTTP. What does the CDN, and the network between CDN and origin, see?

Everything in cleartext: requests, cookies, responses. Configure TLS (ideally with origin certificate validation or mTLS) between CDN and origin, and treat the CDN as a party that can read the data.

3. In the sandbox capture, which fields would ECH hide?

The SNI lab.test (and the ALPN list and other inner ClientHello extensions): ECH encrypts the inner ClientHello. The IP addresses, port 443 and the frame sizes stay visible.

Test yourself

Which of these does TLS 1.3 without ECH leave visible to a network observer?

  1. The HTTP request path
  2. The server name in the SNI extension
  3. Cookies
  4. The response body

Why can record sizes reveal content?

  1. TLS compresses data
  2. AEAD ciphertext length equals plaintext length plus a fixed overhead
  3. TLS records include the URL
  4. Sizes are signed

Where does TLS protection end when a load balancer terminates TLS?

  1. At the user's browser
  2. At the load balancer; the backend hop needs its own protection
  3. At the database
  4. Nowhere, TLS is end-to-end

What does an enterprise TLS-inspection proxy need in order to work?

  1. The servers' private keys
  2. A CA certificate installed as trusted on the clients
  3. Weak cipher suites
  4. TLS 1.0