CVE-2022-23539: Insecure Key Type Usage in jsonwebtoken

jsonwebtoken Updated 02 Oct 2025

Summary

22/12/2022
Yes i
High
8.1

CVE-2022-23539: jsonwebtoken unrestricted key type could lead to legacy keys usage. Affects jsonwebtoken versions < 9.0.0. Fixed in 9.0.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

jsonwebtoken is an npm package used for generating and verifying JSON Web Tokens (JWTs). It provides a secure way to authenticate and authorize users in web applications. However, versions <=8.5.1 of jsonwebtoken could be misconfigured, leading to the usage of legacy, insecure key types for signature verification. This vulnerability can result in the compromise of token security and unauthorized access to protected resources.

Vulnerability Detail

The vulnerability arises from the incorrect configuration of key types and algorithms in jsonwebtoken. In affected versions, insecure key types like DSA can be used with the RS256 algorithm, which is intended for RSA keys. This misconfiguration can allow attackers to bypass token verification and potentially impersonate legitimate users. It is crucial to ensure that the correct key type and algorithm combinations are used for secure token signing and verification.

How To Fix

Latest published version: 9.0.3 as of 23 Oct 2026

npm install jsonwebtoken@9.0.3

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

9.0.0

This is the first release that contains the fix.

npm install jsonwebtoken@9.0.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating to version 9.0.0 is not immediately feasible, the workaround is to explicitly set the allowInvalidAsymmetricKeyTypes option to true in the sign() and verify() functions. This allows the usage of invalid key type/algorithm combinations, but it should only be used as a temporary measure until the package can be updated to a secure version.

Conclusion

The vulnerability in jsonwebtoken versions <=8.5.1 can lead to the usage of insecure key types for token verification. It is crucial to update to version 9.0.0 or later and ensure the correct key type and algorithm combinations are used. Review your code and configurations to address this vulnerability and protect the security of your application.

See every vulnerability recorded for jsonwebtoken →

Share this vulnerability

FAQ

You are affected if you are using jsonwebtoken versions <=8.5.1 and have configured key type and algorithm combinations other than the ones mentioned in the advisory. Check your package version and review your key type and algorithm configurations.

For RSA keys, the valid algorithms are RS256, RS384, RS512, PS256, PS384, and PS512. For EC keys, the valid algorithms are ES256, ES384, and ES512. Make sure your key type and algorithm configurations match these combinations.

The valid curves for ES256, ES384, and ES512 are prime256v1, secp384r1, and secp521r1 respectively. Ensure that the alg parameter in your token matches the correct curve for the chosen algorithm.

There will be no impact if you are already using a valid secure combination of key type and algorithm. However, if you have been using invalid combinations, you will need to update your code to use the correct combinations or set the allowInvalidAsymmetricKeyTypes option to true for legacy compatibility.

You can find more information about this vulnerability, including the affected versions and fix details, in the GitHub Advisory Database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/12/GHSA-8cf7-32gw-wr33/GHSA-8cf7-32gw-wr33.json

Related vulnerabilities

Recent vulnerabilities recorded for jsonwebtoken.

How To Fix

Latest published version: 9.0.3 as of 23 Oct 2026

npm install jsonwebtoken@9.0.3

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

9.0.0

This is the first release that contains the fix.

npm install jsonwebtoken@9.0.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback