{"vuln_id":"GHSA-j8g8-j4j7-8j54","aliases":["CVE-2026-128139"],"description":"NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service","published_at":"2026-11-19T23:54:59Z","modified_at":"2026-11-20T00:00:04.063029Z","first_seen_at":"2026-11-21T19:15:19.352536Z","severity":"high","severity_source":"ghsa","cvss_score":7.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cwe":["CWE-400","CWE-407"],"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-j8g8-j4j7-8j54"},"matched_alias":null,"items":[{"id":10707,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-j8g8-j4j7-8j54: NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service","summary":"NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service\n\n> **affected**: PyPI `nltk` `>= 3.6` — `nltk.corpus.reader.xmldocs.XMLCorpusView` streaming read (and the `nps_chat` / `framenet` readers built on it)\n> **dynamically reproduced**: `3.6` (6/6 checks), `3.9.2` (6/6), `3.10.3` (6/6) and `develop` `6818767b9` (6/6)\n\n---\n\n_Source references (`nltk/corpus/reader/xmldocs.py:NNN`) are to commit `6818767b99c24659107eb2be9bccd32a3d4bf045` (`develop`, `v3.10.3-15-g6818767b9`). The released `v3.10.3` wheel's `xmldocs.py` is byte-identical to that commit, so the same line numbers apply to the released wheel._\n\n### Summary\n\n**An attacker who can make a victim read a well-formed XML corpus file whose body contains one large comment or CDATA section can pin a CPU core for a time quadratic in the file size, because `XMLCorpusView._read_xml_fragment` (`nltk/corpus/reader/xmldocs.py`) re-runs a linear whole-buffer validation after every 1 KiB block while the comment/CDATA terminator is still ahead.** `XMLCorpusView` is NLTK's documented streaming API for XML corpora and is instantiated directly by the `NPSChatCorpusReader` and `FramenetCorpusReader` readers; the module header (`xmldocs.py:16-20`) explicitly handles untrusted corpus XML. The `in_tag` guard added to this function for GHSA-vp2x covers only a single oversized `<...>` tag and leaves the CDATA/comment path quadratic in the current release.\n\n### Details\n\nRoot cause: `_read_xml_fragment` (`xmldocs.py:273-338`) accumulates the file into one `fragment` string in `_BLOCK_SIZE` (1024) character chunks (`xmldocs.py:123, 298-299`). After every block that is not yet a well-formed prefix, the fragment is re-validated against `_VALID_XML_RE`. Two whole-buffer operations dominate:\n\n```python\n# xmldocs.py:308\nif not in_tag and self._VALID_XML_RE.match(fragment): # whole-buffer match (O(len))\nreturn fragment\n# xmldocs.py:312\nif re.search(\"[<>]\", fragment).group(0) == \">\": # O(1) for this input class:\n... # the document starts with '<'\n# xmldocs.py:329\nif self._VALID_XML_RE.match(fragment[:last_open_bracket]): # whole-buffer prefix match (O(len))\n...\n```\n\nFor this input class the `re.search` probe at `xmldocs.py:312` is O(1): the fragment always starts with `<` (e.g. `\n…`), so the first `<`/`>` character is at offset 0 and it never contributes cost. The quadratic cost comes entirely from the two whole-buffer regex matches at `xmldocs.py:308` and `xmldocs.py:329` (the latter scans the buffer up to the most recent `<`, which for this input sits near the end of the buffer).\n\n`_VALID_XML_RE` (`xmldocs.py:238-249`) is a *linear* regex (its tempered-dot comment/CDATA bodies `(?:(?!-->).)*` / `(?:(?!\\]\\]>).)*` scan left-to-right in O(length) — confirmed by the embedded script's single-match check), but for a fragment whose terminator is far ahead the *match itself fails after scanning the whole buffer*. With an unclosed-across-blocks CDATA or comment, **every one of the n/1024 blocks** pays\n\nAffected: PyPI:nltk\n\nFixed in: 3.10.4\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-j8g8-j4j7-8j54\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-128139\nhttps://github.com/nltk/nltk/commit/9cacbb95d97eaac7debb30d6e7decbe74d2c635f\nhttps://github.com/nltk/nltk\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4","url":"https://osv.dev/vulnerability/GHSA-j8g8-j4j7-8j54","published_at":"2026-11-19T23:54:59Z","updated_at":"2026-11-20T00:00:04.063029Z","fetched_at":"2026-11-21T19:15:55.946119Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-128139","vuln_ids":["CVE-2026-128139","GHSA-J8G8-J4J7-8J54"],"tags":["osv","pypi","fix-available"],"cluster_id":2137,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10707","html":"https://vulnwatch.ve1ve2.com/item/10707"}},{"id":2352,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-j8g8-j4j7-8j54 / CVE-2026-128139: NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service","summary":"NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service\n\n> **affected**: PyPI `nltk` `>= 3.6` — `nltk.corpus.reader.xmldocs.XMLCorpusView` streaming read (and the `nps_chat` / `framenet` readers built on it)\n> **dynamically reproduced**: `3.6` (6/6 checks), `3.9.2` (6/6), `3.10.3` (6/6) and `develop` `6818767b9` (6/6)\n\n---\n\n_Source references (`nltk/corpus/reader/xmldocs.py:NNN`) are to commit `6818767b99c24659107eb2be9bccd32a3d4bf045` (`develop`, `v3.10.3-15-g6818767b9`). The released `v3.10.3` wheel's `xmldocs.py` is byte-identical to that commit, so the same line numbers apply to the released wheel._\n\n### Summary\n\n**An attacker who can make a victim read a well-formed XML corpus file whose body contains one large comment or CDATA section can pin a CPU core for a time quadratic in the file size, because `XMLCorpusView._read_xml_fragment` (`nltk/corpus/reader/xmldocs.py`) re-runs a linear whole-buffer validation after every 1 KiB block while the comment/CDATA terminator is still ahead.** `XMLCorpusView` is NLTK's documented streaming API for XML corpora and is instantiated directly by the `NPSChatCorpusReader` and `FramenetCorpusReader` readers; the module header (`xmldocs.py:16-20`) explicitly handles untrusted corpus XML. The `in_tag` guard added to this function for GHSA-vp2x covers only a single oversized `<...>` tag and leaves the CDATA/comment path quadratic in the current release.\n\n### Details\n\nRoot cause: `_read_xml_fragment` (`xmldocs.py:273-338`) accumulates the file into one `fragment` string in `_BLOCK_SIZE` (1024) character chunks (`xmldocs.py:123, 298-299`). After every block that is not yet a well-formed prefix, the fragment is re-validated against `_VALID_XML_RE`. Two whole-buffer operations dominate:\n\n```python\n# xmldocs.py:308\nif not in_tag and self._VALID_XML_RE.match(fragment): # whole-buffer match (O(len))\nreturn fragment\n# xmldocs.py:312\nif re.search(\"[<>]\", fragment).group(0) == \">\": # O(1) for this input class:\n... # the document starts with '<'\n# xmldocs.py:329\nif self._VALID_XML_RE.match(fragment[:last_open_bracket]): # whole-buffer prefix match (O(len))\n...\n```\n\nFor this input class the `re.search` probe at `xmldocs.py:312` is O(1): the fragment always starts with `<` (e.g. `\n…`), so the first `<`/`>` character is at offset 0 and it never contributes cost. The quadratic cost comes entirely from the two whole-buffer regex matches at `xmldocs.py:308` and `xmldocs.py:329` (the latter scans the buffer up to the most recent `<`, which for this input sits near the end of the buffer).\n\n`_VALID_XML_RE` (`xmldocs.py:238-249`) is a *linear* regex (its tempered-dot comment/CDATA bodies `(?:(?!-->).)*` / `(?:(?!\\]\\]>).)*` scan left-to-right in O(length) — confirmed by the embedded script's single-match check), but for a fragment whose terminator is far ahead the *match itself fails after scanning the whole buffer*. With an unclosed-across-blocks CDATA or comment, **every one of the n/1024 blocks** pays\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-j8g8-j4j7-8j54","published_at":"2026-11-19T23:54:59Z","updated_at":"2026-11-19T23:55:00Z","fetched_at":"2026-11-21T19:15:18.416771Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-128139","vuln_ids":["CVE-2026-128139","GHSA-J8G8-J4J7-8J54"],"tags":["ghsa","pip","CWE-400","CWE-407"],"cluster_id":2137,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2352","html":"https://vulnwatch.ve1ve2.com/item/2352"}},{"id":9031,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-128139: 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. From 3.6 to 3.10.3, XMLCorpusView._read_xml_fragment accumulates 1 KiB blocks and repeatedly applies whole-buffer XML validation while a comment or CDATA terminator remains ahead. A large comment in an attacker-controlled corpus file causes quadratic CPU consumption through documented XML corpus readers across the affected range. On 3.6 and 3.9.2, a large CDATA section incurs the quadratic scan before rejection, while on 3.10.3 both comment and CDATA documents are read successfully. This vulnerability is fixed in 3.10.4.\n\nReferences:\nhttps://github.com/nltk/nltk/commit/9cacbb95d97eaac7debb30d6e7decbe74d2c635f\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4\nhttps://github.com/nltk/nltk/security/advisories/GHSA-j8g8-j4j7-8j54\nhttps://github.com/nltk/nltk/security/advisories/GHSA-j8g8-j4j7-8j54","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-128139","published_at":"2026-11-19T18:18:06.303000Z","updated_at":"2026-11-20T22:17:48.923000Z","fetched_at":"2026-11-21T19:15:31.484685Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-128139","vuln_ids":["CVE-2026-128139","GHSA-J8G8-J4J7-8J54"],"tags":["CWE-400","CWE-407"],"cluster_id":2138,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/9031","html":"https://vulnwatch.ve1ve2.com/item/9031"}}]}