/

CVE-2026-78681

Severity:

HIGH RISK

(7.5)

XML Entity Expansion (CWE-776) in NLTK XML Parsing

CVE-2026-78681

Analyzed

Vulnerability type

Category:

XML Entity Expansion

CWE:

CWE-776

Impact:

Denial of Service

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

NLTK versions before 3.10.3 parse XML with an XML processor that honors entity declarations in document DTDs. An attacker who can submit or cause processing of crafted XML may trigger excessive entity expansion, consuming large amounts of memory and causing denial of service.

Affected context

The vulnerability occurs in NLTK modules that process attacker-influenced XML using xml.etree.ElementTree. It becomes risky when untrusted XML is accepted from external sources or indirectly processed through documents, feeds, datasets, or other application inputs, and when entity expansion is not restricted before parsing.

Exploit preconditions

  • Attack surface: NLTK functionality that parses XML documents
  • Required access: Ability to provide, influence, or cause processing of XML input
  • Trigger point: XML parsing of a document containing nested entity declarations
  • Why exploitation is possible: The parser expands entities recursively, allowing a compact document to consume disproportionate memory during processing

Why this happens

The underlying issue is resource exhaustion caused by unrestricted XML entity expansion. XML parsers that honor DTD entity declarations can recursively replace nested entities, allowing input size to grow dramatically in memory.

This maps to CWE-776: Improper Restriction of Recursive Entity References in DTDs, where an application processes recursive or deeply nested entity references without adequate limits or safe-parser controls.

Potential impact

  • Affected processes may consume excessive memory
  • Applications may become unresponsive or terminate unexpectedly
  • Shared workers or services may experience resource starvation
  • Availability of XML-processing features could be reduced
  • Repeated requests could amplify operational disruption

General mitigation guidance

Mitigation generally focuses on preventing untrusted XML from using expansive DTD features and reducing the parser's trust in document-provided instructions.

Common defensive patterns include:

  • Using XML parsers configured to disable DTD processing and entity expansion
  • Applying bounded parsing limits for document size, nesting, and resource consumption
  • Validating XML against a restrictive schema or accepted document model
  • Treating externally supplied XML as untrusted regardless of its source system
  • Isolating XML-processing workloads and assigning only the privileges and resources they require
  • Applying request, queue, timeout, and memory policies to limit denial-of-service impact

How teams detect issues like this

Detection can include static analysis for XML parser calls that permit DTDs or entity expansion, along with code review of NLTK data-ingestion paths and any XML input boundaries.

Runtime monitoring may look for abnormal memory growth, parser timeouts, repeated XML-processing failures, unusually small documents producing large in-memory structures, and request patterns targeting XML endpoints. Policy enforcement can require hardened XML parser configurations and bounded resource usage. Automated code review and dependency analysis tools may help identify unsafe parser behavior and affected dependency ranges.

Sources

SourceLink
github.comgithub.com/nltk/nltk/security/advisories/GHSA-97qj-x29f-37w7
vulncheck.comvulncheck.com/advisories/nltk-before-entity-expansion-dos-via-elementtree

Frequently asked

questions

It can be remotely exploitable when an application processes XML supplied or influenced by an external user. Exploitability depends on whether untrusted XML reaches the affected NLTK parsing code.

The attacker generally needs a way to submit, modify, or trigger processing of XML content. No administrative access is necessarily required if an exposed application accepts the relevant input.

Use a hardened XML parser configuration that disables DTD processing and entity expansion, while enforcing document-size and resource limits.

Treat XML as untrusted input, standardize secure parser policies, review dependency behavior, validate input boundaries, and monitor XML-processing resource usage.

Find out what's already
exploitable in your codebase.