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

Critical CVSS 9.8

OSV id
GHSA-x8q7-6c7m-52gw
Also known as
CVE-2026-128138
Published
Last modified

Affected packages

PackageAffected versionsFixed in
nltk
PyPI
>= 3.10.3, < 3.10.4 3.10.4

How to fix it

Upgrade nltk to 3.10.4 or later.

# in requirements.txt: change the line to nltk==3.10.4
pip install -r requirements.txt
  • If it is an indirect dependency, upgrade the package that depends on it, or add a minimum version constraint for it (e.g. in constraints.txt, or as a dependency in pyproject.toml).
  • Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.

Not sure whether your project uses an affected version? Check your lockfile below for free.

Details

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

References

Am I affected?

Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.

or paste its content

Needed when you paste. package.json and pyproject.toml only have version ranges: use the lockfile next to them.

Only package names and versions are checked; the file itself is not kept. We use your email to send this report and nothing else unless you tick the box above. Privacy policy.

About this data

Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.