CVE-2026-33236 Overview
CVE-2026-33236 is a path traversal vulnerability affecting the Natural Language Toolkit (NLTK), a widely-used open source Python library for Natural Language Processing research and development. The vulnerability exists in the NLTK downloader component, which fails to properly validate the subdir and id attributes when processing remote XML index files. This lack of input validation allows attackers who control a remote XML index server to inject malicious path traversal sequences (such as ../) into these attributes, potentially leading to arbitrary directory creation, arbitrary file creation, and arbitrary file overwrite on the target system.
Critical Impact
Attackers controlling a malicious XML index server can achieve arbitrary file writes and directory traversal on systems using vulnerable NLTK versions, potentially leading to code execution or system compromise.
Affected Products
- NLTK (Natural Language Toolkit) version 3.9.3 and prior
- All Python environments utilizing vulnerable NLTK versions
- Applications and ML pipelines that use the NLTK downloader functionality
Discovery Timeline
- 2026-03-20 - CVE CVE-2026-33236 published to NVD
- 2026-03-23 - Last updated in NVD database
Technical Details for CVE-2026-33236
Vulnerability Analysis
This path traversal vulnerability (CWE-22) stems from insufficient input validation in the NLTK downloader module. The downloader component processes XML index files from remote servers to manage package installations. When parsing these XML files, the subdir and id attributes are accepted without any sanitization or validation for path traversal sequences. This design flaw allows an attacker who controls or can manipulate a remote XML index server to craft malicious XML content that, when processed by the vulnerable downloader, can write files to arbitrary locations outside the intended download directory. The attack requires user interaction—specifically, a user must interact with a malicious or compromised XML index server—but once triggered, the consequences include arbitrary directory creation, file creation, and file overwrite capabilities.
Root Cause
The root cause of this vulnerability is the absence of input validation for path-related attributes in the package class constructor within nltk/downloader.py. Prior to the patch, the subdir and id parameters were directly assigned to class attributes without checking for:
- Absolute paths that could redirect file operations outside the expected directory
- Parent directory references (..) that enable path traversal
- Path separators (/, \, os.sep) in the id field that could manipulate file paths
This oversight allowed malicious XML index files to specify directory traversal sequences, enabling attackers to escape the NLTK data directory and write to arbitrary filesystem locations.
Attack Vector
The attack requires network access and user interaction with a malicious XML index server. An attacker could:
- Set up or compromise an XML index server that NLTK users might connect to
- Craft malicious XML index content with path traversal sequences in subdir or id attributes (e.g., subdir="../../../etc" or id="../malicious")
- When a victim's NLTK downloader fetches and processes this malicious index, the path traversal sequences are used to write files outside the intended directory
- This can result in overwriting critical files, creating malicious files in sensitive directories, or achieving code execution through strategic file placement
The security patch adds validation to prevent these attacks:
self.name = name or id
"""A string name for this package."""
+ # Validate subdir to prevent path traversal from malicious XML index
+ if os.path.isabs(subdir) or ".." in subdir.replace("\\", "/").split("/"):
+ raise ValueError(
+ f"Invalid package subdir {subdir!r}: must be a relative path "
+ f"without parent directory references"
+ )
self.subdir = subdir
"""The subdirectory where this package should be installed.
E.g., ``'corpora'`` or ``'taggers'``."""
+ # Validate id to prevent path traversal
+ if os.sep in id or "/" in id or "\\" in id or ".." in id:
+ raise ValueError(
+ f"Invalid package id {id!r}: must not contain path separators"
+ )
+
self.url = url
"""A URL that can be used to download this package's file."""
Source: GitHub Commit 89fe2ec
Detection Methods for CVE-2026-33236
Indicators of Compromise
- Unexpected file creation or modification outside the NLTK data directory (typically ~/nltk_data/)
- Presence of files with unusual names or in unexpected locations that correlate with NLTK downloader activity
- Log entries showing NLTK downloader connections to unknown or suspicious XML index servers
- Files containing path traversal sequences (../) in application logs or configuration files
Detection Strategies
- Monitor filesystem activity during NLTK package downloads for writes outside the expected nltk_data directory
- Implement network monitoring to detect connections to non-standard NLTK index servers
- Use application-level logging to capture and analyze XML index content being processed by NLTK
- Deploy file integrity monitoring (FIM) on sensitive directories to detect unauthorized modifications
Monitoring Recommendations
- Enable verbose logging for Python applications using NLTK to capture downloader activity
- Implement egress filtering and monitoring for network connections from systems running NLTK
- Configure alerts for any file operations in sensitive system directories that correlate with Python/NLTK process activity
- Regularly audit NLTK configurations to ensure only trusted index servers are configured
How to Mitigate CVE-2026-33236
Immediate Actions Required
- Update NLTK to the patched version that includes commit 89fe2ec2c6bae6e2e7a46dad65cc34231976ed8a
- Audit existing NLTK installations across your environment to identify vulnerable versions
- Review any custom or third-party XML index servers used with NLTK for potential compromise
- Restrict network access for systems running NLTK to only trusted index servers
Patch Information
The vulnerability is addressed in commit 89fe2ec2c6bae6e2e7a46dad65cc34231976ed8a, which adds input validation for both the subdir and id attributes in the downloader module. The patch validates that subdir is a relative path without parent directory references and that id does not contain any path separators. For complete details, refer to the GitHub Security Advisory GHSA-469j-vmhf-r6v7.
Workarounds
- Avoid using the NLTK downloader functionality with untrusted or unknown XML index servers until patched
- Configure firewall rules to block NLTK downloader connections to all but explicitly trusted index servers
- Run NLTK in sandboxed or containerized environments with restricted filesystem access to limit the impact of potential exploitation
- Manually download and install NLTK data packages from trusted sources instead of using the automated downloader
# Update NLTK to the latest patched version
pip install --upgrade nltk
# Verify the installed version includes the security fix
python -c "import nltk; print(nltk.__version__)"
# Alternative: Install directly from the patched commit
pip install git+https://github.com/nltk/nltk.git@89fe2ec2c6bae6e2e7a46dad65cc34231976ed8a
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


