Arbitrary File Read in NLTK via Path Traversal
NLTK versions prior to 3.10.0 are vulnerable to path traversal (CVE-2026-12243) due to improper sequence decoding in nltk.data.load(), allowing attackers to read arbitrary files.
CVE search metadata
CVE search record: CVE-2026-12243. Severity: high. CVSS: 7.5. EPSS: 0.58%. KEV: no. Product: nltk. Brief: Arbitrary File Read in NLTK via Path Traversal. Brief link: https://feed.craftedsignal.io/briefs/2026-08-nltk-path-traversal/
NLTK (Natural Language Toolkit) versions prior to 3.10.0 contain a critical path traversal vulnerability (CVE-2026-12243) in the nltk.data.load() and nltk.data.find() functions. The vulnerability exists because the library performs security validation checks on a user-supplied resource_name string before decoding percent-encoded sequences using url2pathname().
An attacker can bypass these safety checks by supplying encoded traversal sequences (e.g., %2e%2e instead of ..). Because the security validation logic operates on the encoded input, the malicious path is permitted. Once the internal validation is cleared, url2pathname() decodes the sequence to .., enabling the function to resolve paths outside of the intended NLTK data directory. This allows an attacker to read any file on the filesystem accessible by the application process, including sensitive credentials, configuration files, and SSH keys.
Impact
Successful exploitation allows unauthorized access to sensitive system files. In environments where an application exposes functionality that accepts user-defined resource paths to the NLTK library (such as an NLTK-based web scraper or NLP analysis service), an unauthenticated or low-privileged attacker can exfiltrate arbitrary files. This may lead to credential theft, full server compromise, or unauthorized access to protected application data.
Recommendation
- Upgrade the
nltklibrary to version 3.10.0 or later immediately to patch CVE-2026-12243. - Audit applications using
nltk.data.load()ornltk.data.find()to determine if user-controlled input is passed directly to these functions without external sanitization. - If upgrading is not immediately possible, implement a wrapper around
nltk.data.load()that manually performs URL decoding (urllib.parse.unquote) on the input path before any other processing or validation occurs.
Immediate actions
Patch nltk to 3.10.0 or later
Mitigations
Validate all user-supplied paths passed to NLTK functions
CVE-2026-12243