CVE-2026-102265
Deeply nested JWT header triggers RecursionError, causing HTTP 500 errors.
- CVSS 5.3
- CWE-674
- Input Validation and Sanitization
- Remote
PyJWT is a Python implementation of JSON Web Token standards. From 2.13.0 until 2.14.0, PyJWS._load in jwt/api_jws.py is affected because parser catches ValueError but not RecursionError. This occurs when a deeply nested token header reaches json.loads. As a result, RecursionError escapes the documented PyJWT error hierarchy. Consequently, an unauthenticated malformed token can cause a request-level failure and HTTP 500. This issue is fixed in version 2.14.0.
- CWE
- CWE-674
- CVSS base score
- 5.3
- Published
- 2026-09-28
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- PyJWT
- Fixed by upgrading
- Yes
Solution
Upgrade PyJWT to version 2.14.0 (or later).
Vulnerable code sample
import jwt
def verify_token(token: str, secret: str) -> dict:
# VULNERABLE: RecursionError not caught, leaks as 500
try:
# PyJWT may raise RecursionError on deeply nested headers
payload = jwt.decode(token, secret, algorithms=["HS256"])
return payload
except jwt.exceptions.PyJWTError as e:
# Normal error handling
raise ValueError("Invalid JWT") from ePatched code sample
import jwt
def verify_token(token: str, secret: str) -> dict:
# FIX: Catch RecursionError and translate to PyJWT error
try:
payload = jwt.decode(token, secret, algorithms=["HS256"])
return payload
except RecursionError as e:
raise jwt.exceptions.DecodeError("Invalid JWT header") from e
except jwt.exceptions.PyJWTError as e:
raise ValueError("Invalid JWT") from ePublished fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Handle recursive JWS headers as decode errors (jpadilla/pyjwt)
jwt/api_jws.py · PyJWS._load
Cite this entry
@misc{vaitp:cve2026102265,
title = {{Deeply nested JWT header triggers RecursionError, causing HTTP 500 errors.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102265},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102265/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
