CVE-2026-128134: Local Code Execution via Untrusted Search Path in NLTK dependencygraph
Vulnerability ID: CVE-2026-128134
CVSS Score: 7.8
Published: 2026-11-16
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.
TL;DR
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.
Technical Details
- 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
Affected Systems
- Natural Language Toolkit (nltk) on POSIX systems
- nltk: < 3.10.4 (Fixed in:
3.10.4)
Code Analysis
Commit: b002a72
Spawn dot through the trusted path in dependencygraph
File: 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: {}" Mitigation Strategies
- Upgrade NLTK to version 3.10.4 or later to enforce trusted binary validation and loader environment scrubbing via nltk.pathsec.spawn_trusted.
- Audit system and user PATH environment variables on multi-user POSIX systems to eliminate world-writable and group-writable directories.
- Pin the GRAPHVIZ_DOT environment variable to a trusted, root-owned absolute path such as /usr/bin/dot.
Remediation Steps:
- Update the nltk Python package using pip: pip install --upgrade 'nltk>=3.10.4'
- Verify the installed version by running: python3 -c 'import nltk; print(nltk.version)'
- Run a filesystem permission audit across all directories in $PATH to ensure modes do not permit group (0o020) or world (0o002) write access.
- Set export GRAPHVIZ_DOT=/usr/bin/dot in system-wide profile scripts (/etc/profile) on shared servers where Graphviz is used.
References
- GitHub Commit b002a7288c22db86fd6ca2d9526e3f91d6fda797: Spawn dot through the trusted path in dependencygraph
- NLTK Pull Request #3887
- NLTK Release v3.10.4
- GitHub Security Advisory GHSA-7mxv-7h3q-9324
- CVE.org Record: CVE-2026-128134
- CVE v5 JSON Specification for CVE-2026-128134
- National Vulnerability Database (NVD): CVE-2026-128134
- Wiz Vulnerability Database: CVE-2026-128134
Read the full report for CVE-2026-128134 on our website for more details including interactive diagrams and full exploit analysis.