CVE-2026-128137
NLTK path traversal via symlink allows reading files outside corpus root.
- CVSS 5.5
- CWE-59
- Input Validation and Sanitization
- Local
NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. From 3.9.4 until 3.10.4, NLTK corpus-reader path pointers and view methods validate a requested relative path without consistently resolving intermediate directory symlinks against the reader's scoped root. A local attacker who can place such a symlink can make abspaths or words reach a readable file outside the corpus root and disclose its contents. On releases with pathsec enforcement, the file must remain inside a global NLTK allowed root; version 3.9.4 has enforcement disabled and permits a broader escape. This issue is fixed in version 3.10.4.
- CWE
- CWE-59
- CVSS base score
- 5.5
- Published
- 2026-11-19
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Local
- Impact
- Information Disclosure
- Affected component
- NLTK
- Fixed by upgrading
- Yes
Solution
Upgrade NLTK to version 3.10.4 or newer.
Vulnerable code sample
import os
from nltk.corpus.reader.plaintext import PlaintextCorpusReader
def read_corpus_file(root_dir: str, rel_path: str) -> str:
"""
Reads a file from an NLTK corpus using a relative path.
"""
# VULNERABLE: does not resolve intermediate symlinks, allowing path traversal
corpus = PlaintextCorpusReader(root_dir, '.*')
# The internal `abspath` call validates the relative path but may be bypassed via symlinks.
with corpus.abspath(rel_path) as f:
return f.read()Patched code sample
import os
from nltk.corpus.reader.plaintext import PlaintextCorpusReader
def read_corpus_file(root_dir: str, rel_path: str) -> str:
"""
Reads a file from an NLTK corpus using a relative path.
"""
# FIX: resolve symlinks to enforce the corpus root boundary
corpus = PlaintextCorpusReader(root_dir, '.*')
safe_path = os.path.realpath(corpus.abspath(rel_path))
if not safe_path.startswith(os.path.realpath(root_dir) + os.sep):
raise ValueError("Attempted path traversal outside corpus root")
with open(safe_path, 'r', encoding='utf-8') as f:
return f.read()Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Contain CorpusReader / agreement / chat80 file I/O in the pathsec sandbox (nltk/nltk)
nltk/corpus/reader/api.py,nltk/corpus/reader/api.py · CorpusReader.abspath,nltk/corpus/reader/api.py · CorpusReader.abspaths,nltk/corpus/reader/api.py · CorpusReader.open,nltk/corpus/reader/api.py · CorpusReader.__init__,nltk/metrics/agreement.py,nltk/sem/chat80.py,nltk/sem/chat80.py · cities2table,nltk/sem/chat80.py · label_indivs,nltk/sem/chat80.py · main,nltk/sem/chat80.py · val_dump,nltk/sem/chat80.py · val_load
Cite this entry
@misc{vaitp:cve2026128137,
title = {{NLTK path traversal via symlink allows reading files outside corpus root.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-128137},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-128137/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
