NLTK can run untrusted Java code through command arguments

CriticalSE Fix-First Score 51/100CVE-2026-128138SE-AIV-01495Remote code executionAI softwareMade public 20 Nov 2026

Download as PDF

What this means

An attacker who can control what your code passes to NLTK's Java functions can run any program on your server with the same permissions as your application. This can lead to stolen data, modified files, or a complete takeover of the machine.

SecurityElites Manager Brief: the decision in one minute

NLTK 3.10.3 tried to fix a Java code-execution flaw but left a loophole open. Version 3.10.4 closes it. Upgrade now to prevent attackers from running code on your server.

SecurityElites Fix-First Score51 of 100
Our own ranking of what to fix first. Real attacks count most, then the chance of attack, then severity.
SecurityElites fix windowWithin 7 days
Critical severity. This is our suggestion from common practice; your own policy comes first.
Who should own the fixPython and AI platform team.
Likely effortAbout 10 minutes: a version bump and a restart, unless your code passes user input directly to NLTK's Java functions, in which case you may need to add input validation.

Questions to ask your team or supplier

  • Does any of our code pass user input, config files, or external data directly to NLTK's Java functions? If yes, have we added input validation?
  • Which of our services and deployments (dev, test, staging, production, CI/CD) are running NLTK 3.10.3, and have we upgraded all of them?

Message you can forward to the owning team

Security notice: NLTK can run untrusted Java code through command arguments (CVE-2026-128138)

Severity: Critical
SecurityElites Fix-First Score: 51 of 100
SecurityElites fix window: Within 7 days
Action: upgrade to nltk 3.10.4 or later.
What we need from you: confirm whether we run this software, who owns it, and the date it will be fixed.
Full guide: https://securityelites.com/ai-vulnerabilities/cve-2026-128138-nltk-can-run-untrusted-java-code-through-command-arguments/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01495

What is at stake in your AI setup

  • NLP model files for Stanford tools: could be replaced with malicious versions or deleted.
  • Text data processed by NLTK: could be exfiltrated or modified during processing.
  • API keys and credentials in environment: an attacker could read them from the Java process context.
  • Connected tools and databases: an attacker could query or modify data that your NLTK-based service has access to.

Map where your company uses AI

Who is exposed

  • Teams running NLTK 3.10.3 with any code that calls nltk.internals.java() or StanfordSegmenter with values from outside your code (user input, files, APIs).
  • Applications using NLTK 3.10.3 to process text with Stanford tools and accepting configuration from users or external sources.
  • Docker containers or cloud deployments with NLTK 3.10.3 installed, if the application loads tool paths from environment or config files.

Upgrades you need

SoftwareAffected versionsMove to
nltk
PyPI
3.10.3 up to, but not including, 3.10.43.10.4 or later

Am I affected?

Enter the version you run. Nothing you type is stored.

SecurityElites Developer Brief: the technical picture

Is it being attackedWorking attack code is public, so expect attacks to follow
Where the attacker must beAnywhere that can reach it over a network, including the internet if it is exposed
Account neededNone. No login is needed
Does a person have to do somethingNo. It works without anyone clicking or opening anything
How hard it is to doEasy. It works reliably once the attacker can reach it
Risk of: data being readHigh
Risk of: data or settings being changedHigh
Risk of: the service being taken downHigh
Can attackers automate it at scaleYes, according to CISA
How much control an attacker gainsTotal control of the affected software, according to CISA

Read from the official severity rating: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Kind of coding mistake

  • CWE-77: commands can be injected
  • CWE-88

If you cannot upgrade today

  • Until you can upgrade: do not pass any external input (user data, config files, environment variables) to nltk.internals.java() or StanfordSegmenter's java_class parameter. If you must, validate that the value matches a whitelist of allowed
  • Disable Stanford tool functionality in your application if it is not essential, or use an alternative NLP library that does not invoke external Java.

Signs it may already have been used against you

  • Java process logs: look for `java` commands with `-jar`, `@`, or file paths in your application logs, especially if they don't match your known Stanford tool paths.
  • Process monitoring: unexpected child processes spawned by your Python application with names like `java`, `wget`, or `curl`.
  • Network logs: unusual outbound connections from your application server, especially to external hosts downloading JARs or tools.
  • File system: new or modified files in `/tmp`, the application's working directory, or Java/NLTK tool directories during the time 3.10.3 was running.

SecurityElites Fix Guide: step by step

  1. Find where NLTK is installedList all Python environments where your application runs: on your laptop, in Docker, in cloud services, in CI/CD, and everywhere else. Check which ones have nltk installed.
  2. Check the current versionIn each environment, run `python -c "import nltk; print(nltk.__version__)"`. If it shows 3.10.3 or earlier, the system needs an upgrade.
  3. Review code for risky patternsSearch your codebase for calls to `nltk.internals.java()` and `StanfordSegmenter()`. For each, check whether the `cmd` argument or `java_class` parameter comes from user input, config files, environment variables, or any external source. If yes, that code path is vulnerable.
  4. Back up your environmentIf you use containers, snapshot the current image. If you use a virtual environment, export the current dependencies list with `pip freeze > requirements.txt`.
  5. Upgrade NLTK to version 3.10.4Use `pip install --upgrade nltk==3.10.4` in each affected Python environment (locally, in containers, in deployment systems, in CI/CD). Restart any running services or redeployments.
  6. Verify the fix is in placeRun `python -c "import nltk; print(nltk.__version__)"` again in each environment and confirm the version is 3.10.4 or later.
  7. Check for signs of past exploitationReview logs for unexpected Java process launches, failed Java command errors with JAR or @argfile references, or processes started from your application around the time you deployed 3.10.3. If found, see the 'Detect' section.
  8. Test your applicationRun your application's standard tests and exercise any code paths that use NLTK's Java functions. Confirm everything still works as expected.

How to confirm it is fixed: Run `python -c "import nltk; print(nltk.__version__)"` and confirm the version is 3.10.4 or later in all environments where your application runs.

SecurityElites Quick Fixes: copy and paste

Upgrade nltk with pipupgrade

pip install --upgrade "nltk>=3.10.4"
pip show nltk | grep Version

Pin it in requirements.txtupgrade

nltk>=3.10.4

Check installed versionfor this issue

python -c "import nltk; print(nltk.__version__)"

Search for risky Java function calls in sourcefor this issue

grep -r "nltk\.internals\.java\|StanfordSegmenter" --include="*.py" .

Run the service in a locked-down containergeneral hardening

docker run --read-only --cap-drop ALL \
  --security-opt no-new-privileges --user 1000:1000 \
  -p 127.0.0.1:8080:8080 YOUR_IMAGE

Test in a non-production environment first. General hardening examples use placeholder names and ports; change them to match your setup.

Let your AI coding assistant do the upgrade

Paste this into the coding assistant you already use, inside the project. It checks first and asks before it changes anything.

Instruction for your coding assistant

You are helping me fix a security vulnerability (CVE-2026-128138) in this project.\n\n1. Search the whole repository, including lock files, container files and CI configuration, for these packages and list every place they are pinned or installed:\n   - nltk (PyPI): must be 3.10.4 or later
2. Tell me which version we use now and whether it is affected. Stop and ask me before changing anything.
3. After I agree, raise each one to the safe version, update the lock files, and keep every other dependency as it is.
4. Run the tests and tell me what failed.
5. Give me a short summary of the files you changed that I can put in the pull request.

SecurityElites Incident Drill: could your team handle this?

Four questions to ask in your next team meeting. If any has no clear answer, that is the gap to close.

What is the minimum safe version of NLTK?A good answer: NLTK 3.10.4 or later contains the security fix for this vulnerability.
Which NLTK functions are affected by this vulnerability?A good answer: The public nltk.internals.java() helper function and the StanfordSegmenter class, if the cmd or java_class parameters come from outside your code.
What happens if an attacker exploits this?A good answer: They can run any Java code or program on your server with the permissions of your application, potentially stealing data or taking over the system.
What should we do if we find signs of exploitation in our logs?A good answer: Treat it as a security incident: isolate the affected system, preserve logs, begin incident response, and check for data theft or system compromise.

Run a full timed drill with your team

Ticket for your backlog

Paste into Jira, GitHub Issues or any tracker that reads Markdown.

Ready-made ticket

## NLTK can run untrusted Java code through command arguments (CVE-2026-128138)

**Severity:** Critical  |  **SE Fix-First Score:** 51/100  |  **Fix window:** Within 7 days
**Record:** SE-AIV-01495 https://securityelites.com/ai-vulnerabilities/cve-2026-128138-nltk-can-run-untrusted-java-code-through-command-arguments/

### Why this matters
An attacker who can control what your code passes to NLTK's Java functions can run any program on your server with the same permissions as your application. This can lead to stolen data, modified files, or a complete takeover of the machine.

### What to do
1. Find where NLTK is installed
2. Check the current version
3. Review code for risky patterns
4. Back up your environment
5. Upgrade NLTK to version 3.10.4
6. Verify the fix is in place
7. Check for signs of past exploitation
8. Test your application

Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-128138-nltk-can-run-untrusted-java-code-through-command-arguments/

### Done when
- [ ] nltk is at 3.10.4 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Run `python -c "import nltk; print(nltk.__version__)"` and confirm the version is 3.10.4 or later in all environments where your application runs.
- [ ] Logs were checked for signs of earlier use

SecurityElites Fix Tracker

Record who owns this fix, the date it is due and when it is done, and see everything still open in one list. Free with a SecurityElites account.

Sign in to track this fix

Change history

  • 19 Nov 2026: Made public
  • 1 Dec 2026: Published
  • 3 Dec 2026: Guide updated

Official record

## SummaryNLTK 3.10.3 contains security hardening intended to close JVM argument-injection and untrusted JAR/classpath execution paths in `nltk.internals.java()`, including the issue published as GHSA-m4rf-3fr8-xwx3.The patched `options` channel correctly rejects Java argument-file references such as `@/path/to/args` and launcher modes such as `-jar`. However, an additional argument channel remains: the caller-provided `cmd` sequence is appended to the Java command after the validated option and classpath channels, without enforcing that its first item is a Java main-class name.I am reporting this as an additional post-fix bypass / incomplete-fix path affecting the 3.10.3 remediation, rather than as an unrelated vulnerability family.As a result, the same launcher token that is rejected through `options` can be supplied as the first `cmd` item. I confirmed two reachable forms against the official `nltk-3.10.3-py3-none-any.whl`:1. direct use of the public `nltk.internals.java()` helper with `cmd=["-jar", ...]`; and 2. the higher-level `StanfordSegmenter`, whose public `java_class` constructor argument becomes the first `cmd` item and accepts an `@argfile` launcher token.Both paths execute an external researcher-controlled JAR without setting `NLTK_ALLOW_UNSAFE_JARS`, `NLTK_ALLOW_UNSAFE_CLASSPATH`, or using `trusted_raw_options`. The original explicit outside-classpath route is blocked in 3.10.3, while the alternate command channel executes the JAR 3/3 times.## Affected artifact```text Package: nltk Confirmed affected version: 3.10.3 Wheel: nltk-3.10.3-py3-none-any.whl SHA-256: ff9598a8e20518ee0d557745890cc4435b9578489e2dcbc69c4f81fa060caf7c ```Baseline artifact:```text Version: 3.10.2 Wheel: nltk-3.10.2-py3-none-any.whl SHA-256: 2c7ccacb765c5e26b0cb60fb1b57080af522c6924d12a714a243305ba3637412 ```## Relationship to the 3.10.3 security fixesThe existing 3.10.3 hardening validates the dedicated per-call `options` list before it reaches `subprocess.Popen`. In particular, the exact `@argfile` token used in this report is rejected through `options` with a `ValueError` that references CVE-2026-12841 and CWE-88.The command is subsequently assembled in this order:```python final_cmd.extend(validated_options) if classpath_arg is not None: final_cmd.extend(["-cp", classpath_arg]) final_cmd.extend(cmd_list) ````cmd_list` is copied from the public `cmd` argument but its first token is not checked to ensure that it is an ordinary Java main class. Java therefore interprets leading `-jar`, `@argfile`, module-mode, or classpath-mode tokens as launcher control arguments rather than application arguments.This is an alternate argument channel around the same JVM argument/JAR execution boundary protected by the 3.10.3 changes.## Confirmed API paths### Direct public helper```python nltk.internals.java( ["-jar", "/outside/trusted/roots/controlled.jar"], classpath=None, stdout="pipe", stderr="pipe", ) ```The external JAR executed in all three subject runs.### Higher-level `StanfordSegmenter` path`StanfordSegmenter` exposes a public `java_class` constructor argument, stores it, and later places it at the beginning of the `cmd` sequence passed to `nltk.internals.java()`.A controlled argument file containing a `-jar` launcher invocation was supplied as:```python StanfordSegmenter( path_to_jar=trusted_segmenter_jar, java_class="@/path/to/controlled-launcher.args", path_to_model="dummy-model", java_options=[], ) ```The trusted segmenter JAR passed the wrapper's checksum and classpath checks. The `@argfile` then switched the Java launcher to the external JAR, which executed in all three runs.The deprecated wrapper subsequently raised an unrelated post-launch `AttributeError` while processing its output. The external marker had already been written by the child JVM before that exception.## Proof matrix```text R1 NLTK 3.10.2 + explicit external classpath -> control

Weakness type: CWE-77, CWE-88

Use this record in your own tools

Get this record as JSON

curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-128138

For scanners and pipelines: OSV format · CycloneDX format · API guide · Email alerts · Fix tracker

The plain-language sections were written with AI from the official record, and the upgrade versions come directly from the official data. Last updated 4 Dec 2026. Read the vendor advisory before changing a production system.