CVE-2026-102265: PyJWT Uncaught RecursionError in jwt.decode() on Deeply Nested Token Header

pyjwt Updated 30 Sep 2026

Summary

29/09/2026
Yes i
Moderate
5.3

CVE-2026-102265: PyJWT: Uncaught RecursionError in jwt.decode() on deeply nested token header. Affects pyjwt versions >= 2.13.0, < 2.14.0. Fixed in 2.14.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

PyJWT is a Python library that allows developers to encode and decode JSON Web Tokens (JWT). It is widely used for authentication and information exchange in web applications. The library provides a simple interface for creating and verifying tokens, making it a popular choice for securing APIs. However, a vulnerability has been identified in version 2.13.0 that affects the handling of deeply nested JSON arrays in token headers, potentially leading to denial of service attacks.

Vulnerability Detail

The vulnerability arises from the way PyJWT's PyJWS._load() function processes the compact token. When the header segment of the token contains a deeply nested JSON array, the JSON decoder in CPython raises a RecursionError instead of the expected ValueError. This error is not caught by the existing exception handling in the library, allowing an unauthenticated attacker to trigger a server error (HTTP 500) instead of the intended authentication failure (HTTP 401). The recursion threshold is approximately 65,000 nesting levels, making it possible to exploit this vulnerability with a specially crafted token.

How To Fix

Latest published version: 2.15.1 as of 23 Oct 2026

pip install --upgrade "pyjwt==2.15.1"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.14.0

This is the first release that contains the fix.

pip install --upgrade "pyjwt==2.14.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can implement additional validation on the token header before passing it to jwt.decode(). For example, you can limit the depth of the JSON structure or reject tokens that exceed a certain size. Here is a sample code snippet to limit the depth:

import json

def validate_token_header(header):
try:
    json.loads(header)
except json.JSONDecodeError:
        return False
if header.count('[') > 100:  # Limit nesting depth
        return False
    return True

Conclusion

The vulnerability CVE-2026-102265 in PyJWT allows for denial of service attacks through improperly handled deeply nested JSON arrays in token headers. It is crucial to update to version 2.14.0 or later to mitigate this risk. Implementing validation on token headers can serve as a temporary workaround until the update is applied.

See every vulnerability recorded for pyjwt →

Share this vulnerability

FAQ

An unauthenticated attacker can exploit this vulnerability to cause a denial of service by triggering server errors on every request to a JWT validating endpoint.

The vulnerability has been tested and verified on PyJWT version 2.13.0. Any version that does not handle RecursionError in the _load() function is also affected.

You can use Vulert's playground to check if your application is affected by this vulnerability without requiring access to the code or installation. Visit Vulert Scanner for more information.

If you cannot update the package, consider implementing a workaround by validating the token header to limit its depth or size before processing it.

The CVSS score of this vulnerability is 5.3, indicating a moderate severity level.

Related vulnerabilities

Recent vulnerabilities recorded for pyjwt.

How To Fix

Latest published version: 2.15.1 as of 23 Oct 2026

pip install --upgrade "pyjwt==2.15.1"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.14.0

This is the first release that contains the fix.

pip install --upgrade "pyjwt==2.14.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback