CVE-2026-66393
Unbounded recursion in NLTK JSONTaggedDecoder leads to DoS via deep JSON.
- CVSS 8.7
- CWE-674
- Resource Management
- Remote
NLTK versions before 3.9.4 contain an unbounded recursion vulnerability in JSONTaggedDecoder.decode_obj() that allows attackers to cause denial of service by supplying deeply nested JSON structures. Attackers can craft JSON payloads exceeding the recursion limit to trigger an unhandled RecursionError that crashes the Python process.
- CWE
- CWE-674
- CVSS base score
- 8.7
- Published
- 2026-08-22
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Serialization Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- NLTK
- Fixed by upgrading
- Yes
Solution
Upgrade NLTK to version 3.9.4 or newer.
Vulnerable code sample
import json
from nltk.corpus.util import JSONTaggedDecoder
def decode_payload(raw_json: str):
# VULNERABLE: unbounded recursion in JSONTaggedDecoder.decode_obj()
decoder = JSONTaggedDecoder()
return decoder.decode_obj(json.loads(raw_json))Patched code sample
import json
from nltk.corpus.util import JSONTaggedDecoder
def decode_payload(raw_json: str, max_depth: int = 20):
# FIX: limit recursion depth when decoding JSON
def _limited_object_hook(pairs, depth=0):
if depth > max_depth:
raise ValueError("JSON nesting exceeds safe depth")
return {k: v if not isinstance(v, dict) else _limited_object_hook(v.items(), depth+1) for k, v in pairs}
safe_json = json.loads(raw_json, object_pairs_hook=lambda pairs: _limited_object_hook(pairs))
decoder = JSONTaggedDecoder()
return decoder.decode_obj(safe_json)Published 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.
- Fix GHSA-rf74-v2fm-23pw: unbounded recursion in JSONTaggedDecoder (nltk/nltk)
nltk/jsontags.py,nltk/jsontags.py · JSONTaggedDecoder.decode,nltk/jsontags.py · JSONTaggedDecoder.decode_obj
Cite this entry
@misc{vaitp:cve202666393,
title = {{Unbounded recursion in NLTK JSONTaggedDecoder leads to DoS via deep JSON.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-66393},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-66393/}}
}
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 ::
