VAITP Dataset

← Back to the dataset

CVE-2026-129221

NLTK ARFF_Formatter writes unsafe class labels into ARFF schema (pre‑3.10.4)

  • CVSS 5.4
  • CWE-74
  • Input Validation and Sanitization
  • 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, nltk.classify.weka.ARFF_Formatter writes attacker-controlled class labels into the Weka ARFF @ATTRIBUTE '-label-' declaration without safely formatting the label tokens. Crafted labels can alter the generated ARFF schema or records, corrupting classifier input and causing integrity loss or processing failure. This issue is fixed in version 3.10.4.

CVSS base score
5.4
Published
2026-11-19
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Interface
Code defect classification
Incorrect Interface
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
NLTK
Fixed by upgrading
Yes

Solution

Upgrade NLTK to version 3.10.4 or newer.

Vulnerable code sample

import re
from nltk.classify.weka import ARFF_Formatter

def build_arff(instances, class_label):
    """
    Build an ARFF representation of `instances` using the supplied
    `class_label` as the attribute name.
    """
    fmt = ARFF_Formatter()
    # VULNERABLE: writes attacker‑controlled label directly into the ARFF header
    header = f"@ATTRIBUTE '-label-' {class_label}\n"
    fmt.add_attribute(header)
    for feats, lbl in instances:
        fmt.add_instance(feats, lbl)
    return fmt.format()

Patched code sample

import re
from nltk.classify.weka import ARFF_Formatter

def build_arff(instances, class_label):
    """
    Build an ARFF representation of `instances` using the supplied
    `class_label` as the attribute name.
    """
    fmt = ARFF_Formatter()
    # FIX: sanitize the label before embedding it in the ARFF header
    safe_label = re.sub(r"[^\w\-]", "_", class_label)
    header = f"@ATTRIBUTE '-label-' {safe_label}\n"
    fmt.add_attribute(header)
    for feats, lbl in instances:
        fmt.add_instance(feats, lbl)
    return fmt.format()

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 ARFF label injection in Weka classifier (nltk/nltk)
    nltk/classify/weka.py, nltk/classify/weka.py · ARFF_Formatter.data_section, nltk/classify/weka.py · ARFF_Formatter.from_train, nltk/classify/weka.py · ARFF_Formatter.header_section, nltk/classify/weka.py · ARFF_Formatter.write, nltk/classify/weka.py · ARFF_Formatter._fmt_arff_val, nltk/classify/weka.py · ARFF_Formatter.__init__

Cite this entry

@misc{vaitp:cve2026129221,
  title        = {{NLTK ARFF_Formatter writes unsafe class labels into ARFF schema (pre‑3.10.4)}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129221},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129221/}}
}

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.