External Control of File Name or Path Affecting nltk package, versions [3.10.0,3.10.4)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.29% (22nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about External Control of File Name or Path vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-NLTK-22549718
  • published14 Nov 2026
  • disclosed13 Nov 2026
  • creditzx, Daniel Coles, manus-use

Introduced: 13 Nov 2026

NewCVE-2026-126295  (opens in a new tab)
CWE-22  (opens in a new tab)
CWE-73  (opens in a new tab)

How to fix?

Upgrade nltk to version 3.10.4 or higher.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to External Control of File Name or Path via BllipParser.__init__ in nltk/parse/bllip.py, which passes caller-supplied filesystem paths directly to the native bllipparser C extension without routing them through NLTK's pathsec validation. The constructor parameters parser_model, reranker_features, and reranker_weights, as well as the model_dir argument of from_unified_model_dir(), flow unchanged to the C extension's load_parser_model() and load_reranker_model() calls, which open and read the given path at the OS level. An attacker who can influence any of these path arguments can designate an arbitrary file outside the NLTK data roots - including local configuration or credential files readable by the process - for the extension to open and read, bypassing the pathsec data-root confinement that every other NLTK native-tool wrapper enforces. Additionally, supplying a non-regular file (FIFO, socket, device, or directory) or an oversized regular file can cause the native loader to block or read unbounded data into memory, crashing the worker.

Note: This is only exploitable when the optional bllipparser C extension is installed (pip install bllipparser) and an application passes attacker-influenced input as a model path to BllipParser.

PoC

Requires the optional bllipparser C extension to be installed
(pip install bllipparser) so that RerankingParser.load_parser_model
is available. No NLTK data download is needed to exercise the path.
# An application forwards an untrusted "model" path into BllipParser.
from nltk.parse.bllip import BllipParser

# Attacker-controlled value reaches the constructor unchanged.
untrusted_path = "/etc/passwd"
BllipParser(parser_model=untrusted_path)
# The bllipparser C extension opens and reads untrusted_path at the OS
# level with no NLTK pathsec confinement to the data roots.
Structural confirmation without the optional extension installed:

$ grep -n "pathsec\|validate_path\|validate_tool" nltk/parse/bllip.py
(no output)

$ grep -n "validate_tool_path" nltk/tag/crf.py nltk/tag/hunpos.py \
      nltk/tag/stanford.py nltk/parse/malt.py
nltk/tag/crf.py:140
nltk/tag/crf.py:311
nltk/tag/hunpos.py:111
nltk/tag/stanford.py:85
nltk/tag/stanford.py:137
nltk/parse/malt.py:340
nltk/parse/malt.py:344

BllipParser is the only native-tool wrapper with no validate_tool_path call.

Note: Requires the optional bllipparser C extension to be installed via pip; no NLTK data download is needed.

CVSS Base Scores

version 4.0
version 3.1