On this page (7 sections)
A critical flaw in the Python NLP library NLTK means the Java hardening added in version 3.10.3 can still be bypassed. If an application lets untrusted input reach the first item of the Java command, an attacker can make the JVM run a JAR of their choosing. The issue is tracked as CVE-2026-128138 and fixed in 3.10.4.
Anyone who runs NLTK 3.10.3 in a service, notebook server or data pipeline should check whether it is exposed. The details below come from a single source, the GitHub advisory, so treat the finer points as that reporter's findings.
What happened
NLTK 3.10.3 added hardening to close earlier JVM argument-injection and untrusted JAR paths in nltk.internals.java(). That release rejects Java argument-file references such as an @file token and launcher modes such as -jar when they arrive through the dedicated options list. The advisory reporter describes the new problem as an incomplete fix, not an unrelated bug family.
The gap is a second channel. The caller-supplied cmd sequence is added to the Java command after the validated options and classpath, and nothing checks that its first item is an ordinary main-class name. Java then reads a leading -jar or @argfile as a launcher instruction rather than as an application argument.
Technical details
According to the advisory, the command is built in this order: validated options, then the classpath flag and value if present, then the cmd list. Because the first cmd token is not validated, the same token that is blocked in options gets through in cmd.
The reporter confirmed two reachable forms against the official 3.10.3 wheel:
- Direct use of the public nltk.internals.java() helper with a launcher token as the first cmd item.
- The higher-level StanfordSegmenter, whose public java_class constructor argument becomes the first cmd item and accepted an @argfile token.
In both cases an external JAR controlled by the researcher ran without setting NLTK_ALLOW_UNSAFE_JARS, NLTK_ALLOW_UNSAFE_CLASSPATH or using trusted_raw_options. The reporter states the external JAR executed in all three runs of each path, while the original explicit outside-classpath route was blocked in 3.10.3 and legitimate use of an ordinary main class in a trusted classpath still worked.
The weakness class is argument injection: the program builds a command line for another program and lets untrusted text land in a position where the other program treats it as a control flag. Validating one part of the command while leaving another unchecked is a common way for such fixes to fall short.
Who is affected
Only version 3.10.3 is listed as affected, and the advisory range is 3.10.3 up to but not including 3.10.4. The reporter also notes that practical exploitability depends on an embedding application giving an attacker influence over one of these argument paths: the first item of the cmd argument to nltk.internals.java(), or StanfordSegmenter(java_class=...) or an equivalent wrapper-controlled command.
That makes realistic exposure narrow but serious. A script that hard-codes its Java class is far less likely to be reachable than a web service, notebook environment or job runner that builds these values from user input, uploaded configuration or request parameters. The research does not describe any in-the-wild attacks, and does not say whether the issue can be triggered remotely in any particular product.
How to check your exposure
This read-only command shows the installed NLTK version in the active Python environment. A result of 3.10.3 means you are in the affected range.
python -m pip show nltkThis command searches your own code for the two entry points named in the advisory, so you can see whether untrusted data could reach them. Run it from the project root.
grep -rnE "StanfordSegmenter|java_class|internals\.java|nltk\.internals import" .Also check pinned versions in requirements files, lock files and container images, since a build may install 3.10.3 even if your laptop does not.
What to do now
- Upgrade NLTK to 3.10.4 in every environment, image and lock file that uses 3.10.3.
- Rebuild and redeploy containers and virtual environments, then confirm the installed version again.
- Find code that passes user-influenced values to nltk.internals.java() or to StanfordSegmenter(java_class=...), and stop doing that.
- Where a Java class name must be configurable, allow only a fixed list of known class names and reject anything starting with a dash or @.
- Run NLTK-based services as a low-privilege user with limited filesystem and network access, so a launcher bypass has less to work with.
- Review logs and process history on affected hosts for unexpected Java launches or unfamiliar JAR files.
This command upgrades NLTK to the fixed release in the current environment. Run it in each environment that needs it, then re-run the version check above.
python -m pip install "nltk>=3.10.4"Detection and monitoring
The reporter's proof shows the child JVM can run the external code before the wrapper raises an unrelated error, so an application error log alone may not reveal an attempt. Look instead at the host: Java processes started by your Python workers, JAR files in unexpected locations, and argument files written by the application's user.
Add NLTK to your dependency scanning so version pins in 3.10.3 are flagged automatically, and subscribe to the project's security advisories. If NLTK runs behind a public web application, a web application firewall can add a layer against malformed input, though it is no substitute for patching; see what a WAF is. For wider guidance on checking a compromised host, read website hacked: what to do.
Timeline and references
- Nov 15, 2026: advisory published in the nltk/nltk repository.
- Nov 19, 2026: advisory updated and the CVE record published, with the fix in 3.10.4.
Fix references from the CVE record: the commit, pull request 3771 and the v3.10.4 release. The earlier 3.10.3 hardening that this issue bypasses is related to a separate advisory the reporter cites, GHSA-m4rf-3fr8-xwx3. Only one independent publisher covers this story so far, so details may be refined as more analysis appears.
Sources
This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.
