Skip to main content

CVE-2022-29217: CWE-327: Use of a Broken or Risky Cryptographic Algorithm in jpadilla pyjwt

Medium
Published: Tue May 24 2022 (05/24/2022, 14:10:10 UTC)
Source: CVE
Vendor/Project: jpadilla
Product: pyjwt

Description

PyJWT is a Python implementation of RFC 7519. PyJWT supports multiple different JWT signing algorithms. With JWT, an attacker submitting the JWT token can choose the used signing algorithm. The PyJWT library requires that the application chooses what algorithms are supported. The application can specify `jwt.algorithms.get_default_algorithms()` to get support for all algorithms, or specify a single algorithm. The issue is not that big as `algorithms=jwt.algorithms.get_default_algorithms()` has to be used. Users should upgrade to v2.4.0 to receive a patch for this issue. As a workaround, always be explicit with the algorithms that are accepted and expected when decoding.

AI-Powered Analysis

AILast updated: 06/23/2025, 08:20:36 UTC

Technical Analysis

CVE-2022-29217 is a vulnerability identified in the PyJWT library, a widely used Python implementation of JSON Web Tokens (JWT) as defined by RFC 7519. JWTs are commonly used for securely transmitting information between parties as a JSON object, and they rely on cryptographic signing algorithms to ensure the integrity and authenticity of the token. PyJWT supports multiple signing algorithms, and the library allows the application to specify which algorithms are accepted when decoding tokens. The vulnerability arises when an application uses the default setting `jwt.algorithms.get_default_algorithms()` without explicitly restricting the accepted algorithms. This default includes some cryptographic algorithms considered broken or risky (CWE-327), which can be exploited by an attacker who crafts a JWT token specifying a weak or insecure signing algorithm. By doing so, the attacker may bypass signature verification, potentially allowing token forgery or manipulation. The issue affects PyJWT versions from 1.5.0 up to but not including 2.4.0. The recommended mitigation is to upgrade to version 2.4.0 or later, where the vulnerability is patched. Alternatively, applications should explicitly specify and restrict the accepted algorithms when decoding JWTs rather than relying on the default set. This vulnerability does not require user interaction or authentication to exploit, but it does require the attacker to submit a crafted JWT token to the application. There are no known exploits in the wild reported to date. The vulnerability primarily impacts the confidentiality and integrity of systems relying on PyJWT for authentication or authorization mechanisms, as compromised tokens could lead to unauthorized access or privilege escalation.

Potential Impact

For European organizations, the impact of this vulnerability can be significant, especially for those relying on PyJWT for securing APIs, web applications, or microservices architectures. Exploitation could allow attackers to forge JWT tokens, bypass authentication controls, and gain unauthorized access to sensitive data or systems. This could lead to data breaches, unauthorized transactions, or disruption of services. Sectors such as finance, healthcare, government, and critical infrastructure that use JWT for identity and access management are particularly at risk. The vulnerability undermines the integrity and confidentiality of authentication tokens, potentially enabling lateral movement within networks or privilege escalation. Given the widespread use of Python and PyJWT in modern web applications, the scope of affected systems is broad. However, the absence of known exploits in the wild suggests that exploitation is not yet widespread, though the risk remains high if unpatched. Organizations failing to upgrade or explicitly restrict algorithms expose themselves to potential compromise, regulatory non-compliance, and reputational damage.

Mitigation Recommendations

1. Immediate upgrade of PyJWT to version 2.4.0 or later, where the vulnerability is patched. 2. Review all applications using PyJWT to ensure that the decoding of JWT tokens explicitly specifies accepted algorithms rather than relying on the default set. For example, use `jwt.decode(token, key, algorithms=['HS256'])` to restrict to secure algorithms. 3. Conduct code audits to identify any instances where `jwt.algorithms.get_default_algorithms()` or similar default settings are used and replace them with explicit algorithm lists. 4. Implement additional token validation layers such as token expiration checks, issuer validation, and audience restrictions to reduce the risk of token misuse. 5. Monitor application logs for suspicious JWT tokens or authentication anomalies that could indicate attempted exploitation. 6. Educate developers and security teams about secure JWT handling practices and the risks of using weak cryptographic algorithms. 7. For critical systems, consider implementing Web Application Firewalls (WAFs) or API gateways that can enforce strict JWT validation policies. These measures go beyond generic advice by focusing on explicit algorithm restriction, code auditing, and layered validation controls.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-04-13T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9843c4522896dcbf2fc8

Added to database: 5/21/2025, 9:09:23 AM

Last enriched: 6/23/2025, 8:20:36 AM

Last updated: 8/15/2025, 12:10:29 AM

Views: 18

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats