Skip to main content

CVE-2026-128138 — Vulnerability in nltk — CVE Details

CRITICAL

NLTK incomplete fix: additional JVM/JAR sandbox bypass through unvalidated launcher tokens in java() command arguments

Published November 19, 2026Updated November 20, 2026Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.73%). Schedule for your next planned update.

Does your project use an affected nltk version?

Paste your requirements.txt to check it for CVE-2026-128138 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my requirements.txt

Summary

Summary

NLTK 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

Package: nltk
Confirmed affected version: 3.10.3
Wheel: nltk-3.10.3-py3-none-any.whl
SHA-256: ff9598a8e20518ee0d557745890cc4435b9578489e2dcbc69c4f81fa060caf7c

Baseline artifact:

Version: 3.10.2
Wheel: nltk-3.10.2-py3-none-any.whl
SHA-256: 2c7ccacb765c5e26b0cb60fb1b57080af522c6924d12a714a243305ba3637412

Relationship to the 3.10.3 security fixes

The 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:

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

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:

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

R1  NLTK 3.10.2 + explicit external classpath
    -> controlled Java bytecode executed

R2  NLTK 3.10.3 + same explicit external classpath
    -> UntrustedJarError; no marker

R3A NLTK 3.10.3 + direct cmd=["-jar", external_jar]
    -> controlled external JAR executed, 3/3

R3B NLTK 3.10.3 + StanfordSegmenter(java_class="@argfile")
    -> controlled external JAR executed, 3/3

R4  NLTK 3.10.3 + ordinary main class in trusted classpath
    -> legitimate execution preserved

A direct channel comparison also confirmed:

options=["@argfile"]       -> BLOCKED
cmd/java_class="@argfile"  -> EXTERNAL JAR EXECUTED

Machine-readable proof results and a portable reproducer are attached.

Preconditions

Practical exploitability depends on an embedding application exposing attacker influence over one of these public argument paths:

  • the leading item of nltk.internals.java(cmd=...); or
  • StanfordSegmenter(java_class=...) or an equivalent wrapper-controlled command token.

The attacker must also be able to reference an argument file or JAR readable by the NLTK process. The Java child process executes with the privileges of that process.

This is not a claim that importing NLTK alone is remotely exploitable. The confirmed issue is that the default protected execution boundary can be bypassed when these argument channels are exposed to untrusted input.

Impact

Successful exploitation allows execution of attacker-selected Java bytecode with the privileges of the process using NLTK.

Suggested classifications:

  • CWE-88: Improper Neutralization of Argument Delimiters in a Command
  • CWE-94: Improper Control of Generation of Code

Suggested severity: Moderate, subject to maintainer assessment of realistic argument reachability in embedding applications.

Reproduction

The complete reproducer, machine-readable proof results, and proposed remediation are included in the attached evidence package.

nltk-3103-candidate-a-maintainer-evidence.zip

The included reproducer/reproduce_cmd_channel_bypass.py creates only temporary researcher-controlled Java source, JAR, argument-file, and marker artifacts. It performs no network access.

Requirements:

  • Python 3.10 or newer
  • nltk==3.10.3
  • a JDK providing java, javac, and jar

Run:

python reproducer/reproduce_cmd_channel_bypass.py

A confirmed run exits with status 0 and reports that:

  • the options channel blocks @argfile;
  • the direct cmd channel executes the external JAR 3/3;
  • the higher-level StanfordSegmenter.java_class channel executes it 3/3; and
  • legitimate trusted main-class execution remains functional.

Recommended remediation

Enforce that the first ordinary cmd item is a Java main-class token. Reject Java launcher switches and @argfile references in this channel by default, before constructing or executing the subprocess command.

For example:

cmd_list = list(cmd)
if not cmd_list:
    raise ValueError("cmd must contain a Java main class")
first = cmd_list[0]
if not isinstance(first, str) or not first or first.startswith(("-", "@")):
    raise ValueError("cmd must begin with a Java main class")

If raw Java launcher modes are intentionally supported, they should require a clearly named explicit trusted escape hatch rather than sharing the normal main-class channel.

The attachment includes a proposed source patch and focused regression tests. Local verification against code derived from the official 3.10.3 wheel showed:

direct -jar command channel       BLOCKED
StanfordSegmenter @argfile path   BLOCKED
external marker creation          BLOCKED
legitimate trusted main class     PRESERVED

Relationship to existing advisory / duplicate note

The public advisory GHSA-m4rf-3fr8-xwx3 describes the per-call options validation gap fixed in 3.10.3. This report is intentionally scoped as an additional bypass of that remediation through the distinct cmd/java_class argument channel.

I did not locate a public advisory, issue, or pull request describing this leading-cmd launcher-token path. I cannot determine whether an equivalent private report already exists, so please deduplicate this report against any private reports or unpublished follow-up work.

Please keep this report and attachment private while assessing and preparing any fix. I am available to test a candidate patch and adapt the regression tests to the project's preferred style.

Fix status (2026-09-28)

Status: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).

PR: #3771 "Reject Java launcher switches and @argfiles in the java() cmd argument (CWE-88)", merged 2026-08-20, merge commit 45a08fded on develop. Fix commit: b36212795 (java() raises ValueError when the first cmd token is a launcher switch or an @argfile, and when any cmd token is an @argfile; StanfordSegmenter passes its java_class as that first token, nltk/tokenize/stanford_segmenter.py line 432, so both reported paths hit the same check).

Probe: none. Reproduction on develop 2fa3f48fe with the process spawn intercepted: cmd=["-jar", jar], cmd=["@argfile"] and cmd=["Main", "@argfile"] each raise ValueError (CWE-88) before any spawn.

Release: none yet; no release tag contains b36212795.

Advisory Timeline

  • First published November 19, 2026 (6 days ago).
  • Last revised November 20, 2026 — 0 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

pip
Update nltk to 3.10.4 or later
pip install "nltk>=3.10.4"

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: PyPI (1).

PackageFixed In
nltk PyPI · Affected: 3.10.33.10.4

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Frequently Asked Questions

What is CVE-2026-128138?
NLTK incomplete fix: additional JVM/JAR sandbox bypass through unvalidated launcher tokens in java() command arguments. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.8/10).
How do I check if my project is affected by CVE-2026-128138?
CVE-2026-128138 affects nltk. It has a 0.7% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-128138 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
9.8

Maximum impact if exploited, often with little effort or access required.

EPSS Score (30-day exploit probability)
0.73%
EPSS percentile: 50

This is an above-median EPSS score — 50% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.

Also Known As

GHSA-x8q7-6c7m-52gw

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my requirements.txt