CVE-2022-3102: jwcrypto token substitution can lead to authentication bypass
Summary
CVE-2022-3102: jwcrypto token substitution can lead to authentication bypass. Affects jwcrypto versions < 1.4. Fixed in 1.4. 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 jwcrypto package is an open-source library available on PyPI that provides functionality for JSON Web Tokens (JWT). JWTs are used for securely transmitting information between parties as a JSON object. The jwcrypto library allows for the creation, signing, and validation of JWTs. However, a vulnerability has been discovered in the library that can lead to authentication bypass or authorization bypass if the token substitution attack is successfully executed.
Vulnerability Detail
The vulnerability in jwcrypto arises from the library's ability to auto-detect the type of token being provided. This can result in incorrect conclusions about the trustworthiness of the token. An attacker can substitute a signed JWS (JSON Web Signature) with a JWE (JSON Web Encryption) that is encrypted with the public key normally used for signature validation. This attack is only possible if the validating application also has access to the private key used for signing the tokens. The impact of this attack depends on the use of the token, potentially leading to authentication bypass or authorization bypass. The attacker has full control over the data placed in the JWE and can inject any desired claim value.
How To Fix
Latest published version: 1.6.1 as of 22 Oct 2026
pip install --upgrade "jwcrypto==1.6.1"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
1.4
This is the first release that contains the fix.
pip install --upgrade "jwcrypto==1.4"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If you are unable to immediately update the jwcrypto package, you can implement the following workaround to mitigate the risk of the token substitution attack:
- Ensure that the private key corresponding to the public key used for encryption is not accessible to the application during token validation.
- Specify the 'use' parameter of the JWK (JSON Web Key) as 'sig' to indicate that the key is only used for signing/verification. This will raise an exception if the key is used for encryption.
- If the JWK includes the 'key_ops' parameter, ensure that it does not include the 'decrypt' operation. This will also raise an exception if the key is used for encryption.
- Implement token type checking before validation to detect unexpected JWS tokens.
Conclusion
The jwcrypto package is vulnerable to a token substitution attack that can lead to authentication bypass or authorization bypass. It is recommended to update the package to version 1.4 or higher to mitigate this vulnerability. If immediate updating is not possible, implementing the provided workaround can help reduce the risk. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for jwcrypto →
FAQ
The impact of this vulnerability depends on the use of the token. It can potentially lead to authentication bypass or authorization bypass, allowing an attacker to gain unauthorized access or perform unauthorized actions.
To determine if your application is affected, you can use the Vulert Playground at Vulert Scanner. Simply input your Pipfile.lock file, and Vulert will check for any open-source vulnerabilities, including this specific vulnerability.
Yes, this vulnerability can be exploited remotely if the attacker is able to submit a malicious token to the application for validation.
Yes, there are several mitigating factors that can protect applications from this issue. These include ensuring that the private key used for signing tokens is not accessible during validation, specifying the 'use' parameter of the JWK as 'sig', and checking the token type before validation.
The severity rating of this vulnerability is moderate. While it has the potential for significant impact, there are mitigating factors in place that can reduce the risk. However, the rating may vary depending on the specific use case and operational constraints.
References
Related vulnerabilities
Recent vulnerabilities recorded for jwcrypto.