VulnWatch by ve1ve2
high 8.5 EPSS 0.18%

GHSA-7mxv-7h3q-9324 / CVE-2026-128134: NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element

Source:
GitHub Security Advisories
Published:
Fetched:
Updated:
Affects:
nltk

https://github.com/advisories/GHSA-7mxv-7h3q-9324 ↗

ghsapipCWE-426CWE-427

NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element ## Summary `nltk.parse.dependencygraph.dot2img` invokes the Graphviz `dot` executable without the trusted-execution guarantees that NLTK applies to its other native-tool wrappers. The function resolves `dot` by bare name and then runs the resolved absolute path with a raw `subprocess.run`, omitting the ownership/writability check and the loader-environment scrub that `nltk.pathsec.spawn_trusted` provides. On a POSIX host, a local, unprivileged actor who can write to any group/world-writable directory that appears on the victim's `PATH` can plant a trojan `dot`; when the victim later renders a `DependencyGraph` (for example in a Jupyter notebook, which auto-invokes `_repr_svg_`) or calls `dot2img` directly, the planted binary executes as the victim. The advisory GHSA-6hwm-xvph-95vm (CVE-2026-78680) addressed the same untrusted-search-path class for the Graphviz `dot` invoker in `nltk/translate/api.py`, but `dot2img` received only part of that remediation and remains exploitable. ## Root Cause NLTK's native-tool security model layers four defenses (documented in `nltk/EXTERNAL_TOOL_SECURITY.md`): (1) `find_binary` refuses a current-working-directory-relative match; (2) `resolve_trusted_executable` verifies the resolved file is a regular file that no other unprivileged user can replace (private parent directories, owner is the user or root, no group/world write bit); (3) shell execution is refused; (4) `safe_env` scrubs loader and interpreter environment variables before exec. Layers 2, 3, and 4 are reached only through `nltk.pathsec.spawn_trusted`. `dot2img` calls `find_binary("dot")` (layer 1 only), then executes the result with `subprocess.run([dot_binary, ...])` and no `env=` argument. Layer 1 rejects only non-absolute matches, so an absolute path returned by the `which` search stage survives even when the file lives in a writable directory. Because `dot2img` never calls `spawn_trusted`, the ownership check and environment scrub never run. ```text nltk/parse/dependencygraph.py:626 dot_binary = find_binary("dot") # layer 1 only nltk/parse/dependencygraph.py:631 subprocess.run([dot_binary, "-T%s" % t], ...) # no trust check, no env= nltk/parse/dependencygraph.py:638 subprocess.run([dot_binary, "-T%s" % t], ...) # binary-format branch, same gap nltk/internals.py:1034 if searching_bare_name and not os.path.isabs(path): continue # skips only relative matches nltk/translate/api.py:145 process = spawn_trusted(dot_binary, [f"-T{output_format}"], ...) # hardened sibling ``` ## Impact Prerequisites: a POSIX host on which the attacker is a local, unprivileged user (or code) able to write to a group/world-writable directory that appears on the victim's `PATH`. This includes the commonly cited case of a Homebrew `/usr/local/bin` with `drwxrwxr-x` permissions, or a writable directory placed early on `PATH`. The attacker plants a trojan `dot` there. When the victim renders a `DependencyGraph` (notebook `_repr_s Affected packages: pip:nltk Patched: nltk 3.10.4

Linked vulnerabilities (4)

CVE-2026-128134 high 7.8 EPSS 0.18% (p8) NVDCVE.orgGHSAGHSA
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

nltk: nltk: Arbitrary code execution via untrusted search path

CWE: CWE-427, CWE-426Aliases: GHSA-7mxv-7h3q-9324, CVE-2026-78680, GHSA-6hwm-xvph-95vmNVD: Awaiting Analysis
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element

CWE: CWE-426, CWE-427Aliases: CVE-2026-128134, CVE-2026-78680, GHSA-6hwm-xvph-95vm
CVE-2026-78680 high 8.5 EPSS 0.15% (p5) NVDCVE.org
CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

NLTK versions before 3.10.3 fail to use validated absolute paths when invoking the Graphviz dot binary in dependencygraph.dot2img and AlignedSent._repr_svg_, allowing attackers to execute arbitrary code by placing a malicious dot binary in the search path or current working directory. Attackers can exploit bare-name binary resolution on Windows via the current working directory or on Unix-like systems via relative PATH entries to execute their binary instead of the legitimate Graphviz tool.

CWE: CWE-426NVD: Awaiting Analysis