PyJWT@1.3.0

JSON Web Token implementation in Python

  • latest version

    2.15.1

  • latest non vulnerable version

  • first published

    15 years ago

  • latest version published

    19 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the PyJWT package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • M
    Regular Expression Denial of Service (ReDoS)

    Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via is_pem_format in jwt/utils.py, which previously used a regex (_PEM_RE) that accepted PEM formatting variants recognised by the underlying cryptography loader but not explicitly validated by pyjwt. An attacker with high privileges can supply a key in one of these loader-accepted PEM variants to trigger a crash, causing a denial of service.

    How to fix Regular Expression Denial of Service (ReDoS)?

    Upgrade pyjwt to version 2.14.0 or higher.

    [,2.14.0)
    • C
    Open Redirect

    PyJWT is a Python implementation of RFC 7519.

    Affected versions of this package are vulnerable to Open Redirect via the fetch_data method in jwt/jwks_client.py, which follows HTTP redirects when fetching a JWK Set from a remote URI. An attacker who can influence the JWKS endpoint URL or perform a MitM attack can redirect the request to an arbitrary server, causing the client to send its request headers (potentially including authorization or other sensitive headers) to an attacker-controlled host, and to accept a forged JWK Set that undermines signature verification.

    How to fix Open Redirect?

    Upgrade PyJWT to version 2.14.0 or higher.

    [,2.14.0)
    • C
    Improper Verification of Cryptographic Signature

    PyJWT is a Python implementation of RFC 7519.

    Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature via is_pem_format() in jwt/utils.py, which fails to recognize certain loader-accepted PEM formatting variants as valid PEM. The fix for CVE-2022-29217 rejects an asymmetric key passed to an HMAC algorithm only when is_pem_format() identifies the key as PEM-encoded. Because the old regex does not match all PEM variants that the underlying cryptography library's loader accepts, an attacker can supply a non-standard but loader-accepted PEM key to bypass the asymmetric-key-as-HMAC-secret guard, enabling signature forgery.

    Note: This is only exploitable when the application accepts a user-influenced key or algorithm selection that allows an asymmetric public key to be used as an HMAC secret.

    How to fix Improper Verification of Cryptographic Signature?

    Upgrade PyJWT to version 2.14.0 or higher.

    [,2.14.0)
    • M
    Incorrect Behavior Order: Validate Before Canonicalize

    PyJWT is a Python implementation of RFC 7519.

    Affected versions of this package are vulnerable to Incorrect Behavior Order: Validate Before Canonicalize via the _load method in jwt/api_jws.py, which accepts non-canonical base64url-encoded JWS segments. Because the library does not verify that a decoded-then-re-encoded segment round-trips to the original input, an attacker can supply a JWT whose header, payload, or signature segment is a non-canonical base64url encoding that decodes to the same bytes as a legitimate token. This allows the attacker to forge or manipulate tokens in ways that bypass integrity checks, leading to limited confidentiality and integrity impact.

    How to fix Incorrect Behavior Order: Validate Before Canonicalize?

    Upgrade PyJWT to version 2.14.0 or higher.

    [,2.14.0)
    • M
    Allocation of Resources Without Limits or Throttling

    Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via PyJWKClient.get_signing_key in jwt/jwks_client.py, where an attacker can repeatedly present tokens with unknown key IDs, causing the client to perform an unbounded number of forced refreshes against the JWKS endpoint. Each unrecognised kid triggers a fresh HTTP fetch with no rate limiting or cooldown, allowing an attacker to exhaust the server's resources or cause excessive outbound network traffic.

    How to fix Allocation of Resources Without Limits or Throttling?

    Upgrade pyjwt to version 2.14.0 or higher.

    [,2.14.0)
    • M
    Improper Verification of Cryptographic Signature

    Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature via the jwt.decode or jwt.decode_complete functions when used with a PyJWK key. An attacker can bypass algorithm restrictions and gain unauthorized access to protected resources by signing a token with a disallowed algorithm, setting an allowed algorithm in the JWT header, and leveraging control over a registered JWK/JWKS private key.

    How to fix Improper Verification of Cryptographic Signature?

    Upgrade pyjwt to version 2.13.0 or higher.

    [,2.13.0)
    • L
    Unintended Proxy or Intermediary ('Confused Deputy')

    Affected versions of this package are vulnerable to Unintended Proxy or Intermediary ('Confused Deputy') via the uri parameter being passed directly to urllib.request.urlopen, which allows fetching resources using unsupported schemes such as file, ftp, and data. An attacker can access arbitrary local files or external resources and potentially forge tokens by supplying crafted URLs.

    Note:

    This is only exploitable if the application's jku URL ingestion path accepts attacker-controlled URLs.

    How to fix Unintended Proxy or Intermediary ('Confused Deputy')?

    Upgrade pyjwt to version 2.13.0 or higher.

    [,2.13.0)
    • M
    Improper Cleanup on Thrown Exception

    Affected versions of this package are vulnerable to Improper Cleanup on Thrown Exception via the get_signing_key function. An attacker can exhaust system resources by sending numerous JWTs with attacker-controlled kid values, causing repeated outbound requests to the JWKS endpoint.

    Note:

    This is only exploitable if the JWKS fetch fails and the upstream endpoint does not implement effective rate limiting or error handling.

    How to fix Improper Cleanup on Thrown Exception?

    Upgrade pyjwt to version 2.13.0 or higher.

    [,2.13.0)
    • M
    Allocation of Resources Without Limits or Throttling

    Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the Base64URL decoding process. An attacker can cause excessive CPU and memory consumption by supplying an arbitrarily large payload segment when verifying detached JWS tokens with the unencoded-payload option enabled.

    How to fix Allocation of Resources Without Limits or Throttling?

    Upgrade pyjwt to version 2.13.0 or higher.

    [,2.13.0)
    • H
    Improper Authentication

    Affected versions of this package are vulnerable to Improper Authentication when decoding JSON Web Tokens. An attacker can forge valid tokens by supplying a public key as the secret for the HMAC algorithm when both asymmetric and HMAC algorithms are supported.

    How to fix Improper Authentication?

    Upgrade pyjwt to version 2.13.0 or higher.

    [,2.13.0)
    • M
    Inadequate Encryption Strength

    Affected versions of this package are vulnerable to Inadequate Encryption Strength due to the HMAC and RSA key lengths used in the JSON Web Signature (JWS) implementation not meeting recommended security standards.

    How to fix Inadequate Encryption Strength?

    Upgrade pyjwt to version 2.11.0 or higher.

    [,2.11.0)
    • H
    Improper Verification of Cryptographic Signature

    Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature due to improper validation of the crit header parameter. An attacker can bypass critical header checks by crafting a JSON Web Signature (JWS) token with unrecognized critical extensions.

    How to fix Improper Verification of Cryptographic Signature?

    Upgrade pyjwt to version 2.12.0 or higher.

    [,2.12.0)
    • H
    Authentication Bypass

    pyjwt is a JSON Web Token implementation in Python.

    Affected versions of the package are vulnerable to Authentication Bypass. In PyJWT 1.5.0 and below the invalid_strings check in HMACAlgorithm.prepare_key does not account for all PEM encoded public keys. Specifically, the PKCS1 PEM encoded format would be allowed because it is prefaced with the string -----BEGIN RSA PUBLIC KEY----- which is not accounted for. This enables symmetric/asymmetric key confusion attacks against users using the PKCS1 PEM encoded public keys, which would allow an attacker to craft JWTs from scratch.

    How to fix Authentication Bypass?

    Upgrade pyjwt to version 1.5.1 or higher.

    [,1.5.1)