CVE-2026-12243: Path Traversal via Percent-Encoding in nltk.data.find() and nltk.data.load()
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(resourcename)) if os.path.exists(p): return FileSystemPathPointer(p)
Proof of Concept import nltk.data nltk.data.path = ["/home/user/nltkdata"] %2e%2e decodes to .. via url2pathname(), escaping the data dir data = nltk.data.load("%2e%2e/SECRETcredentials.txt", format="raw") print(data) b'AWSSECRETKEY=AKIAIOSFODNN7EXAMPLE\nDATABASEPASS=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 resourcename = unquote(resourcename) # 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().
Other sources
Rejected reason: This CVE ID has been rejected or withdrawn by its CVE Numbering Authority.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/nltkto a version that resolves this vulnerability.Fixed in 3.10.0 - Configuration
Update the NLTK data loading logic so that the resource name is decoded first (e.g., call unquote / percent-decoding before performing path safety checks), instead of performing path safety checks on the raw still-encoded string before url2pathname() decoding occurs.
NLTK (nltk.data.load / nltk.data.find / nltk/data.py find) resource_name decoding order = decode before validation
Event History
Frequently Asked Questions
What is CVE-2026-12243?
CVE-2026-12243 is a high severity vulnerability in NLTK version 3.9.4 that allows for path traversal attacks via percent-encoded sequences.
How does the path traversal vulnerability work in CVE-2026-12243?
The vulnerability allows attackers to exploit the incomplete fix of percent-encoded traversal sequences, such as `..%2f`, which can bypass security checks.
What are the potential impacts of CVE-2026-12243?
Exploitation of CVE-2026-12243 can lead to unauthorized access to files outside of the intended directory structure.
How can I fix CVE-2026-12243?
To fix CVE-2026-12243, update to the latest version of NLTK that addresses the path traversal vulnerability.
What should I do if I am using NLTK version 3.9.4?
If you are using NLTK version 3.9.4, it is critical to upgrade to a patched version to mitigate the risk of path traversal attacks.