One OK, and the conversation stopped being words
Picture the moment. A mail client has logged in, and it would like to stop paying full price for every byte. It sends four words — A5 COMPRESS DEFLATE — and then it waits, obediently, because the specification forbids it from sending anything else until the verdict lands. The server replies with the most boring line in protocol design: A5 OK, then CRLF.
Nothing about that reply looks like a door closing. It is one. The next octet the server emits is no longer IMAP at all. It is DEFLATE output, and both machines had better agree on precisely which byte that was.
That is the whole strange beauty of RFC 4978, the 2007 extension that taught email to compress itself mid-sentence. It added no new response form, no new verb family, no new grammar. It simply declared that after one successful tagged reply, the conversation continues in a different language — and that the boundary is a single byte position, invisible on the wire, agreed by memory.
The choreography is unforgiving. The client may not send another command while the verdict is outstanding. On OK, it compresses the first command that follows. The server keeps that successful tagged reply itself uncompressed, then switches on its encoder immediately after the CRLF that ends the line. A rejection leaves both directions exactly as they were.
Get it wrong by one response and the failure is not subtle. A client that switches too early feeds plain text into a decompressor. A server that waits one reply too long hands the client compressed bits and asks it to read them as IMAP grammar. TCP can deliver every byte perfectly, in order, checksummed and on time, and the session still turns to gibberish — because the network did its job and the two peers stopped agreeing on what the bytes meant.
Capability was permission, not a promise
The advertisement said the server understood an algorithm. That is all it said. It did not promise that your mailbox would shrink, that the CPU bill would be acceptable, or that the connection was confidential. Each side chooses its own outbound compression effort; the peer has to decode whatever stream it is handed.
The refusal rules kept that meaning narrow and honest. A server that already had the same compression mechanism running through another layer could answer NO with COMPRESSIONACTIVE. Activating the extension twice was simply invalid. The protocol refused to stack the same stateful transform just because two negotiation surfaces happened to offer it.
There were also two histories, not one — a separate context for each direction. Repeated client commands made the upstream stream predictable. Server responses, field names and mailbox text filled the downstream history. Compression did not conjure a single mystical dictionary shared by all traffic on Earth; each sender maintained the context for the bytes it produced, and each receiver had to keep pace.
The stack had an order, and it was not the order you typed
An IMAP session could also acquire a SASL security layer, or TLS, or both. RFC 4978 prescribed exactly one outgoing stack: compress first, then apply SASL signing or encryption where present, then wrap the result in TLS. The receiver unwound those operations in reverse.
That order held even if the client had issued the enabling commands in some other sequence. Administrative chronology and data transformation are different facts, and only one of them touches the bytes. The extension therefore had to live inside the protocol state machine rather than hide beneath it.
Current IMAP4rev2 keeps the same discipline around security transitions: a successful response identifies the exact point where a new layer begins. A long-lived connection may change its representation or its protection — but only if both peers assign the same meaning to the boundary.
Why email compressed so well, and where it choked
IMAP was unusually friendly to compression, because humans are repetitive and mail is humans. Clients reuse a tiny command vocabulary. Servers reuse response forms and header names. Threads reuse quotations. One evolving history can replace later phrases with short references to earlier material, and the savings compound.
The traffic was never uniform, though. A compressed archive or a JPEG shrugs off further reduction. A large attachment can shove useful IMAP patterns out of the window and make the compressor burn resources learning the wrong material just as ordinary responses return. The specification discussed full flushes near large literals and adjusting effort around data that looked incompressible — local optimizations, not new wire commands.
That is why the extension was more than a file zipper. It compressed a mixed, interactive stream while the application still knew whether the next bytes were syntax, headers, text or a literal. That knowledge saved bandwidth and CPU. It also made the application the owner of the context.
Encryption hid the words, not the lengths
In 2007, the security section of the extension did little more than point at the TLS compression thinking of the day. Later attacks moved the industry's understanding forward. CRIME and its relatives showed that encryption can hide content while leaving observable length. Put a secret and attacker-influenced text into the same compression history, and repeated guesses change the compressed size just enough to leak relationships about the secret.
The attacks catalogued in RFC 7457 concerned TLS and web compression. They do not prove an IMAP COMPRESS exploit was ever deployed, nor that every IMAP compression context is vulnerable. They do establish, permanently, why "compressed before encrypted" is not a complete confidentiality argument.
Current TLS best practice tells TLS 1.2 deployments not to enable ordinary TLS-level compression except in an application shown to be safe, and notes that TLS 1.3 removed it altogether. The same guidance warns that compression above TLS can create related disclosure risks that TLS itself cannot repair. Application knowledge buys better compression. It also buys the obligation to decide which values may share history.
The hidden state needed an owner
Compression made later bytes depend on earlier bytes without changing a single logical IMAP message. That dependency was useful only while both endpoints agreed on activation, direction, algorithm and context. Decode failure, resource exhaustion, or a confidentiality worry therefore could not be diagnosed from an encrypted packet capture alone — the evidence had already been folded into a length.
The durable lesson is narrower and more useful than "never compress secrets." Name the context. Decide who can influence its inputs, who can observe its output size, how long history survives, what decoding may consume, and how compression gets switched off without corrupting the session. An optimization that remembers is a state machine, not decoration.
Sources and limits
The DEFLATE format is defined by RFC 1951. The IMAP capability, command boundary, layer order and tuning discussion come from RFC 4978. The attack class is summarized in RFC 7457; the current IMAP core is RFC 9051; current TLS advice is RFC 9325; and the capability remains in the IANA IMAP registry. These sources do not measure current use or document a specific IMAP COMPRESS compromise.
Member Briefing
Read the full trend briefing
Members read the full briefing with the source notes behind every finding.
Strategic Circle
A daily briefing in your language, built from changes we have verified.
Join for USD 20/monthCancel anytime.
Members also get the full research library, a daily briefing on the networks they follow and the private forum.






