CVE-2026-129228: NLTK Denial of Service Vulnerability
MODERATECVE-2026-129228 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-674: Uncontrolled Recursion) affecting NLTK libraries in the PyPI ecosystem. The issue involves uncontrolled recursion in toolbox settings helpers causes denial of service via deeply nested input. Remediation is available by upgrading affected packages to version 3.10.4.
CVE-2026-129228 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).
How to Fix CVE-2026-129228
To remediate this vulnerability, upgrade all affected NLTK dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install nltk>=3.10.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show nltk
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-129228, inspect your installed packages using pip:
pip show nltk
Analyze the terminal output to locate any version of NLTK in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.10.4), your application is affected.
Note: The pip show nltk command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In NLTK, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-129228 Affected NLTK Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nltk
|
PyPI |
< 3.10.4
|
3.10.4
|
References
Frequently Asked Questions
What is CVE-2026-129228?
Which NLTK versions are affected?
What version fixes CVE-2026-129228?
Is nltk affected?
What is the CVSS score of CVE-2026-129228?
What CWE is associated with CVE-2026-129228?
How can I check PyPI dependencies for CVE-2026-129228?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-f2h2-f4fc-p978",
"modified" : "2026-11-19T23:50:38Z",
"published" : "2026-11-19T23:50:37Z",
"aliases" : [ "CVE-2026-129228" ],
"summary" : "NLTK: Uncontrolled recursion in Toolbox settings helpers causes denial of service via deeply nested input",
"details" : "## Root Cause\nThe Toolbox settings-tree helpers recurse over the parsed element tree without any depth\nbound. `_to_settings_string` (`nltk/toolbox.py:418`), `remove_blanks`\n(`nltk/toolbox.py:432`), `add_default_fields` (`nltk/toolbox.py:451`), `_sort_fields`\n(`nltk/toolbox.py:484`), and `add_blank_lines` (`nltk/toolbox.py:502,516`) each recurse once\nper element level with no depth counter or explicit stack. The producer\n`ToolboxSettings.parse` builds the element tree iteratively, so nesting depth is driven\nentirely by attacker-supplied `\\+marker` / `\\-marker` pairs.\n\n## Impact\nAn application that parses an untrusted Toolbox settings file and then serialises or\ntransforms it through any of the public helper functions aborts with an unhandled\n`RecursionError`, terminating the affected operation or request worker (denial of service,\nCWE-674). The recursion is pure Python, yielding a catchable `RecursionError` rather than\nmemory corruption or code execution. Confidentiality and integrity are unaffected.\n\n## Attack Chain\n1. The application parses an untrusted settings file via `ToolboxSettings.open_string` /\n `open` plus `parse`, producing an *N*-deep element tree; parsing is iterative and\n completes without error.\n2. The application passes the tree to a public helper — `to_settings_string`,\n `remove_blanks`, `add_default_fields`, `sort_fields`, or `add_blank_lines` — as in the\n module's own parse-then-serialise round trip.\n3. The helper recurses once per element level with no depth guard, consuming call-stack\n frames. This holds even when the helper's configuration dictionaries are empty.\n4. Once the nesting depth exceeds the interpreter recursion limit, an unhandled\n `RecursionError` propagates out of the public API.\n\n## Bypass Evidence\nAgainst the shipped source at the default recursion limit, a settings input nested 5 levels\ndeep traverses cleanly through every helper, while a well-formed input nested 5000 levels\ndeep drives each of the five helpers to an unhandled `RecursionError`; the iterative parse\nbuilds the 4999-deep tree without error, isolating the fault to the recursive helpers. The\nconfig-taking helpers (`add_default_fields`, `sort_fields`, `add_blank_lines`) recurse to\nfailure even with empty configuration dictionaries. A repository-wide search confirms no\ndepth guard exists anywhere in this module.\n\n## Suggested Fix\nCap nesting depth at the shared producer `ToolboxSettings.parse` (the choke point that\nbuilds the tree), or convert the five helpers to iterative traversals / add a shared\nrecursion-depth bound, so all consumers are protected by one fix.\n\nReported by pi (GitHub: @manus-pi).\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: #3885 \"Bound recursion depth in parsers and traversal helpers\" (ekaf), merged 2026-09-11, merge commit e521ecafc on develop.\n\nFix commit: 0b6975377 (nltk/toolbox.py: the settings helpers stop at MAX_TOOLBOX_DEPTH=500 with ValueError).\n\nProbe: 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)).\n\nRelease: none yet; no release tag contains e521ecafc.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "nltk"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.10.4"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.10.3"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/security/advisories/GHSA-f2h2-f4fc-p978"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-129228"
}, {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/pull/3885"
}, {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/commit/0b6975377d0334af604d32c9d83b26b46e1d437c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nltk/nltk"
}, {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/releases/tag/v3.10.4"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-674" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-11-19T23:50:37Z",
"nvd_published_at" : "2026-11-19T19:17:21Z"
}
}