Embedded keys in the RFC
RFC 7515 §4.1.3 defines the jwk (JSON Web Key) header parameter as:"The public key that corresponds to the key used to digitally sign the JWS."The intent is for the token to be self-describing - a recipient can fetch the public key directly from the token without contacting any external endpoint.
The vulnerability arises when a library or application uses the embedded JWK directly for signature verification without checking it against a trusted key store. Since the attacker controls the token - including its header - they can embed any public key they choose, sign the token with the matching private key, and the server will successfully verify the signature using the attacker's own key.
The forged token structure
The payload contains whatever claims the attacker wants (role: "admin", arbitrary sub, etc.). The signature is computed using the attacker's RSA private key. A vulnerable server:
- Parses the header and extracts the
jwkfield - Imports the embedded public key
- Verifies the signature using that key
- The signature is valid - it was signed by the corresponding private key
- The server accepts the forged token as legitimate
node-jose and CVE-2018-0114
The most widely-cited real-world instance is node-jose versions prior to 0.11.0, disclosed in 2018. node-jose is the JOSE implementation used internally by many enterprise products, notably several Cisco applications. The vulnerable code path:
EC key variant
The same attack works with ECDSA (ES256). The attacker generates an EC keypair, embeds the public EC key as the jwk claim with kty: "EC", and signs with the private EC key. The JWK format for EC keys:
Detection
To test a target, generate a fresh RSA or EC keypair in JWT Arsenal, forge a token with an arbitrary payload and your public key embedded in the header, then send it:
node-jose < 0.11.0- CVSS 10.0 in Cisco product context- Affected Cisco Prime Infrastructure, Cisco Enterprise Network Function Virtualization Infrastructure Software, and others
- Pattern still appears in custom JWT parsers that extract the JWK before validating the signature
- Also found in some OIDC client libraries that support key discovery via
jwkheader
Mitigations
- Never use the
jwkheader field as the source of the verification key - always use a server-side trusted key store - If the library supports "keystore mode" vs "auto-key mode," always use keystore mode
- Validate that any key material used for verification matches a pre-configured trusted key by key ID or thumbprint
- Consider stripping or rejecting tokens that contain
jwk,jku, orx5uheader claims before processing - Keep JWT libraries up to date - this class of bug is typically fixed in library updates