Staging Environment: Content and features may be unstable or change without notice.
Search for packages
Package details: pkg:pypi/pyjwt@0.4.1
purl pkg:pypi/pyjwt@0.4.1
Next non-vulnerable version 2.12.0
Latest non-vulnerable version 2.12.0
Risk 4.0
Vulnerabilities affecting this package (3)
Vulnerability Summary Fixed by
VCID-42yf-7k7m-dkf6
Aliases:
CVE-2017-11424
GHSA-r9jw-mwhq-wp62
PYSEC-2017-24
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.
1.5.1
Affected by 2 other vulnerabilities.
VCID-shhe-tubm-f7f8
Aliases:
CVE-2026-32597
GHSA-752w-5fwx-jx9f
PyJWT accepts unknown `crit` header extensions ## Summary PyJWT does not validate the `crit` (Critical) Header Parameter defined in RFC 7515 §4.1.11. When a JWS token contains a `crit` array listing extensions that PyJWT does not understand, the library accepts the token instead of rejecting it. This violates the **MUST** requirement in the RFC. This is the same class of vulnerability as CVE-2025-59420 (Authlib), which received CVSS 7.5 (HIGH). --- ## RFC Requirement RFC 7515 §4.1.11: > The "crit" (Critical) Header Parameter indicates that extensions to this > specification and/or [JWA] are being used that **MUST** be understood and > processed. [...] If any of the listed extension Header Parameters are > **not understood and supported** by the recipient, then the **JWS is invalid**. --- ## Proof of Concept ```python import jwt # PyJWT 2.8.0 import hmac, hashlib, base64, json # Construct token with unknown critical extension header = {"alg": "HS256", "crit": ["x-custom-policy"], "x-custom-policy": "require-mfa"} payload = {"sub": "attacker", "role": "admin"} def b64url(data): return base64.urlsafe_b64encode(data).rstrip(b"=").decode() h = b64url(json.dumps(header, separators=(",", ":")).encode()) p = b64url(json.dumps(payload, separators=(",", ":")).encode()) sig = b64url(hmac.new(b"secret", f"{h}.{p}".encode(), hashlib.sha256).digest()) token = f"{h}.{p}.{sig}" # Should REJECT — x-custom-policy is not understood by PyJWT try: result = jwt.decode(token, "secret", algorithms=["HS256"]) print(f"ACCEPTED: {result}") # Output: ACCEPTED: {'sub': 'attacker', 'role': 'admin'} except Exception as e: print(f"REJECTED: {e}") ``` **Expected:** `jwt.exceptions.InvalidTokenError: Unsupported critical extension: x-custom-policy` **Actual:** Token accepted, payload returned. ### Comparison with RFC-compliant library ```python # jwcrypto — correctly rejects from jwcrypto import jwt as jw_jwt, jwk key = jwk.JWK(kty="oct", k=b64url(b"secret")) jw_jwt.JWT(jwt=token, key=key, algs=["HS256"]) # raises: InvalidJWSObject('Unknown critical header: "x-custom-policy"') ``` --- ## Impact - **Split-brain verification** in mixed-library deployments (e.g., API gateway using jwcrypto rejects, backend using PyJWT accepts) - **Security policy bypass** when `crit` carries enforcement semantics (MFA, token binding, scope restrictions) - **Token binding bypass** — RFC 7800 `cnf` (Proof-of-Possession) can be silently ignored - See CVE-2025-59420 for full impact analysis --- ## Suggested Fix In `jwt/api_jwt.py`, add validation in `_validate_headers()` or `decode()`: ```python _SUPPORTED_CRIT = {"b64"} # Add extensions PyJWT actually supports def _validate_crit(self, headers: dict) -> None: crit = headers.get("crit") if crit is None: return if not isinstance(crit, list) or len(crit) == 0: raise InvalidTokenError("crit must be a non-empty array") for ext in crit: if ext not in self._SUPPORTED_CRIT: raise InvalidTokenError(f"Unsupported critical extension: {ext}") if ext not in headers: raise InvalidTokenError(f"Critical extension {ext} not in header") ``` --- ## CWE - CWE-345: Insufficient Verification of Data Authenticity - CWE-863: Incorrect Authorization ## References - [RFC 7515 §4.1.11](https://www.rfc-editor.org/rfc/rfc7515.html#section-4.1.11) - [CVE-2025-59420 — Authlib crit bypass (CVSS 7.5)](https://osv.dev/vulnerability/GHSA-9ggr-2464-2j32) - [RFC 7800 — Proof-of-Possession Key Semantics](https://www.rfc-editor.org/rfc/rfc7800)
2.12.0
Affected by 0 other vulnerabilities.
VCID-up5n-d12g-u3g6
Aliases:
GMS-2015-6
JWT Verification bypass It is possible for an attacker to bypass verification when "a token digitally signed with an asymetric key (RS/ES family) of algorithms but instead the attacker send a token digitally signed with a symmetric algorithm (HS* family)". It is also possible for an attacker to create his own signed token with any payload he wants and have it considered valid using the "none" algorithm.
1.0.0
Affected by 2 other vulnerabilities.
Vulnerabilities fixed by this package (0)
Vulnerability Summary Aliases
This package is not known to fix vulnerabilities.

Date Actor Action Vulnerability Source VulnerableCode Version
2026-05-01T14:52:02.477088+00:00 GHSA Importer Affected by VCID-42yf-7k7m-dkf6 https://github.com/advisories/GHSA-r9jw-mwhq-wp62 38.6.0
2026-04-29T23:25:29.204741+00:00 GitLab Importer Affected by VCID-shhe-tubm-f7f8 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2026-32597.yml 38.5.0
2026-04-29T20:26:57.533351+00:00 GitLab Importer Affected by VCID-42yf-7k7m-dkf6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2017-11424.yml 38.5.0
2026-04-29T19:08:57.597961+00:00 GitLab Importer Affected by VCID-up5n-d12g-u3g6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/GMS-2015-6.yml 38.5.0
2026-04-17T00:40:41.076504+00:00 GitLab Importer Affected by VCID-shhe-tubm-f7f8 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2026-32597.yml 38.4.0
2026-04-16T21:47:12.042353+00:00 GitLab Importer Affected by VCID-42yf-7k7m-dkf6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2017-11424.yml 38.4.0
2026-04-16T20:32:21.331164+00:00 GitLab Importer Affected by VCID-up5n-d12g-u3g6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/GMS-2015-6.yml 38.4.0
2026-04-16T02:10:46.497156+00:00 GHSA Importer Affected by VCID-42yf-7k7m-dkf6 https://github.com/advisories/GHSA-r9jw-mwhq-wp62 38.4.0
2026-04-13T14:31:28.986956+00:00 GitLab Importer Affected by VCID-shhe-tubm-f7f8 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2026-32597.yml 38.3.0
2026-04-11T23:03:01.204476+00:00 GitLab Importer Affected by VCID-42yf-7k7m-dkf6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2017-11424.yml 38.3.0
2026-04-11T21:42:45.072626+00:00 GitLab Importer Affected by VCID-up5n-d12g-u3g6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/GMS-2015-6.yml 38.3.0
2026-04-11T13:37:43.053208+00:00 GHSA Importer Affected by VCID-42yf-7k7m-dkf6 https://github.com/advisories/GHSA-r9jw-mwhq-wp62 38.3.0
2026-04-02T23:11:25.138021+00:00 GitLab Importer Affected by VCID-42yf-7k7m-dkf6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2017-11424.yml 38.1.0
2026-04-02T21:56:54.288591+00:00 GitLab Importer Affected by VCID-up5n-d12g-u3g6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/GMS-2015-6.yml 38.1.0
2026-04-02T14:26:52.927507+00:00 GHSA Importer Affected by VCID-42yf-7k7m-dkf6 https://github.com/advisories/GHSA-r9jw-mwhq-wp62 38.1.0
2026-04-01T17:31:16.757659+00:00 GitLab Importer Affected by VCID-42yf-7k7m-dkf6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2017-11424.yml 38.0.0
2026-04-01T16:14:04.709216+00:00 GitLab Importer Affected by VCID-up5n-d12g-u3g6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/GMS-2015-6.yml 38.0.0
2026-04-01T14:59:55.248997+00:00 PyPI Importer Affected by VCID-42yf-7k7m-dkf6 https://osv-vulnerabilities.storage.googleapis.com/PyPI/all.zip 38.0.0
2026-04-01T12:41:32.441805+00:00 Pypa Importer Affected by VCID-42yf-7k7m-dkf6 https://github.com/pypa/advisory-database/blob/main/vulns/pyjwt/PYSEC-2017-24.yaml 38.0.0