CVE-2026-78680: NLTK before 3.10.3 Arbitrary Code Execution via Graphviz dot Binary
NLTK versions before 3.10.3 fail to use validated absolute paths when invoking the Graphviz dot binary in dependencygraph.dot2img and AlignedSent.reprsvg, 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.
Other sources
Two NLTK sites executed the Graphviz dot program by bare name, so process creation resolved it via the search path — and on Windows via the current working directory — rather than a validated absolute location. An attacker who can place a file named dot where resolution looks (the CWD on Windows, or a writable/relative entry such as . on PATH) has their binary executed in place of Graphviz (arbitrary code execution).
Affected (<= 3.10.2): - nltk.parse.dependencygraph.dot2img — called findbinary("dot") but discarded the returned validated path and then ran the bare name ["dot", ...], so the validation had no effect. - nltk.translate.api.AlignedSent.reprsvg — ran the bare name with no validation at all (IPython SVG rendering).
This is the same class already fixed for the senna, weka, boxer, malt, repp and hunpos wrappers. nltk.internals.findbinary refuses a CWD-relative match for a bare tool name and returns only a trusted absolute path; the fix runs that path in both sites.
---
Attack demonstration Captured output, not illustrative. A ./dot that writes a PWNED marker, planted in the CWD with . prepended to PATH.
The vulnerable behaviour (old bare-name exec): Control (OLD behavior) — bare ['dot'] in this dir with '.' on PATH: bare ['dot'] executed planted binary = True
The patched functions refuse it: FIXED code, with ./dot planted and '.' on PATH: dependencygraph.dot2img : Exception "Cannot find the dot binary..." | planted-binary-executed=False safe AlignedSent.reprsvg : Exception "Cannot find the dot binary..." | planted-binary-executed=False safe
And findbinary itself was attacked directly (the fix trusts nothing else): Attack 1: ./dot in CWD, no dot on PATH -> LookupError (refused) safe Attack 2: ./dot/dot (dir 'dot' holding 'dot') -> LookupError (refused) safe Attack 3: '.' on PATH + ./dot -> LookupError (refused) safe Attack 4: attacker-writable ABSOLUTE dir on PATH -> returned /…/evilbin/dot (absolute) Attack 4 is out of scope: trusting an absolute directory that is already on PATH is the operating system's own trust model — an attacker who can write to a PATH directory owns the account regardless of NLTK. findbinary defends specifically against the CWD/relative injection that bare-name exec is vulnerable to (attacks 1–3), which is exactly what this fix inherits.
Environment: python 3.13.7. dot is not required to reproduce — the planted binary is the payload.
— GitHub
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/nltkto a version that resolves this vulnerability.Fixed in 3.10.3 - Upgrade
Upgrade
nltkto a version that resolves this vulnerability.Fixed in 3.10.3 - Compensating control
Ensure the process cannot resolve attacker-controlled relative/CWD entries for Graphviz: do not include the current working directory (.) in PATH (especially on Windows), and prevent untrusted users from being able to place a malicious 'dot' executable in writable working directories that may be used when rendering Graphviz output.
Event History
Frequently Asked Questions
Which environments are exposed to this issue?
NLTK installations before 3.10.3 are exposed when code invokes dependencygraph.dot2img or AlignedSent._repr_svg_ and resolves the Graphviz dot executable by bare name. On Windows, a malicious dot binary in the current working directory can be selected; on Unix-like systems, relative entries in PATH can cause the same outcome.
What does an attacker need to exploit it?
An attacker needs the ability to place a malicious executable named dot in a location searched before the legitimate Graphviz binary, such as the current working directory on Windows or a relative PATH location on Unix-like systems. Exploitation also requires the affected NLTK functionality to invoke dot.
What is the immediate mitigation if upgrading is not possible?
Avoid invoking the affected NLTK methods in untrusted or attacker-controlled working directories, and ensure PATH does not contain relative entries. Ensure the dot executable resolved by the process is the legitimate Graphviz binary rather than an attacker-controlled file.