flashman
← All posts

JWE zip compression and decompression debugging

Debug compressed JWE tokens by checking protected zip headers, algorithm policy, decrypt-then-decompress order, output limits, side channels, and safe fixtures.

2026-09-19 · 6 min read · Rahul Chitturi

  • jwe
  • jwt
  • security

JOSE compression applies to JWE plaintext before encryption; it is not a generic feature of signed JWS tokens. A service that expects ordinary compact JWT claims can report misleading parse or signature errors when it receives an encrypted, compressed token.

Compression also changes the resource and confidentiality model. Tiny ciphertext can expand into large plaintext, while ciphertext length can reveal information when an attacker can influence nearby secret-bearing content.

Constrain the token profile first

Document whether the endpoint accepts JWE, which key-management and content-encryption algorithms are allowed, whether zip is permitted, and the maximum encoded, decrypted, and decompressed sizes. Reject unsupported combinations before expensive processing.

  • Read zip only from the integrity-protected JOSE header.
  • Do not reinterpret a JWS payload as compressed bytes.
  • Use maintained JOSE and compression implementations.
  • Bound nesting, token length, output size, and processing time.

Authenticate before trusting output

The JOSE library should validate compact structure, resolve a trusted key, enforce algorithm policy, authenticate and decrypt the JWE, and only then expose bounded decompressed content for claim parsing. Avoid returning parser details that form a decryption oracle.

Do not compress secrets together with attacker-controlled text when observable ciphertext length can become a side channel. Disabling compression is often the simplest policy for small tokens.

Use synthetic limit fixtures

Use Flashman's JWT, Base64, and JSON tools only to inspect disposable structures, and the units converter to document byte limits. Actual decryption and authentication belong in a maintained JOSE library.

Test uncompressed and compressed JWEs, unsupported zip values, altered protected headers, wrong keys, truncation, high expansion ratios, nested tokens, duplicate headers, algorithm rejection, limit boundaries, generic errors, and every producer-verifier pair.

Try these tools