CVE-2022-23540: Insecure Default Algorithm in jsonwebtoken Library
Summary
CVE-2022-23540: Overview In versions. Affects jsonwebtoken versions < 9.0.0. Fixed in 9.0.0. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
The jsonwebtoken library is an npm package that provides functionality for creating, signing, and verifying JSON Web Tokens (JWTs). JWTs are used for secure transmission of information between parties. The library allows developers to generate and validate JWTs using various algorithms. However, versions <=8.5.1 of the library have a vulnerability that can lead to signature validation bypass. This vulnerability occurs when the jwt.verify() function is used with a token that has no signature, no specified algorithms, and a falsy secret or key. In such cases, the library defaults to the none algorithm for signature verification, which can be exploited to bypass signature validation.
Vulnerability Detail
The vulnerability in the jsonwebtoken library allows an attacker to bypass signature validation when using the jwt.verify() function. By providing a token with no signature, no specified algorithms, and a falsy secret or key, the library defaults to the none algorithm for signature verification. This means that even if the token is tampered with or does not have a valid signature, it will still be considered valid by the library. This can lead to unauthorized access or privilege escalation in applications that rely on JWTs for authentication or authorization.
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
There is no specific workaround for this vulnerability. The best course of action is to update to a fixed version of the jsonwebtoken library.
Conclusion
The jsonwebtoken library versions <=8.5.1 are vulnerable to signature validation bypass due to an insecure default algorithm in the jwt.verify() function. To mitigate this vulnerability, it is crucial to update to version 9.0.0 or later of the library. This update removes the default support for the none algorithm and ensures that tokens with no signature and no specified algorithms are not considered valid. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for jsonwebtoken →
FAQ
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide the package-lock.json file of your application, and Vulert will analyze it for any open-source vulnerabilities, including this one.
The consequences of this vulnerability can vary depending on how JWTs are used in the affected application. In general, it can lead to unauthorized access or privilege escalation, as the library will consider tampered or invalid tokens as valid. This can result in attackers bypassing authentication or gaining elevated privileges within the application.
At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is important to update to a fixed version of the jsonwebtoken library to mitigate the risk of potential exploits.
No, the default support for the none algorithm has been removed in version 9.0.0 of the jsonwebtoken library. If you still need to use the none algorithm, you must explicitly specify it in the jwt.verify() options.
There should be no impact on existing users if they update to version 9.0.0 or later of the jsonwebtoken library and do not rely on the none algorithm. However, if the none algorithm is required, it must be explicitly specified in the jwt.verify() options.
References
Related vulnerabilities
Recent vulnerabilities recorded for jsonwebtoken.