Staging Environment: Content and features may be unstable or change without notice.
Search for packages
Package details: pkg:pypi/pyjwt@2.10.0
purl pkg:pypi/pyjwt@2.10.0
Next non-vulnerable version 2.12.0
Latest non-vulnerable version 2.12.0
Risk 4.0
Vulnerabilities affecting this package (2)
Vulnerability Summary Fixed by
VCID-5zts-netw-syay
Aliases:
CVE-2024-53861
GHSA-75c5-xw7c-p5pm
PyJWT Issuer field partial matches allowed ### Summary The wrong string if check is run for `iss` checking, resulting in `"acb"` being accepted for `"_abc_"`. ### Details This is a bug introduced in version [2.10.0](https://github.com/jpadilla/pyjwt/commit/1570e708672aa9036bc772476beae8bfa48f4131#diff-6893ad4a1c5a36b8af3028db8c8bc3b62418149843fc382faf901eaab008e380R366): checking the "iss" claim changed from `isinstance(issuer, list)` to `isinstance(issuer, Sequence)`. ```diff - if isinstance(issuer, list): + if isinstance(issuer, Sequence): if payload["iss"] not in issuer: raise InvalidIssuerError("Invalid issuer") else: ``` Since str is a Sequnce, but not a list, `in` is also used for string comparison. This results in `if "abc" not in "__abcd__":` being checked instead of `if "abc" != "__abc__":`. ### PoC Check out the unit tests added here: https://github.com/jpadilla/pyjwt-ghsa-75c5-xw7c-p5pm ```python issuer = "urn:expected" payload = {"iss": "urn:"} token = jwt.encode(payload, "secret") # decode() succeeds, even though `"urn:" != "urn:expected". No exception is raised. with pytest.raises(InvalidIssuerError): jwt.decode(token, "secret", issuer=issuer, algorithms=["HS256"]) ``` ### Impact I would say the real world impact is not that high, seeing as the signature still has to match. We should still fix it.
2.10.1
Affected by 1 other vulnerability.
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.
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-04-29T23:25:29.311348+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-29T21:57:17.668323+00:00 GitLab Importer Affected by VCID-5zts-netw-syay https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2024-53861.yml 38.5.0
2026-04-17T00:40:41.185486+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-16T23:15:59.227220+00:00 GitLab Importer Affected by VCID-5zts-netw-syay https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2024-53861.yml 38.4.0
2026-04-13T14:31:29.061350+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-12T00:34:39.654770+00:00 GitLab Importer Affected by VCID-5zts-netw-syay https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2024-53861.yml 38.3.0
2026-04-07T04:56:32.933583+00:00 GHSA Importer Affected by VCID-5zts-netw-syay https://github.com/advisories/GHSA-75c5-xw7c-p5pm 38.1.0
2026-04-03T00:42:25.324836+00:00 GitLab Importer Affected by VCID-5zts-netw-syay https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2024-53861.yml 38.1.0
2026-04-02T12:40:29.510110+00:00 GitLab Importer Affected by VCID-5zts-netw-syay https://gitlab.com/gitlab-org/advisories-community/-/blob/main/pypi/PyJWT/CVE-2024-53861.yml 38.0.0
2026-04-01T12:50:08.422282+00:00 GithubOSV Importer Affected by VCID-5zts-netw-syay https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/12/GHSA-75c5-xw7c-p5pm/GHSA-75c5-xw7c-p5pm.json 38.0.0