Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Shared compression dictionaries add cache and secret-dependent state

Shared compression dictionaries add cache and secret-dependent state Compression Dictionary Transport lets a server compress an HTTP response using a dictionary downloaded earlier. The browser can advertise a matching

Shared compression dictionaries add cache and secret-dependent state

Compression Dictionary Transport lets a server compress an HTTP response using a dictionary downloaded earlier. The browser can advertise a matching dictionary, the server can refer to a dictionary identifier, and both sides save bandwidth when a site serves many similar resources. The feature also adds a long-lived state object that affects encoding, caching, and information leakage.

RFC 9842 defines the transport and its security considerations. The Risks are not limited to a broken decompressor. Shared dictionaries can make compression side channels easier to vary or repeat. If a response mixes attacker-controlled input with a secret, the compressed size can reveal information about the secret even when the dictionary itself contains only public data. The RFC recommends preventing active use of multiple dictionaries for the same content, disabling compression when any part of the content comes from an uncontrolled source, and protecting dictionary access with the same care as the response.

Same-origin restrictions are necessary

Browser implementations restrict dictionaries to the same origin and tie dictionary-compressed resources to the document origin or a valid CORS path. The dictionary is also subject to cache partitioning. These restrictions reduce cross-origin reuse and tracking, but they do not remove the need for a server policy. A compromised same-origin resource can still influence what a user receives.

The dictionary's URL, identifier, and matching rules should be treated as configuration, not optional performance metadata. A deployment that accepts a dictionary identifier from an untrusted request without checking its scope may let a client steer the server toward a stale or attacker-influenced object. The server should validate the exact identifier and match rule, and it should fail closed when the expected dictionary is unavailable.

Plan versioning and rollback

Use content hashes or monotonic versions for dictionary identity. Keep an old dictionary available until active clients have refreshed, then remove it through a controlled cache policy. Test a dictionary miss, a stale identifier, a corrupt payload, and a response where the encoded size differs from the stored metadata. A fast rollback should restore a known good dictionary without changing the response semantics.

Because the feature is controlled by HTTP headers and sometimes HTML relationship attributes, review Content Security Policy and proxy rewriting rules. A dictionary request that is blocked by connect-src or a gateway can produce a performance regression that looks like a network fault. Log the dictionary identifier and result, not the sensitive response content.

Do not compress mixed trust

The most important rule is simple: do not combine secrets from one user with input chosen by another user in a dictionary-compressed response. If a template must mix public and private data, separate the response or disable dictionary compression for that route. Measure the benefit against the new state and side-channel surface. Compression is a transport optimization; it is not a reason to weaken a response boundary.

References

[1] RFC 9842, Compression Dictionary Transport. https://datatracker.ietf.org/doc/rfc9842/

[2] MDN, Compression Dictionary Transport. https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Compression_dictionary_transport

[3] MDN, Use-As-Dictionary. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Use-As-Dictionary

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.