The dictionary two strangers share

Two machines that will never meet are required to hold the same dictionary, in the same order, at the same instant. A third party in the hallway is counting how big each message is. That is not a thought experiment about trust. It is the header compression layer of HTTP/2, and it has been running under most of the web for more than a decade.

The dictionary is HPACK. Its rulebook is RFC 7541, published in May 2015 on the Standards Track, and its abstract is one sentence long: the document "defines HPACK, a compression format for efficiently representing HTTP header fields, to be used in HTTP/2".

The verdict is uncomfortable and it is permanent. HPACK bought compactness with a length side channel it documented itself, and because HTTP/2 offers no alternative header compressor, every browser, CDN edge and load balancer on the planet still pays that price. What makes the document worth reading now is not the compression. It is the candour — HPACK is one of the few documents in the Internet's library that devotes an entire section to explaining how it can be turned against you, and then ships anyway, because the alternative was worse.

Why HTTP/2 needed header compression at all

An HTTP exchange is mostly boilerplate. The host, the user agent, the cookie, the accept list, the bearer token: the same strings, request after request, byte for byte, on connections that carry hundreds of requests at a time. Compressing the body saves you the payload. Compressing the headers saves you the tax you pay on every single request just to announce who you are.

SPDY, Google's pre-standard HTTP replacement, did this with zlib. In 2012, Juliano Rizzo and Thai Duong showed that compressing a secret alongside attacker-controlled text lets an attacker recover the secret one byte at a time by watching the ciphertext shrink. They called it CRIME. HPACK was built with that lesson in the room: no shared LZ77 window across the stream, no compressing field values against each other, and an explicit escape hatch for the fields you would rather not have indexed at all.

It did not make the leak disappear. It made the leak smaller, narrower, and — crucially — written down.

Two tables, one of them alive

HPACK compresses with two tables. The static table is 61 entries baked into the specification: the headers everyone sends, indexed once and never again. The dynamic table is the interesting one, and RFC 7541 describes it precisely — "a list of header fields maintained in first-in, first-out order", "initially empty", with entries added "as each header block is decompressed".

Read that last clause twice. The decoder is not sent instructions to build a table. It is sent a stream, and it is expected to build the same table the encoder built, in the same order, by the same arithmetic, for as long as the connection lives. The default ceiling for that table is 4,096 octets, adjustable mid-conversation by a settings change and a size update.

Even the literal strings get squeezed: a static Huffman code, also shipped inside the document, so that a header value present in neither table still costs fewer bits than it would in plain ASCII.

A contract with no repair clause

There is no synchronisation protocol inside HPACK. No checksum, no sequence number, no resend. The encoder references entries by index and simply assumes the decoder's table matches its own. When it does not, the failure is not a clean error — it is a stream that decodes into the wrong headers, which is worse, because wrong headers still look like headers.

HTTP/2 absorbs this by making a compression error fatal for the entire connection. One bad index and everything multiplexed onto that connection dies and gets rebuilt. That is the price of a dictionary with no repair clause: the repair is the connection.

The eviction arithmetic nobody sees

Entries leave the table when it reaches its maximum size, or when a new entry shoves the oldest one out. The maximum itself can be changed mid-stream by a size update. Every one of those rules exists for a single reason: so that two independent implementations, written by different people in different countries, compute an identical table from an identical byte stream.

The specification is unusually pedantic about this — the octet counting, the eviction order, the index space split between static and dynamic entries. That is what you do when the state is invisible and the penalty for divergence is a dead connection.

Section 7.1: when length becomes information

Here is the part worth remembering. Section 7.1 of RFC 7541 is titled "Probing Dynamic Table State", and it says out loud that the compression context "can be probed by an attacker who can both define header fields to be encoded and observe the length of those fields once they are encoded".

The mechanism is almost embarrassingly simple. Add a guess to a request. If the guess is already in the table, the encoder emits a short index and the block shrinks. If it is not, the encoder emits the literal and the block grows. One guess per request, one bit learned per guess, repeat until the cookie falls out.

TLS does not save you, and the document says so: encryption "only provides a limited amount of protection for the length of that content". Compression converts redundancy into length. Encryption hides the content and leaves the length. The observer cannot read your session token, but the observer can count.

What RFC 7541 actually did about it

The specification does not pretend the leak away. It lists its mitigations: keep sensitive fields out of the dynamic table using a "never indexed" literal representation, shrink the table so there is less state to probe, and pad at other layers where padding exists.

Then it makes the trade explicit. HPACK chose compactness because HTTP/2 wanted many requests multiplexed onto one connection, and a stateful dictionary is the only way to get large savings on repetitive headers. A stateful dictionary, in turn, encodes information about itself in every message it produces.

The format could not remove the signal. So it wrote the signal down, in plain English, in a document anyone can read.

Why HPACK is still everywhere, and why that is the real story

HTTP/2 has exactly one header compression scheme, and it is HPACK. There is no negotiation, no fallback, no off switch. Every browser, every CDN edge, every load balancer, every gRPC client and every reverse proxy that speaks HTTP/2 carries the same state machine and the same length leak, because the protocol does not offer an alternative.

That is how infrastructure lock-in actually happens. Not with a monopoly and not with a mandate, but with a design that solves the problem in front of it, documents the cost honestly, and then gets implemented by everyone because the protocol leaves no other door.

An RFC has no enforcement mechanism. Its authority is that everyone built it. The IETF's legitimacy claim has always been "rough consensus and running code", and HPACK is a clean demonstration of both halves: consensus produced the document, and running code made it law. RFC 7540 and RFC 7541 were published in the same month, as a pair, and the web adopted the pair.

HTTP/3 did not repeal the trade so much as relocate it. QPACK, defined in RFC 9204, fixes HPACK's head-of-line blocking by letting encoder and decoder drift apart across streams — and inherits the same fundamental exposure, because a smaller block still says something about what went into it. The leak was not solved. It was moved, and re-documented.

The measurement device

Any compression scheme is a measuring instrument pointed at its own input. The more redundancy it strips, the more the size of the output says about the shape of the input, and an adversary who can vary the input can read the difference off the ruler.

Every protocol that compresses something secret has to make that trade and write it down, rather than discover it in a paper three years later. HPACK wrote it down in section 7.1, in a document the entire web now depends on, and then shipped.

More than a decade on, the dictionary is still shared, the lengths still talk, and the only thing standing between the two is a specification that had the decency to admit what it was doing.