NLTK Stanford wrapper classes execute untrusted JAR files without verification
Five Stanford interface classes in NLTK accept user-controllable JAR paths and execute them via subprocess without integrity verification. An attacker who can supply a malicious JAR file could achieve arbitrary code execution.
nltk/nltk
Originally disclosed on huntr
In nltk/nltk versions 3.9.3 and earlier, five Stanford interface classes (StanfordPOSTagger, StanfordNERTagger, StanfordParser, StanfordDependencyParser, and StanfordNeuralDependencyParser) are vulnerable to untrusted JAR code execution. These classes accept user-controllable JAR paths and execute them via the java() function, which invokes subprocess.Popen() without integrity verification. This vulnerability is identical to CVE-2026-0848, which was fixed for StanfordSegmenter by adding SHA256 verification. However, the fix was not applied to these additional classes, leaving them susceptible to arbitrary code execution when loading untrusted JAR files.
From the GitHub Advisory Database (GHSA-9r6g-266r-89x4, CC BY 4.0).
What the report shows
The target is the NLTK library, in versions 3.9.3 and earlier. The affected feature is the set of Stanford interface classes that wrap the Stanford NLP tools: StanfordPOSTagger, StanfordNERTagger, StanfordParser, StanfordDependencyParser and StanfordNeuralDependencyParser. Each of these classes takes a path to a JAR file and runs it.
The report states that these five classes accept user-controllable JAR paths and execute them through the java() function, which calls subprocess.Popen() without any integrity verification. In other words, whatever JAR path is handed to the class is launched as a Java process, with no check that the file is the expected, trusted Stanford artefact.
The report ties this directly to CVE-2026-0848. That earlier issue affected StanfordSegmenter, and it was fixed by adding SHA256 verification of the JAR before execution. The same fix was not applied to the five classes listed above, so they remain able to execute an arbitrary JAR supplied by whoever controls the path.
The report contains no proof-of-concept request, payload or command. It records a high severity. No CVSS vector, weakness category or bounty amount is stated. The report is drawn from the GitHub Advisory Database entry GHSA-9r6g-266r-89x4.
Root cause
The root cause is a missing integrity check on a file that is then executed. The wrapper classes treat the JAR path as trusted input and pass it straight to process execution. The java() helper builds a command line and hands it to subprocess.Popen(), so the JAR is run as code rather than parsed as data.
The comparison with CVE-2026-0848 makes the pattern clear: the project already knew the correct control (SHA256 verification of the JAR) and applied it to one class, but the fix was not propagated to the sibling classes that share the same execution path. The fix was applied to one class but not to the sibling classes that share the same execution path.
Impact
Where an application lets an attacker influence the JAR path passed to one of these classes, the attacker can cause an arbitrary JAR to be executed by the process running NLTK. The JAR is launched as a Java process by the host application. The report describes this as arbitrary code execution when loading untrusted JAR files. It does not describe a specific deployment, so the practical reach depends on whether the path is attacker-controlled in a given application.
How this kind of bug works
The bug class is untrusted file execution: a library accepts a filesystem path to an executable artefact (here a JAR) and runs it without confirming that the file is the one it expects. The danger is not in reading the file but in executing it. A JAR is a container for compiled Java classes, and running it via the Java launcher executes its code, so any integrity gap around the path becomes a code execution gap.
The usual reason it happens is that the path is treated as configuration supplied by a trusted developer, while in practice it can come from user input, environment variables, configuration files or plugin directories. Defences are straightforward in principle: verify the artefact against a known hash or signature before execution, pin the expected location, and refuse to run anything that does not match. Sandboxing the spawned process and running it with least privilege limits the damage when verification is missing.
How to test for it
Look for library or application features that take a path to an executable artefact and run it: JAR wrappers, model loaders, plugin systems, external tool integrations. Trace where that path comes from. If it can be influenced by a request parameter, a stored setting, an uploaded file or an environment value, the sink is worth testing.
A concrete method:
- Identify the parameter or setting that supplies the artefact path.
- Point it at a benign artefact you control that produces an observable effect, such as writing a marker file or making an outbound request to a listener you own.
- Trigger the feature and watch for the effect.
- If the effect appears, you have execution; confirm it is your artefact and not a cached or default one.
A positive result is the observable side effect from your artefact appearing when the feature runs. Common false positives are paths that are validated elsewhere before reaching the sink, artefacts that are only parsed and never executed, and effects that come from a default artefact rather than the one you supplied. Check whether a hash or signature check exists on the path and whether it can be bypassed by supplying a different file at the same location.
How it is fixed
The fix used for CVE-2026-0848 was SHA256 verification of the JAR before execution. In this codebase the established control is SHA256 verification of the JAR, as applied to StanfordSegmenter for CVE-2026-0848. The report notes the fix was not applied to these additional classes. Where possible, pin the expected path and reject anything outside it, and avoid accepting user-controllable paths at all. Running the spawned process with least privilege and in a sandbox reduces impact if a check is missed.
Hunting notes
This bug class tends to hide in integration layers: wrappers around external tools, model and artefact loaders, plugin and extension systems, and anything that shells out to an interpreter or runtime. Recon signals include libraries that bundle or download binary artefacts, configuration options that name a file path, and code that calls process-spawning functions with a path variable. When a project has fixed one instance of this pattern, check the sibling classes and call sites that share the same helper; incomplete fixes are common. To make a report land, show the full path from attacker-controlled input to execution, demonstrate the effect with a harmless artefact, and reference the existing fix and advisory pattern so the maintainers can see the gap quickly.
What happened, in plain words
NLTK is a Python library for natural language processing. NLTK has Stanford interface classes that wrap the Stanford NLP tools, which are shipped as JAR files. A JAR is a package of compiled Java code, a bit like a zip file that the computer can run.
To use those Stanford tools, NLTK has small helper classes, one per tool. The report names five of them: StanfordPOSTagger, StanfordNERTagger, StanfordParser, StanfordDependencyParser and StanfordNeuralDependencyParser. Each one is given the location of a JAR file on disk and then starts it.
The problem is that these five classes do not check what the JAR actually is. They take the path they are given, pass it to an internal java() function, and that function starts the file with subprocess.Popen(). subprocess.Popen() is the standard Python way to launch another program on the machine. So whatever file sits at that path is run as code, with no check that it is the genuine Stanford tool.
The report says this is the same flaw as CVE-2026-0848. A CVE is a public identifier for a known security bug. That earlier issue affected a sixth class, StanfordSegmenter, and it was fixed by adding SHA256 verification: before running the JAR, the code computes a fingerprint of the file and compares it with the expected one. If the file has been swapped for something else, the fingerprints differ and the file is not run. That fix was applied to StanfordSegmenter only. The five classes above were left as they were, so they can still be made to run any JAR whose path reaches them.
The report gives no example request, payload or command. It records a high severity. No CVSS score, weakness category or bounty amount is stated. It comes from the GitHub Advisory Database entry GHSA-9r6g-266r-89x4.
Why it happens
The cause is a missing integrity check on a file that is then executed. The wrapper classes treat the JAR path as something trustworthy and pass it straight to the code that starts a process. The java() helper builds a command line and hands it to subprocess.Popen(), so the JAR is run as a program rather than read as data.
The comparison with CVE-2026-0848 shows the pattern. The project already had the right control, SHA256 verification, and used it in one class, but did not carry it over to the sibling classes that start a JAR in the same way. Security people call this an incomplete fix: the dangerous spot is closed in one place and left open in others.
What an attacker could do
If an application lets an attacker influence the JAR path passed to one of these classes, the attacker can get their own JAR executed by the process running NLTK. That JAR runs as a Java process started by the host application. The report describes this as arbitrary code execution when loading untrusted JAR files. It does not describe a specific deployment, so how far this reaches in practice depends on whether the path is attacker-controlled in a given application.
In general, how this kind of bug works
The bug class is untrusted file execution: a library accepts a path to an executable file and runs it without confirming the file is the one it expects. The danger is not in reading the file but in running it. A JAR holds compiled Java code, and starting it with the Java launcher executes that code, so any gap in checking the file becomes a gap that allows code to run.
It usually happens because the path is treated as a setting a trusted developer supplies, while in reality it can come from user input, environment variables, configuration files or plugin folders. The defences are simple in principle: check the file against a known fingerprint or signature before running it, fix the expected location, and refuse anything that does not match. Running the started process in a sandbox and with the least privilege it needs limits the damage when a check is missing.
In general, how to test for it
Look for features that take a path to an executable file and run it: JAR wrappers, model loaders, plugin systems, integrations with external tools. Trace where that path comes from. If a request parameter, a stored setting, an uploaded file or an environment value can influence it, the spot is worth testing.
A concrete method:
- Find the parameter or setting that supplies the file path.
- Point it at a harmless file you control that produces a visible effect, such as writing a marker file or making an outbound request to a listener you own.
- Trigger the feature and watch for the effect.
- If the effect appears, you have execution; confirm it is your file and not a cached or default one.
A positive result is the visible side effect from your file appearing when the feature runs. Common false positives are paths that are checked elsewhere before reaching the dangerous call, files that are only read and never run, and effects that come from a default file rather than the one you supplied. Check whether a fingerprint or signature check exists on the path and whether it can be bypassed by putting a different file at the same location.
In general, how it is fixed
The fix used for CVE-2026-0848 was SHA256 verification of the JAR before execution. In this codebase the established control is SHA256 verification of the JAR, as applied to StanfordSegmenter for CVE-2026-0848. The report notes the fix was not applied to these additional classes. Where possible, fix the expected path and reject anything outside it, and avoid accepting user-controlled paths at all. Running the started process with least privilege and in a sandbox reduces the impact if a check is missed.
In general, where to look
This bug class tends to hide in integration layers: wrappers around external tools, model and file loaders, plugin and extension systems, and anything that calls out to an interpreter or runtime. Signals to watch for include libraries that bundle or download binary files, configuration options that name a file path, and code that calls process-starting functions with a path variable. When a project has fixed one instance of this pattern, check the sibling classes and call sites that share the same helper; incomplete fixes are common. To make a report land, show the full path from attacker-controlled input to execution, demonstrate the effect with a harmless file, and reference the existing fix and advisory pattern so the maintainers can see the gap quickly.
Glossary
- NLTK: a Python library for natural language processing, used to work with text.
- JAR: a package file containing compiled Java code that the computer can run.
- Java: a programming language and runtime; JAR files are run by the Java launcher.
- Class: in Python, a reusable piece of code that bundles data and behaviour; here, one helper per Stanford tool.
- Wrapper: code that sits around another tool and calls it on your behalf.
subprocess.Popen(): the standard Python function for starting another program on the machine.- Path: the location of a file on disk, such as a folder and file name.
- Integrity verification: checking that a file is exactly the one expected and has not been swapped or altered.
- SHA256: a hashing algorithm that turns a file into a short fingerprint; two different files give different fingerprints.
- CVE: a public identifier for a known security vulnerability.
- CVE-2026-0848: the earlier, related issue affecting
StanfordSegmenter, fixed by adding SHA256 verification. - Arbitrary code execution: getting a program to run code of the attacker's choosing.
- Untrusted file execution: running a file without confirming it is the expected, trusted one.
- Incomplete fix: a fix applied in one place but not to other places with the same flaw.
- CVSS: a scoring system for rating the severity of vulnerabilities.
- Least privilege: giving a process only the permissions it actually needs.
- Sandbox: an isolated environment that limits what a running program can do.
- False positive: a test result that looks like a problem but is not one.