Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2022-23539

CVE-2022-23539: Auth0 Jsonwebtoken Auth Bypass Vulnerability

CVE-2022-23539 is an auth bypass vulnerability in Auth0 Jsonwebtoken that allows insecure key types for signature verification. This weakness enables attackers to bypass authentication. This article covers technical details, affected versions, security impact, and mitigation strategies.

Published:

CVE-2022-23539 Overview

CVE-2022-23539 is a cryptographic vulnerability in the Auth0 jsonwebtoken library for Node.js that allows misconfiguration of key types used for signature verification. Versions <=8.5.1 of the library could be configured to use legacy, insecure key types with incompatible algorithms, such as using DSA keys with the RS256 algorithm. This algorithm/key type mismatch can lead to improper token validation and potential authentication bypass scenarios.

Critical Impact

Applications using affected versions may incorrectly validate JWT tokens due to insecure key type and algorithm combinations, potentially allowing attackers to forge authentication tokens or bypass security controls.

Affected Products

  • Auth0 jsonwebtoken versions <=8.5.1 for Node.js
  • Applications implementing JWT authentication using the vulnerable library
  • Any downstream dependencies relying on auth0/node-jsonwebtoken

Discovery Timeline

  • 2022-12-23 - CVE CVE-2022-23539 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-23539

Vulnerability Analysis

This vulnerability is classified under CWE-327 (Use of a Broken or Risky Cryptographic Algorithm). The core issue lies in the library's failure to properly validate that the cryptographic key type matches the specified signing algorithm during token verification. When an application specifies an algorithm like RS256 (RSA with SHA-256), the library should only accept RSA keys for verification. However, vulnerable versions allow other key types, such as DSA keys, to be used with incompatible algorithms.

This misconfiguration creates a dangerous situation where cryptographic operations may fail silently or produce unexpected results, potentially leading to tokens being validated when they should be rejected. Attackers who can influence the key material or algorithm selection could exploit this weakness to bypass authentication mechanisms.

Root Cause

The root cause is insufficient validation of asymmetric key type and algorithm combinations within the sign() and verify() functions. The library lacked proper checks to ensure that the provided cryptographic key matched the expected key type for the specified algorithm, allowing insecure combinations to be processed.

Attack Vector

The vulnerability is exploitable over the network and requires low privileges to exploit. An attacker could exploit this vulnerability in scenarios where:

  1. The application accepts user-controlled or external key material
  2. Algorithm negotiation is possible through the JWT header
  3. Key confusion attacks can be mounted against the verification process

The attack does not require user interaction and can result in complete compromise of confidentiality and integrity of the authentication system.

javascript
// Security patch in lib/asymmetricKeyDetailsSupported.js
// Source: https://github.com/auth0/node-jsonwebtoken/commit/e1fa9dcc12054a8681db4e6373da1b30cf7016e3
+const semver = require('semver');
+
+module.exports = semver.satisfies(process.version, '>=15.7.0');

The patch introduces version checking for Node.js to ensure asymmetric key details are properly supported, enabling validation of key types against algorithms.

javascript
// Security patch in lib/rsaPssKeyDetailsSupported.js
// Source: https://github.com/auth0/node-jsonwebtoken/commit/e1fa9dcc12054a8681db4e6373da1b30cf7016e3
+const semver = require('semver');
+
+module.exports = semver.satisfies(process.version, '>=16.9.0');

This additional patch ensures RSA-PSS key details validation is only enabled on Node.js versions that properly support these features.

Detection Methods for CVE-2022-23539

Indicators of Compromise

  • Unexpected JWT validation successes with mismatched key types and algorithms
  • Authentication logs showing tokens signed with unusual algorithm/key combinations
  • Application errors related to cryptographic operations during token verification
  • Evidence of DSA keys being used with RSA algorithms (RS256, RS384, RS512)

Detection Strategies

  • Audit package.json and package-lock.json files for jsonwebtoken versions <=8.5.1
  • Use software composition analysis (SCA) tools to identify vulnerable dependencies
  • Monitor authentication systems for anomalous token validation patterns
  • Review application code for explicit algorithm and key type configurations

Monitoring Recommendations

  • Implement logging for JWT verification operations including algorithm and key type used
  • Set up alerts for authentication failures or unexpected successes that may indicate exploitation attempts
  • Monitor dependency management systems for outdated jsonwebtoken packages
  • Review application security logs for cryptographic operation anomalies

How to Mitigate CVE-2022-23539

Immediate Actions Required

  • Upgrade jsonwebtoken library to version 9.0.0 or later immediately
  • Audit all applications using jsonwebtoken for vulnerable configurations
  • Review the GitHub Security Advisory GHSA-8cf7-32gw-wr33 to verify your algorithm/key combinations are secure
  • Test authentication flows after upgrading to ensure compatibility

Patch Information

The vulnerability has been fixed in jsonwebtoken version 9.0.0. This version implements proper validation for asymmetric key type and algorithm combinations. The fix is available via the GitHub commit e1fa9dcc12054a8681db4e6373da1b30cf7016e3.

After upgrading, if you intentionally need to use non-standard key type/algorithm combinations (not recommended), you must explicitly set the allowInvalidAsymmetricKeyTypes option to true in the sign() and/or verify() functions.

Workarounds

  • If immediate upgrade is not possible, manually validate that key types match expected algorithms before calling verification functions
  • Restrict the algorithms accepted by your application to a known-secure list
  • Ensure all cryptographic keys are sourced from trusted, controlled locations
  • Implement additional validation layers around JWT verification operations
bash
# Upgrade jsonwebtoken to the patched version
npm update jsonwebtoken@^9.0.0

# Verify the installed version
npm list jsonwebtoken

# Check for other vulnerable dependencies
npm audit

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.