Executive brief
jsonwebtoken is a popular Node.js library used to create and verify digitally signed tokens that authenticate users and protect sensitive data in web applications. A flaw in the library's key validation logic allows an attacker to forge authentication tokens by switching from the intended RSA encryption algorithm to HMAC, potentially granting unauthorized access to protected resources and user accounts. Organizations using both symmetric and asymmetric keys in the same verification function are at risk.
Technical details
The vulnerability is an insecure implementation of the key retrieval function in jsonwebtoken versions ≤8.5.1, allowing algorithm confusion attacks. When an application supports both symmetric (HMAC) and asymmetric (RSA) key verification within the same key retrieval function, an attacker can forge tokens by switching the signing algorithm from RSA to HMAC, as the library may incorrectly verify the token using the wrong key-algorithm combination. The attack requires the attacker to know or be able to derive the key used for verification, and the application must be misconfigured to use both key types with a poorly implemented retrieval function. This leads to successful validation of forged tokens, enabling account takeover or unauthorized access. The fix is available in version 9.0.0.
Affected products
- Auth0 jsonwebtoken <=8.5.1
Timeline
- 2022-12-21: disclosed
- 2022-12-21: patched: version 9.0.0 released