Описание
NLTK: Corpus Reader Sandbox Bypass
Summary
NLTK corpus-reader constructors can still reach outside-root file and database reads before the nltk.pathsec sandbox boundary is enforced.
The PoC shows the safe path blocked by pathsec.open, then LinThesaurusCorpusReader and PanLexLiteCorpusReader succeeding in the same process.
Affected Product
- Product: NLTK
- Asset / component:
nltk.corpus.readerconstructors - Version tested:
3.10.2 - Deployment / package / tag: commit
474af1f5a94b1b8d53fc2b6defec3a2ce7633b74/ PyPInltk - Environment used for verification: Python 3.13.14
Vulnerability Details
- Vulnerability class: path sandbox bypass / external control of file path
- Required privileges: none beyond the ability to supply a corpus root path to a consumer call site
- Entry point:
LinThesaurusCorpusReader(root)andPanLexLiteCorpusReader(root) - Trust boundary crossed: NLTK data-root sandbox enforced by
nltk.pathsec - Root affected functions:
- Measured unsafe effect: outside-root file/database reads still happen with
ENFORCE=True
Root Cause
CorpusReader.__init__() turns a string root into a FileSystemPathPointer without any pathsec validation, and these readers then use builtin open() or sqlite3.connect() directly on derived paths. The constructor path therefore never hits the sandbox guard that pathsec.open() enforces.
Proof of Concept
Save the script as hy01_raw_path_poc.py in the checkout root and run python hy01_raw_path_poc.py.
Expected output:
Impact
A caller can make NLTK read filesystem content outside the intended NLTK data sandbox through public corpus-reader constructors. In the PoC, that includes a local text file and a local SQLite db.
Severity
- Base Score: 7.5 (High)
- Severity reasoning: The bug is reliably triggerable by caller-controlled path input and exposes data outside the intended trust boundary; no special privileges are needed inside the process.
Remediation
Validate raw string roots before constructing readers, and route all corpus-root/path handling through pathsec or a validated PathPointer. Remove direct builtin open() and direct sqlite3.connect(os.path.join(...)) use on constructor-derived paths.
Ссылки
- https://github.com/nltk/nltk/security/advisories/GHSA-3gq4-3j92-5w49
- https://nvd.nist.gov/vuln/detail/CVE-2026-79674
- https://github.com/nltk/nltk/commit/bc007200d123c1a98d74c2eb230f5e06c53886b8
- https://github.com/nltk/nltk/releases/tag/v3.10.3
- https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3736.yaml
- https://www.vulncheck.com/advisories/nltk-path-traversal-via-corpus-reader-constructors
Пакеты
nltk
<= 3.10.2
3.10.3
Связанные уязвимости
NLTK versions before 3.10.3 contain a path sandbox bypass vulnerability in corpus-reader constructors that allows attackers to read files outside the intended data root. Attackers can supply arbitrary corpus root paths to LinThesaurusCorpusReader and PanLexLiteCorpusReader constructors to access filesystem content and SQLite databases outside the pathsec sandbox boundary.
NLTK versions before 3.10.3 contain a path sandbox bypass vulnerability in corpus-reader constructors that allows attackers to read files outside the intended data root. Attackers can supply arbitrary corpus root paths to LinThesaurusCorpusReader and PanLexLiteCorpusReader constructors to access filesystem content and SQLite databases outside the pathsec sandbox boundary.
NLTK versions before 3.10.3 contain a path sandbox bypass vulnerability in corpus-reader constructors that allows attackers to read files outside the intended data root. Attackers can supply arbitrary corpus root paths to LinThesaurusCorpusReader and PanLexLiteCorpusReader constructors to access filesystem content and SQLite databases outside the pathsec sandbox boundary.
NLTK versions before 3.10.3 contain a path sandbox bypass vulnerabilit ...
Уязвимость компонента nltk.corpus.reader пакета библиотек для символьной и статистической обработки естественного языка NLTK, позволяющая нарушителю получить несанкционированный доступ к защищаемой информации