NLTK: Uncontrolled recursion in Toolbox settings helpers causes denial of service via deeply nested input
Root Cause
The Toolbox settings-tree helpers recurse over the parsed element tree without any depth
bound. _to_settings_string (nltk/toolbox.py:418), remove_blanks
(nltk/toolbox.py:432), add_default_fields (nltk/toolbox.py:451), _sort_fields
(nltk/toolbox.py:484), and add_blank_lines (nltk/toolbox.py:502,516) each recurse once
per element level with no depth counter or explicit stack. The producer
ToolboxSettings.parse builds the element tree iteratively, so nesting depth is driven
entirely by attacker-supplied \+marker / \-marker pairs.
Impact
An application that parses an untrusted Toolbox settings file and then serialises or
transforms it through any of the public helper functions aborts with an unhandled
RecursionError, terminating the affected operation or request worker (denial of service,
CWE-674). The recursion is pure Python, yielding a catchable RecursionError rather than
memory corruption or code execution. Confidentiality and integrity are unaffected.
Attack Chain
- The application parses an untrusted settings file via
ToolboxSettings.open_string/openplusparse, producing an N-deep element tree; parsing is iterative and completes without error. - The application passes the tree to a public helper —
to_settings_string,remove_blanks,add_default_fields,sort_fields, oradd_blank_lines— as in the module's own parse-then-serialise round trip. - The helper recurses once per element level with no depth guard, consuming call-stack frames. This holds even when the helper's configuration dictionaries are empty.
- Once the nesting depth exceeds the interpreter recursion limit, an unhandled
RecursionErrorpropagates out of the public API.
Bypass Evidence
Against the shipped source at the default recursion limit, a settings input nested 5 levels
deep traverses cleanly through every helper, while a well-formed input nested 5000 levels
deep drives each of the five helpers to an unhandled RecursionError; the iterative parse
builds the 4999-deep tree without error, isolating the fault to the recursive helpers. The
config-taking helpers (add_default_fields, sort_fields, add_blank_lines) recurse to
failure even with empty configuration dictionaries. A repository-wide search confirms no
depth guard exists anywhere in this module.
Suggested Fix
Cap nesting depth at the shared producer ToolboxSettings.parse (the choke point that
builds the tree), or convert the five helpers to iterative traversals / add a shared
recursion-depth bound, so all consumers are protected by one fix.
Reported by pi (GitHub: @manus-pi).
Fix status (2026-09-28)
Status: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).
PR: #3885 "Bound recursion depth in parsers and traversal helpers" (ekaf), merged 2026-09-11, merge commit e521ecafc on develop.
Fix commit: 0b6975377 (nltk/toolbox.py: the settings helpers stop at MAX_TOOLBOX_DEPTH=500 with ValueError).
Probe: nltk/test/unit/security_probes/ghsa_f2h2_f4fc_p978.py (added in 2a6704952 on that PR); verdict on develop 2fa3f48fe: FIXED (bounded during parse (ValueError)).
Release: none yet; no release tag contains e521ecafc.
Software afectado
Haz clic en una tecnología para ver todas sus vulnerabilidades.
| Plataforma | Paquete | Versiones vulnerables | Corregida en |
|---|---|---|---|
| Python (PyPI) | nltk | < 3.10.4 | 3.10.4 |
Referencias
- https://github.com/nltk/nltk/security/advisories/GHSA-f2h2-f4fc-p978
- https://nvd.nist.gov/vuln/detail/CVE-2026-129228
- https://github.com/nltk/nltk/pull/3885
- https://github.com/nltk/nltk/commit/0b6975377d0334af604d32c9d83b26b46e1d437c
- https://github.com/nltk/nltk
- https://github.com/nltk/nltk/releases/tag/v3.10.4
- Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L- Debilidad (CWE)
CWE-674- Plataforma
- Python (PyPI)
- Paquete
nltk- Publicada
- 19.11.2026
- Actualizado
- 20.11.2026 01:17
Fuentes y licencias
OSV / GitHub Advisory Database - GHSA-f2h2-f4fc-p978 - CC BY 4.0
Historial de vulnerabilidades: nltk
Todas las vulnerabilidades publicadas de este paquete (Python (PyPI)), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.
- Entradas en total
- 79
- Primera → última
- 08.2019 11.2026
- Sin corrección
- 5
- Explotada en ataques
- 0
Distribución por gravedad
- Crítica 5
- Alta 41
- Media 31
- Baja 2
Divulgaciones por año
- 2019: 1
- 2020: 0
- 2021: 2
- 2022: 1
- 2023: 0
- 2024: 1
- 2025: 0
- 2026: 74
-
NLTK: Uncontrolled recursion in Toolbox settings helpers causes denial of service via deeply nested input esta entrada
Identifica las vulnerabilidades de tu aplicación
Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.