CVE-2026-128138
NLTK 3.10.3 permits arbitrary Java code execution via JVM token handling.
- CVSS 9.8
- CWE-77
- Input Validation and Sanitization
- Local
NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. From 3.10.3 until 3.10.4, the NLTK 3.10.3 JVM hardening validates Java launcher tokens in the options channel but appends the caller-controlled cmd sequence without requiring its first token to be a main class. Supplying -jar or an @argfile through nltk.internals.java or StanfordSegmenter.java_class can therefore execute attacker-selected Java bytecode without the unsafe-JAR opt-in. This issue is fixed in version 3.10.4.
- CWE
- CWE-77
- CVSS base score
- 9.8
- Published
- 2026-11-19
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- NLTK
- Fixed by upgrading
- Yes
Solution
Upgrade NLTK to version 3.10.4 (or later).
Vulnerable code sample
import os
import subprocess
from nltk.internals import java
def run_stanford_segmenter(java_opts, user_cmd):
"""
Executes the Stanford Segmenter via NLTK's java helper.
java_opts: list of JVM options (e.g., ['-Xmx2g'])
user_cmd: list of tokens supplied by the caller (e.g., ['-jar', 'malicious.jar'])
"""
# VULNERABLE: appends caller-controlled command without validating its first token
cmd = java(java_opts + user_cmd)
subprocess.run(cmd, check=True)Patched code sample
import os
import subprocess
from nltk.internals import java
def run_stanford_segmenter(java_opts, user_cmd):
"""
Executes the Stanford Segmenter via NLTK's java helper.
java_opts: list of JVM options (e.g., ['-Xmx2g'])
user_cmd: list of tokens supplied by the caller (e.g., ['-jar', 'stanford-segmenter.jar'])
"""
# FIX: ensure the first token of user_cmd is a safe launcher token
safe_tokens = {'-jar', '-cp', '-classpath'}
if not user_cmd or user_cmd[0] not in safe_tokens:
raise ValueError("Invalid Java launcher token")
cmd = java(java_opts + user_cmd)
subprocess.run(cmd, check=True)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Reject Java launcher switches and @argfiles in the java() cmd argument (nltk/nltk)
nltk/internals.py · java
Cite this entry
@misc{vaitp:cve2026128138,
title = {{NLTK 3.10.3 permits arbitrary Java code execution via JVM token handling.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-128138},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-128138/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
