Executive brief
NLTK is a Python library for natural language processing that includes visualization capabilities for parsing and translation tasks. Two visualization functions in NLTK could be tricked into running an attacker-controlled executable file instead of the legitimate Graphviz 'dot' program if the attacker can place a malicious file in the current directory or on the system PATH. This allows arbitrary code execution with the privileges of the user running Python—a critical risk for any system using NLTK for document analysis or interactive notebooks.
Technical details
This is a CWE-426/CWE-427 (untrusted search path) vulnerability in NLTK's binary invocation. Two vulnerable sites exist: (1) nltk.parse.dependencygraph.dot2img() called find_binary("dot") to validate the path but then discarded the returned absolute path and executed the bare name ["dot", ...], defeating the validation; and (2) nltk.translate.api.AlignedSent._repr_svg_() invoked the bare name with no validation at all (used in IPython SVG rendering). On Windows, the current working directory is searched before PATH; on Unix-like systems, relative entries like "." on PATH are vulnerable. An attacker needs local file placement capability (e.g., write access to the CWD or a writable PATH directory) and the ability to trigger the vulnerable code (parsing/SVG rendering). The fix applies find_binary()'s trusted absolute-path validation to both sites, raising LookupError on missing binaries, which is converted to the user-facing "Cannot find the dot binary" exception. Patched in version 3.10.3; affected versions are 3.10.2 and earlier.
Affected products
- NLTK Project NLTK <= 3.10.2
Timeline
- 2026-08-11: disclosed: GitHub Advisory published
- 2026-09-01: advisory: Advisory updated in GitHub Advisory Database
- 2026-08-12: patched: NLTK version 3.10.3 released with fix
References
- https://github.com/nltk/nltk/security/advisories/GHSA-6hwm-xvph-95vm
- https://github.com/nltk/nltk/commit/1a3cd1764ab3deb084fb66d0ffb4873717659538
- https://github.com/nltk/nltk/releases/tag/v3.10.3
- https://www.vulncheck.com/advisories/nltk-before-arbitrary-code-execution-via-graphviz-dot-binary
- https://api.github.com/repos/nltk/nltk/security-advisories/GHSA-6hwm-xvph-95vm