Summary
OpenIDC/cjose versions 0.6.1 through 0.6.2.5 generate an all-zero content-encryption key when encrypting certain AES-CBC-HMAC JWEs with key-management algorithms that create a fresh CEK. Anyone who obtains an affected JWE may be able to decrypt its plaintext and forge or modify authenticated content because the key is fixed and publicly predictable.
Affected context
The issue occurs in cjose JWE encryption when all of the following conditions apply:
- The AES-CBC-HMAC content-encryption algorithm is used, such as A128CBC-HS256, A192CBC-HS384, or A256CBC-HS512.
- The selected key-management algorithm generates a new content-encryption key.
- The affected cjose implementation generates the CEK through the vulnerable AES-CBC handling path.
JWEs produced under these conditions may be decryptable or forgeable by parties that can obtain the ciphertext.
Exploit preconditions
- Attack surface: Applications or services that use cjose to create JWEs.
- Required access: Access to an affected JWE; direct access to the encryption process is not necessarily required.
- Trigger point: JWE encryption using an affected AES-CBC-HMAC algorithm and a key-management mode that creates a fresh CEK.
- Why exploitation is possible: The generated CEK consists of predictable zero bytes rather than cryptographically random material, allowing the fixed key to be used for decryption or content forgery.
Why this happens
The vulnerable implementation fails to generate a fresh cryptographically secure content-encryption key for applicable AES-CBC-HMAC JWEs. Instead, the CEK is initialized to an all-zero value, violating the requirement that encryption keys be unpredictable and unique.
This maps primarily to CWE-330: Use of Insufficiently Random Values. It is also related to CWE-321: Use of Hard-coded Cryptographic Key, because the effective encryption key is fixed and publicly knowable rather than generated from a secure random source.
Potential impact
- Attackers may decrypt plaintext contained in affected JWEs.
- Attackers may forge or modify authenticated JWE content.
- Confidential information protected by affected ciphertexts could be disclosed.
- Applications may accept tampered claims, tokens, or configuration data.
- Secrets contained in previously generated ciphertexts may require rotation.
- Previously affected data may remain compromised even after the implementation is corrected.
General mitigation guidance
Mitigation focuses on ensuring that every generated CEK comes from a cryptographically secure random source and that vulnerable algorithm combinations are not used.
Common defensive patterns include:
- Prefer AES-GCM content-encryption algorithms where compatible with deployment requirements.
- Use a caller-supplied CEK only when the application securely generates, protects, and manages that key.
- Avoid JWE encryption through affected cjose algorithm combinations until a corrected implementation is available.
- Re-encrypt data produced with the vulnerable behavior and rotate secrets that may have been exposed.
- Treat existing ciphertext as potentially compromised rather than assuming that a library correction repairs historical data.
- Apply least-privilege controls to keys, plaintext, and services responsible for JWE processing.
How teams detect issues like this
Organizations can detect this issue through:
- Static analysis and dependency review for cjose versions and AES-CBC-HMAC JWE usage.
- Code review checks for encryption paths that generate fresh CEKs through affected implementations.
- Regression tests that encrypt equivalent inputs repeatedly and verify that generated encrypted keys and ciphertext components are not deterministically reused.
- Policy enforcement that restricts approved JWE content-encryption algorithms and rejects vulnerable combinations.
- Inventory and forensic review of ciphertexts created during the affected deployment period.
- Automated software composition analysis and security review tools that flag vulnerable dependency ranges and weak key-generation patterns.

