K081 / Cryptographic protocols and formats
JWE JOSE
JWE is a JSON-based encryption format that encrypts a payload so only its recipient can read it.
CRYPTOGRAPHY LAB / K081
Cryptography Lab · JWE JOSE
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
JWE Compact (dir + A256GCM, fixed protected header)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- JWE is a JSON-based encryption format that encrypts a payload so only its recipient can read it. Source document ↗
- Classification and reversibility
- Encryption protocol; recipient decrypts payload with key. Source document ↗
- Key or secret requirements
- Not confirmed in the survey
- Operating principle and structure
- Hybrid structure: symmetric CEK encrypts body, recipient public key or other key protects CEK. Source document ↗
- Key size, block size and parameters
- enc defines key length/mode parameters, e.g. A256GCM 256 bits and A128GCM 128 bits. Source document ↗
- Security strength and recommendation
- Some JWE algorithms such as RSA1_5 deprecated; constrain allowed algorithms. Source document ↗
- Known attacks and vulnerabilities
- Invalid Curve attacks in JWE implementations affected multiple libraries. Source document ↗
- Standards and certification
- Standardized in RFC 7516. Source document ↗
- Typical uses
- Encrypt arbitrary data such as token payload so only recipient can read it. Source document ↗
- Implementations, libraries and tools
- panva jose and other libraries support JWE Compact/JSON serialization encryption/decryption. Source document ↗
- Decryption or decoding
- Use key matching protected header alg/enc with decrypt_compact or equivalent. Source document ↗
- Advantages
- Confidentiality and integrity/tamper detection through authentication tag. Source document ↗
- Limitations and cautions
- Unchecked decompressed size in ZIP-compressed JWE may exhaust memory (DoS). Source document ↗
- Distinguishing encryption, encoding and hashing
- Base64URL segments are encoding, not encryption; distinguish from JWE cryptographic encryption/authentication. Source document ↗
Practical examples
Example
Set protected alg/enc, AEAD-encrypt payload with CEK, protect CEK with recipient key and serialize compact/JSON JWE. Recipient checks alg/enc, recovers CEK and decrypts/verifies tag.
Procedure
Allowlist alg/enc, generate CEK or use direct key, encrypt/generate tag, protect CEK by key-management alg, serialize header/ciphertext/IV/tag. On receipt parse header, validate allowlist, recover CEK, decrypt/verify and obtain plaintext. Base64URL is encoding.
Scenario
Encrypt sensitive service payloads or JWT claims with recipient public key, private-key decryption. General JSON Serialization supports multiple recipients with CEK protected for each.
Pitfalls and alternatives
Avoid RSA1_5/none, alg confusion, missing tag verification, ZIP bombs and Base64URL confusion. Use vetted libraries/current AEAD (A256GCM), fixed allowlist, decompression limits and key protection.
References
- Encrypt and decrypt JSON Web Encryption (JWE) | polyjose ↗
- JSON Web Encryption: Exploring JWE Token - Brennenstuhl on Security ↗
- JSON Web Encryption - Crypto++ Wiki ↗
- What Is JWE? JSON Web Encryption Explained with Examples — Jsonic ↗
- JOSE: Deprecate 'none' and 'RSA1_5' ↗
- Internet Bug Bounty | Report #213437 - Critical vulnerability in JSON Web Encryption (JWE) - RFC 7516 Invalid Curve attack ↗
- Understanding JSON Web Encryption (JWE) - Scott Brady ↗
- panva/jose ↗
- Cheatsheet - joserfc ↗
- CVE-2026-39373 ↗
- The Mechanics of JWE: Key Wrapping, Authenticated Encryption, and Five-Part Tokens | The Seasoned Programmer Blog ↗