NLTK XML corpus reader CPU exhaustion with large comments or CDATA

HighSE Fix-First Score 43/100CVE-2026-128139SE-AIV-01467Denial of service and resource exhaustionAI softwareMade public 20 Nov 2026

Download as PDF

What this means

An attacker who provides a specially made XML file can make a system reading it use 100% of one CPU core for a time that grows with the file size squared. This can freeze document processing, delay analysis pipelines, or be used to trigger service timeouts and downtime.

SecurityElites Manager Brief: the decision in one minute

NLTK versions before 3.10.4 hang for a dangerously long time (quadratic in file size) when reading XML files with large comments or data sections. An attacker can freeze CPU cores and cause denial of service. Upgrade to 3.10.4 or later immediately if your systems read XML corpora.

SecurityElites Fix-First Score43 of 100
Our own ranking of what to fix first. Real attacks count most, then the chance of attack, then severity.
SecurityElites fix windowWithin 30 days
High severity. This is our suggestion from common practice; your own policy comes first.
Who should own the fixData science and NLP engineering teams, plus platform operations.
Likely effortAbout 15 minutes per service: a version bump to 3.10.4 or later and a restart. Testing the fix takes another 10 minutes. This estimate assumes you can identify all services using NLTK and have a standard deployment process.

Questions to ask your team or supplier

  • Do we have inventory of all services and scripts that use NLTK's XML readers, and have we confirmed their current versions?
  • Who provides or controls the XML corpus files that our systems read, and do we have validation or size limits in place for them?

Message you can forward to the owning team

Security notice: NLTK XML corpus reader CPU exhaustion with large comments or CDATA (CVE-2026-128139)

Severity: High
SecurityElites Fix-First Score: 43 of 100
SecurityElites fix window: Within 30 days
Action: upgrade to nltk 3.10.4 or later.
What we need from you: confirm whether we run this software, who owns it, and the date it will be fixed.
Full guide: https://securityelites.com/ai-vulnerabilities/cve-2026-128139-nltk-xml-corpus-reader-cpu-exhaustion-with-large-comments/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01467

What is at stake in your AI setup

  • Training or retrieval data: If NLTK is used to load language corpora for training or retrieval systems, a denial of service attack on the XML reader blocks access to that data.
  • Compute bill: Sustained 100% CPU use from a single-core exhaustion attack wastes compute resources and increases cloud costs.

Map where your company uses AI

Who is exposed

  • Teams using NLTK's XMLCorpusView, NPSChatCorpusReader, or FramenetCorpusReader to read XML files from any source.
  • Services that accept XML corpus files from users, customers, or untrusted sources.
  • Analysis pipelines that process XML-based language datasets without input validation.

Upgrades you need

SoftwareAffected versionsMove to
nltk
PyPI
3.6 up to, but not including, 3.10.43.10.4 or later

Am I affected?

Enter the version you run. Nothing you type is stored.

SecurityElites Developer Brief: the technical picture

Is it being attackedWorking attack code is public, so expect attacks to follow
Where the attacker must beAnywhere that can reach it over a network, including the internet if it is exposed
Account neededNone. No login is needed
Does a person have to do somethingNo. It works without anyone clicking or opening anything
How hard it is to doEasy. It works reliably once the attacker can reach it
Risk of: data being readNone
Risk of: data or settings being changedNone
Risk of: the service being taken downHigh
Can attackers automate it at scaleYes, according to CISA
How much control an attacker gainsPartial control, according to CISA

Read from the official severity rating: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Kind of coding mistake

  • CWE-400: resources can be exhausted
  • CWE-407

Where it sits in the standards

OWASP Top 10 for LLM Applications 2025: LLM10 Unbounded Consumption

If you cannot upgrade today

  • Until you can upgrade, add a file size check before reading XML with NLTK: reject files larger than a reasonable limit (e.g., 10 MB) for your use case.
  • Add a timeout to XML reading operations so that if processing stalls, the operation is cancelled and an alert is raised. Set the timeout to the longest legitimate processing time for your largest expected file.
  • If you control the XML files, validate them with a schema or external tool before passing them to NLTK.

Signs it may already have been used against you

  • CPU usage: One core jumps to 100% during XML corpus file reads and stays there for a long time, longer than expected for the file size. Normal processing is O(n) in file size; quadratic behavior means processing time is much larger than exp
  • Application logs: Processing a single XML file takes many seconds or minutes even though the file is small or medium-sized. The delay is not proportional to file size.
  • File characteristics: The problematic XML file contains a very large comment (between ``) or CDATA section (between ``) with minimal other content.

Log searches to start from

Single-core CPU exhaustion during file processing. Adapt field names to your system.Splunk

source=system_metrics process=nltk OR process=python cpu_usage > 90 duration > 30s | stats avg(duration) by filename | where avg(duration) > 60

Long processing times for XML reads. Adapt field names to match your logs.Elastic

process.name:nltk OR process.name:python AND action:"read_xml" AND duration_ms > 60000 | stats avg(duration_ms) by file.name

Written with AI as a starting point. Review them and change the index and field names to match your own logs before you rely on the result.

SecurityElites Fix Guide: step by step

  1. Find where NLTK is installedList all services and applications in your environment that import or use `nltk.corpus.reader.xmldocs` or the readers that depend on it (NPSChatCorpusReader, FramenetCorpusReader). Check requirements files, dependency lists, and package manager records for `nltk`.
  2. Check the current NLTK versionOn each system, run `pip show nltk` or equivalent to see the installed version. Record all versions found. If the version is 3.10.4 or later, that service is already protected.
  3. Assess XML file sourcesFor each affected service, document where XML corpus files come from: uploaded by users, pulled from a data source, bundled with the application, or fetched from a URL. Focus on services that accept files from outside your control.
  4. Upgrade NLTK to 3.10.4 or laterUse your package manager to install `nltk >= 3.10.4`. For example, in a requirements.txt or setup.py, change the version constraint to `nltk >= 3.10.4`. Then run the installation in each environment (development, testing, production).
  5. Restart affected servicesRestart all applications and services that use NLTK so they load the new version from memory.
  6. Verify the fixRun `pip show nltk` again on each system and confirm the version is 3.10.4 or later. The vulnerability is fixed if the version shown is 3.10.4, 3.10.5, 3.11, or any higher version.
  7. Check for prior exploitationReview CPU usage logs and system monitoring data from the past 90 days for any spikes in CPU use during XML file processing. Look for sustained 100% CPU on a single core that correlates with file uploads or corpus reads. Check application logs for processing times that are unexpectedly long for the file size.
  8. Restrict XML file sourcesIf possible, limit who can upload or provide XML files to your system. Validate file size before processing. Consider adding file size checks and timeouts to XML reading code to catch future attacks early.

How to confirm it is fixed: Confirm that all services have been upgraded to NLTK 3.10.4 or later by running `pip show nltk` and checking the version number.

SecurityElites Quick Fixes: copy and paste

Upgrade nltk with pipupgrade

pip install --upgrade "nltk>=3.10.4"
pip show nltk | grep Version

Pin it in requirements.txtupgrade

nltk>=3.10.4

Check installed NLTK versionfor this issue

pip show nltk | grep Version

Rate and size limits with nginxgeneral hardening

limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;

server {
    location /api/ {
        limit_req zone=api burst=20 nodelay;
        client_max_body_size 2m;
    }
}

Test in a non-production environment first. General hardening examples use placeholder names and ports; change them to match your setup.

Let your AI coding assistant do the upgrade

Paste this into the coding assistant you already use, inside the project. It checks first and asks before it changes anything.

Instruction for your coding assistant

You are helping me fix a security vulnerability (CVE-2026-128139) in this project.\n\n1. Search the whole repository, including lock files, container files and CI configuration, for these packages and list every place they are pinned or installed:\n   - nltk (PyPI): must be 3.10.4 or later
2. Tell me which version we use now and whether it is affected. Stop and ask me before changing anything.
3. After I agree, raise each one to the safe version, update the lock files, and keep every other dependency as it is.
4. Run the tests and tell me what failed.
5. Give me a short summary of the files you changed that I can put in the pull request.

SecurityElites Incident Drill: could your team handle this?

Four questions to ask in your next team meeting. If any has no clear answer, that is the gap to close.

What versions of NLTK are vulnerable to this denial of service attack?A good answer: NLTK versions 3.6 and later up to (but not including) 3.10.4 are vulnerable; 3.10.4 and later are fixed.
What type of XML content can trigger the CPU exhaustion?A good answer: A large comment section (between ``) or a large CDATA section (between ``) in an otherwise well-formed XML file causes the problem.
How would an attacker get a victim to read a malicious XML file?A good answer: They could upload a crafted XML file through a user-facing form, provide it as a data source, or if the system fetches corpus files from a URL they control, serve it from there.
What is the main sign that this attack is happening on a live system?A good answer: One CPU core hits 100% and stays there for a time much longer than expected for the file being processed, often many seconds or minutes for a small or medium file.

Run a full timed drill with your team

Ticket for your backlog

Paste into Jira, GitHub Issues or any tracker that reads Markdown.

Ready-made ticket

## NLTK XML corpus reader CPU exhaustion with large comments or CDATA (CVE-2026-128139)

**Severity:** High  |  **SE Fix-First Score:** 43/100  |  **Fix window:** Within 30 days
**Record:** SE-AIV-01467 https://securityelites.com/ai-vulnerabilities/cve-2026-128139-nltk-xml-corpus-reader-cpu-exhaustion-with-large-comments/

### Why this matters
An attacker who provides a specially made XML file can make a system reading it use 100% of one CPU core for a time that grows with the file size squared. This can freeze document processing, delay analysis pipelines, or be used to trigger service timeouts and downtime.

### What to do
1. Find where NLTK is installed
2. Check the current NLTK version
3. Assess XML file sources
4. Upgrade NLTK to 3.10.4 or later
5. Restart affected services
6. Verify the fix
7. Check for prior exploitation
8. Restrict XML file sources

Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-128139-nltk-xml-corpus-reader-cpu-exhaustion-with-large-comments/

### Done when
- [ ] nltk is at 3.10.4 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Confirm that all services have been upgraded to NLTK 3.10.4 or later by running `pip show nltk` and checking the version number.
- [ ] Logs were checked for signs of earlier use

SecurityElites Fix Tracker

Record who owns this fix, the date it is due and when it is done, and see everything still open in one list. Free with a SecurityElites account.

Sign in to track this fix

Change history

  • 19 Nov 2026: Made public
  • 1 Dec 2026: Published
  • 3 Dec 2026: Guide updated

Official record

> **affected**: PyPI `nltk` `>= 3.6` — `nltk.corpus.reader.xmldocs.XMLCorpusView` streaming read (and the `nps_chat` / `framenet` readers built on it) > **dynamically reproduced**: `3.6` (6/6 checks), `3.9.2` (6/6), `3.10.3` (6/6) and `develop` `6818767b9` (6/6)---_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._### Summary**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.### DetailsRoot 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:```python # xmldocs.py:308 if not in_tag and self._VALID_XML_RE.match(fragment): # whole-buffer match (O(len)) return fragment # xmldocs.py:312 if re.search("[<>]", fragment).group(0) == ">": # O(1) for this input class: ... # the document starts with '<' # xmldocs.py:329 if self._VALID_XML_RE.match(fragment[:last_open_bracket]): # whole-buffer prefix match (O(len)) ... ```For this input class the `re.search` probe at `xmldocs.py:312` is O(1): the fragment always starts with `<` (e.g. `<root>…`), 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).`_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 O(current buffer length) on lines 308 and 329, for a total of ~O(n²) character operations.The `in_tag` guard added for GHSA-vp2x (`xmldocs.py:283-305`) tracks only bare `<`/`>` characters: it is `True` inside an unclosed `<...>` tag and, in that state, skips only the line-308 match. It never represents "the fragment sits inside an unclosed CDATA or comment" — XML allows arbitrary `<`/`>` inside those constructs — so both the line-308 match and the line-329 backtrack match still fire on every block for a CDATA/comment fragment. The comment block at `xmldocs.py:283-289` even documents the intended linearity contract ("re-running it on every 1 KiB block otherwise makes a single oversized tag O(n^2) (CWE-407)"); the guard implements it for the tag branch only.The single-match cost is linear, not super-linear: the embedded script measures `_VALID_XML_RE.match()` on 512 KiB → 1 MiB → 2 MiB unclosed-CDATA buffers and gets ≈ 0.074 s → 0.142 s → 0.280 s (≈ 1:1.9:3.8, i.e. linear), asserting

Weakness type: CWE-400, CWE-407

Use this record in your own tools

Get this record as JSON

curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-128139

For scanners and pipelines: OSV format · CycloneDX format · API guide · Email alerts · Fix tracker

The plain-language sections were written with AI from the official record, and the upgrade versions come directly from the official data. Last updated 4 Dec 2026. Read the vendor advisory before changing a production system.