VAITP Dataset

← Back to the dataset

CVE-2026-129231

Quadratic CPU DoS in NLTK <3.10.4 via long line in corpus file.

  • CVSS 5.3
  • CWE-400
  • Resource Management
  • Local

NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Prior to 3.10.4, SeekableUnicodeStreamReader.readline appends each new block to a growing character buffer and reruns splitlines over the entire buffer on every iteration. An attacker-controlled corpus file containing one very long unterminated line therefore causes quadratic CPU consumption in line-oriented corpus readers and can deny service. This issue is fixed in version 3.10.4.

CVSS base score
5.3
Published
2026-11-19
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
NLTK
Fixed by upgrading
Yes

Solution

Upgrade NLTK to version 3.10.4 or later.

Vulnerable code sample

import io
from nltk.corpus.reader.util import SeekableUnicodeStreamReader

def count_lines(filepath):
    """Count lines in a corpus file using NLTK's SeekableUnicodeStreamReader."""
    # VULNERABLE: quadratic CPU due to growing buffer in readline
    with open(filepath, "rb") as raw:
        reader = SeekableUnicodeStreamReader(raw)
        line_count = 0
        while True:
            line = reader.readline()
            if not line:
                break
            line_count += 1
    return line_count

Patched code sample

import io
from nltk.corpus.reader.util import SeekableUnicodeStreamReader

def count_lines(filepath):
    """Count lines in a corpus file using a safe buffered reader."""
    # FIX: replace SeekableUnicodeStreamReader with TextIOWrapper to avoid quadratic buffering
    with open(filepath, "rb") as raw:
        reader = io.TextIOWrapper(raw, encoding="utf-8")
        line_count = 0
        while True:
            line = reader.readline()
            if not line:
                break
            line_count += 1
    return line_count

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.

Cite this entry

@misc{vaitp:cve2026129231,
  title        = {{Quadratic CPU DoS in NLTK <3.10.4 via long line in corpus file.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129231},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129231/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.