Skip to content

chore(deps): update dependency nltk to v3.10.4 [security] - #383

Merged
dreadnode-renovate-bot[bot] merged 1 commit into
mainfrom
renovate/pypi-nltk-vulnerability
Nov 1, 2026
Merged

dreadnode-renovate-bot[bot] merged 1 commit into
mainfrom
renovate/pypi-nltk-vulnerability

Conversation

@dreadnode-renovate-bot

@dreadnode-renovate-bot dreadnode-renovate-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

| Package | Change | Age | Confidence |
|

Generated Summary:

No relevant changes.

This summary was generated with ❤️ by rigging

| nltk (source) | 3.10.3 → 3.10.4 | age | confidence |


NLTK: WekaClassifier passes an unvalidated caller-controlled model path to the weka JVM, bypassing nltk.pathsec containment

GHSA-j456-xh4h-cpf2

More information

Details

Summary

WekaClassifier in NLTK passes a caller-controlled model file path to the weka Java VM without any nltk.pathsec validation. WekaClassifier.train puts the caller's model_filename verbatim into the weka argv ["-d", model_filename, ...] (weka writes the trained model there), and WekaClassifier._classify_many puts self._model into ["-l", self._model, ...] (weka reads it). Under nltk.pathsec.ENFORCE=True (the default on current HEAD), NLTK's stated invariant — established by advisory CVE-2026-81726 / GHSA-8mgp-746c-j5xp — is that caller-controlled model-artifact paths must be bounded to the allowed NLTK data roots before any native tool opens them. WekaClassifier is the one java()-based tool wrapper that skips this entirely, giving an untrusted workflow arbitrary-location file write (-d) and an arbitrary file read/parse oracle (-l), defeating pathsec containment.

This is a standalone, unfixed variant of the same class as CVE-2026-81726, on a code path the CVE-2026-81726 fix never touched. That advisory enumerates 6 functions (TransitionParser.train, TransitionParser.parse, AveragedPerceptron.save, AveragedPerceptron.load, PerceptronTagger.save_to_json, save_maxent_params) — WekaClassifier is not among them, and weka.py contains no validate_tool_path/validate_model_resource at all.

Root Cause

WekaClassifier.train(cls, model_filename, ...) builds cmd = [javaclass, "-d", model_filename, "-t", train_filename] (nltk/classify/weka.py:256) and WekaClassifier._classify_many builds [..., "-l", self._model, "-T", <staged>, ...] (weka.py:131-133); self._model is stored unvalidated in __init__ (weka.py:108-110). Only the internally-generated train.arff/test.arff are staged via make_staging_dir; the model path is passed as-is. nltk.internals.java() (internals.py:388-431) validates the classpath (_verify_jar_sandbox), the JVM launcher options (_validate_java_options, the CVE-2026-12841 fix), the main-class token cmd[0], and rejects @argfile tokens in any position — but it explicitly permits program arguments starting with - and never inspects the interior of a program-arg path value. So -d <path> / -l <path> flow unchecked to subprocess.Popen(final_cmd, shell=False) and the weka JVM performs an unbounded native open/write on the caller-chosen path.

Sibling wrappers prove the intended pattern: CRFTagger.train/set_model_file call validate_tool_path (crf.py:134,300); MaltParser.generate_malt_command validates -i/-o via validate_tool_path (malt.py:340,344), its model via validate_model_resource (malt.py:326) and working_dir via validate_path (malt.py:206). weka.py already uses pathsec elsewhere (validate_path for WEKAHOME, pathsec_open for ARFF writes) but never for the model path.

Impact

Under pathsec.ENFORCE=True (default on HEAD), an untrusted workflow that chooses the weka model save/load path obtains:

  • Arbitrary-location file write via -d — overwrite or create a file at an attacker-chosen absolute or ..-traversal path outside the allowed NLTK data roots (content constrained to weka's serialized-model format; the target choice is the integrity impact). This corrupts/clobbers arbitrary chosen files.
  • Arbitrary file read/parse oracle via -l — weka loads an out-of-root path as a model, yielding an existence/parse differential (file content is not echoed back → confidentiality impact is limited).

This defeats the pathsec containment advisory CVE-2026-81726 promises, at the same privilege level / threat model that advisory was accepted under.

Proof of Concept
import nltk.pathsec as ps; ps.ENFORCE = True
from nltk.classify.weka import WekaClassifier

##### write-side: model written OUTSIDE any allowed NLTK data root (refused for CRFTagger, allowed here)
WekaClassifier.train("/tmp/outside_sandbox/evil.model",
                     [({"a": 1}, "pos"), ({"a": 0}, "neg")])

##### read-side: -l opens an arbitrary path
clf = WekaClassifier(fmt, "/home/victim/secret.model")
clf.classify_many([{"a": 1}])

The argv construction — the vulnerable step — is confirmed without weka installed (see Bypass Evidence); a configured weka.jar is needed only to observe the JVM's actual file I/O.

Attack Chain
  1. Entry. Action: an app running with pathsec.ENFORCE=True lets an untrusted workflow choose the weka model path and calls WekaClassifier.train("../../../home/victim/x", featuresets) (write) or WekaClassifier(fmt, "/home/victim/secret.model").classify_many(...) (read). Guard: none — plain classmethod/constructor parameter (weka.py:230,108-110). Bypass proof: grep shows weka.py uses no validate_tool_path/validate_model_resource/validate_tool_dir (NONE).
  2. Command build. Action: the path is placed into cmd = [javaclass, "-d", model_filename, "-t", train_filename] (weka.py:256) / ["-l", self._model, ...]. Guard: only the internally-generated train.arff is staged via make_staging_dir; the model path is passed as-is. Bypass proof: runtime capture yielded ['weka.classifiers.bayes.NaiveBayes', '-d', '/tmp/outside_sandbox_weka.model', '-t', '<staged>/train.arff'] — the raw out-of-root path is cmd[2].
  3. java() sink. Action: java(cmd, classpath=_weka_classpath, ...) → subprocess.Popen(final_cmd) (internals.py:431). Guard: java() validates classpath, JVM options, cmd[0], and rejects @argfile tokens. Bypass proof: none of these inspect the -d/-l program-arg value; internals.py explicitly documents that program args after the main class may start with -, and the path is neither cmd[0] nor an @-token, so every java() gate passes. Negative control: the same path through validate_tool_path(..., for_write=True, must_exist=False) raises PermissionError.
  4. Impact. Action: the weka JVM opens the path outside the allowed roots → arbitrary-location write (-d) / parse-existence oracle (-l). Guard: pathsec is never consulted (no validate_tool_path, no pathsec_open). Bypass proof: the directly-analogous sibling CRFTagger.train calls validate_tool_path(model_file, must_exist=False) (crf.py:300); weka does not, and commit ee6d6138 hardened weka's other sinks (scratch files, WEKAHOME jar) while leaving the model path unvalidated.
Bypass Evidence
  • Negative control (guard is real): validate_tool_path("/tmp/outside_sandbox_weka.model", for_write=True, must_exist=False) → PermissionError; validate_tool_path("../../../home/victim/.ssh/authorized_keys", ...) → PermissionError.
  • Sink reached unvalidated (guard absent): captured write-side argv ['weka.classifiers.bayes.NaiveBayes', '-d', '/tmp/outside_sandbox_weka.model', '-t', '<staged>/train.arff'] and read-side [..., '-l', '/home/victim/secret.model', '-T', '<staged>/test.arff', '-p', '0'].
  • Version: git show v3.10.3:nltk/classify/weka.py contains both the -d model-path build (line 235) and the -l read, and NO validate_tool_path.
Affected Versions

<= 3.10.3 (present on the latest release tag v3.10.3 and on HEAD c06cd264). No published fix has ever targeted the weka -d/-l model path; commits after v3.10.3 (ee6d6138, 92aeada6, a9752559) touched weka.py for other sinks but did not add model-path validation.

Suggested Fix

Before building the -d/-l/-T command, validate the model path with pathsec, mirroring CRFTagger/MaltParser:

validate_tool_path(model_filename, context="WekaClassifier.train", for_write=True, must_exist=False)
validate_tool_path(self._model, context="WekaClassifier._classify_many")

Reported by zx (Jace) — GitHub: @​manus-use

Fix status (2026-09-28)

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

PR: #​3863 "Bound the WekaClassifier model path to the pathsec data roots", merged 2026-09-06, merge commit bc2878725 on develop. Fix commit: 6a1760629.

Probe: nltk/test/unit/security_probes/ghsa_j456_xh4h_cpf2.py, added by PR #​3905 "Add GHSA-j456 live probe; expand the GHSA-8mgp probe attack set" (commit a96715264, merged 2026-09-20, merge commit 84d987bf8); verdict on develop 2fa3f48fe: FIXED (WekaClassifier -l and -d refuse out-of-root model paths).

Release: none yet; no release tag contains 6a1760629.

Severity

  • CVSS Score: 8.6 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

nltk/nltk (nltk)

v3.10.4

Compare Source

Version 3.10.4 2026-10-20

This release routes every file path, archive, download, URL fetch and external program through one sandbox that keeps reads and writes inside the trusted data directories, refuses path traversal, symlink escapes and decompression bombs, blocks requests to internal network addresses, and runs Java and other third-party tools only from trusted absolute locations with validated options and input. Pickled models now load through a restricted unpickler, XML and JSON parsing are hardened, and regular expressions, recursion and slow algorithms in the tokenizers, parsers, stemmers and corpus readers are bounded against denial-of-service input. Text that NLTK writes to the terminal, to CSV files, to the WordNet browser and to third-party tool input is sanitized against injection.

Security changes you may notice

Every refusal below raises with a message that starts with "Security Violation" and names the check, so a failure is easy to search for (PR #​3877).

  • Data directories (nltk.pathsec, nltk.data): corpora, models and every other resource are read and written only inside the directories listed in nltk.data.path. A path that leaves a data root, a symlink that points out of one, and a NUL byte or encoded traversal in a resource name are refused. A data root, or a directory on the way to a resource, that another account can write to is skipped with a warning naming the directory and the remedy. Keep private data in a private directory and add it to nltk.data.path; /tmp is not a data root. Model save and load methods (perceptron, maxent, named-entity chunker, Weka, crf, hunpos, Stanford) accept destinations inside a data root only (PR #​3797, #​3753, #​3850, #​3761, #​3755, #​3759, #​3760, #​3763, #​3806, #​3807, #​3808, #​3809, #​3813, #​3814, #​3815, #​3848, #​3851, #​3852, #​3853, #​3863, #​3871, #​3888, #​3945, #​3961, #​3969, #​3981)
  • Downloader: downloaded package archives stay private to the installing account (0600). An install another account must read is extracted: a download made as root or outside the installing account's home extracts on its own, and nltk.download(..., extract=True) / python -m nltk.downloader --extract (or --no-extract) decide explicitly. This also unpacks the packages the index leaves zipped (wordnet, omw-1.4 ...); the extracted files are readable by every account and are found before the archive. find() names an archive it cannot read and says how to extract it instead of reporting it "not found". The downloader installs only into directories no other account can write to, treats an archive another account owns or can write to as stale and downloads it afresh, extracts only from an archive no other account could have changed since its checksum was verified, bounds the size of what it fetches, and refuses index entries and archive members that would write outside the package directory (PR #​3929, #​3804, #​3850, #​3778)
  • Pickles: nltk.data.load(..., format="pickle") reconstructs plain data only; a pickle that names any class or function is refused. Model loaders that need classes use an explicit allowlist of audited globals, so a gadget such as os.system can never be reconstructed from a model file. chat80 shelve values load the same way (PR #​3794, #​3754, #​3757, #​3802, #​3817, #​3823, #​3824)
  • XML, JSON and YAML: nltk.xmlsec refuses any document that declares an entity or references an external one (billion-laughs, external-entity and DTD attacks) and bounds the tree depth, and every corpus XML view, the downloader index, Toolbox and internals parse through it. JSON resources load with a depth and size bound; YAML (the markdown corpus front matter and nltk.data.load(..., format="yaml")) loads through a bounded safe loader. Oversized or too deeply nested input raises ValueError naming the limit (PR #​3754, #​3805, #​3828, #​3933, #​3972, #​3974)
  • Regular expressions (nltk.redos): every regular expression NLTK compiles, including one you pass to RegexpTokenizer, RegexpStemmer, RegexpParser, re_show, TokenSearcher.findall, tgrep, nltk.help tag-set lookups and the concordance and nemo GUIs, now goes through nltk.redos on the regex engine. A pattern longer than 100,000 characters, nested more than 100 deep, with more than 1,000 capturing groups or an excessive repetition product is refused with nltk.redos.error, a subclass of re.error; a match that runs longer than nltk.redos.DEFAULT_TIMEOUT (5 seconds) raises TimeoutError instead of hanging. Patterns keep re syntax; match objects are the regex engine's (PR #​3825, #​3829, #​3830, #​3831, #​3832, #​3833, #​3834, #​3835, #​3836, #​3837, #​3838, #​3839, #​3840, #​3841, #​3842, #​3843, #​3844, #​3845, #​3846, #​3796, #​3801, #​3906, #​3907, #​3908, #​3910)
  • Regular expressions made linear: the leading-run and re-anchoring patterns that a timeout cannot catch were rewritten or bounded in the word, Treebank, blankline, TextTiling, toktok and syllable tokenizers, the readline of corpus streams, the CoNLL SRL, TIMIT, senseval, pl196x, NKJP, Alpino, YCOE, IEER, ACE, VerbNet, reviews and Lin readers, relextract, the valuation parser, the CCG lexicon parser, dependency grammars and chomsky_normal_form, each verified on the real corpus (PR #​3947, #​3934, #​3932, #​3938, #​3935, #​3933, #​3869, #​3944, #​3911, #​3909, #​3953, #​3895)
  • Size, depth and time bounds: trees deeper than nltk.tree.MAX_TREE_DEPTH (500), WordNet and other relation walks deeper than nltk.util.MAX_RECURSION_DEPTH (500), tgrep deeper than 50, Toolbox deeper than 500, dependency graphs deeper than 200, are refused with ValueError naming the limit rather than exhausting the stack, and the stemmers, distance metrics, skipgrams, parsers and grammar transforms run in linear or bounded time with identical output for legitimate input. chart_parse stops after nltk.parse.chart.DEFAULT_MAX_TIME (5 seconds of wall-clock, needed only for feature grammars; max_time=None disables it). Tree.repr no longer recurses, so a deep accepted tree prints (PR #​3827, #​3885, #​3895, #​3767, #​3784, #​3917, #​3958, #​3960, #​3977)
  • External tools and Java: a tool binary is resolved from an absolute path or a trusted search path only, never from the current directory; the binary, its directory and the model and data files handed to it must not be writable by another account (symlinked and multi-call executables such as a packaged Graphviz dot are supported). java() accepts a main class as the first argument only (no -jar, @​argfile or .java source file), validates its options against an allowlist, and loads jars only from a data root unless NLTK_ALLOW_UNSAFE_JARS=1 opts out with a warning. CoreNLP server options are allowlisted. Stanford, Malt, Senna, hunpos, Prover9, megam, TADM, Weka and crf wrappers validate their paths and the text they pipe to the tool against line and argument injection (PR #​3772, #​3771, #​3975, #​3743, #​3782, #​3788, #​3768, #​3798, #​3887, #​3858, #​3950, #​3951, #​3812, #​3816, #​3868, #​3894, #​3941, #​3850, #​3925)
  • Network: the downloader, nltk.data.load of a URL and the CHILDES reader fetch through pathsec.urlopen, which refuses addresses that are not globally routable (loopback, private, link-local and multicast, including tunnelled and obfuscated forms), pins the validated address for the connection, allows file:// with a local authority only, and refuses a proxied fetch unless NLTK_ALLOW_PROXIED_URLOPEN=1 (or nltk.pathsec.ALLOW_PROXIED_FETCH = True) asserts the proxy is trusted. The CoreNLP client talks to its local server with requests and is not affected (PR #​3847, #​3810, #​3750, #​3850)
  • Terminal, CSV, DOT and HTML output: every print in the library goes through nltk.termsec.safe_print, which renders control characters, escape sequences and unbalanced bidi overrides from corpus text as visible \xNN escapes instead of letting them reach the terminal. The CSV files the twitter and sentiment helpers write neutralise formula-leading and control-sequence cells, AlignedSent DOT labels are escaped, the WordNet browser escapes corpus text, and nltk.data.load's verbose output no longer prints the full resource URL (PR #​3914, #​3915, #​3937, #​3946, #​3931, #​3930, #​3856, #​3902)
  • Corpus stores and encodings: the PanLex Lite and chat80 sqlite stores open read-only on a pinned descriptor with their schema screened and a statement step budget, chat80 shelves are read by a key manifest, Toolbox SFM markers are sanitised, and a resource encoding that is not a text codec (bz2_codec and friends) is refused (PR #​3961, #​3964, #​3959, #​3888, #​3800, #​3962)
  • Package contents: the wheel no longer ships nltk.test.unit (the attack harnesses, advisory probes and their fixtures), so pip install nltk is about half the size and import nltk.test.unit works from a source checkout or the sdist only. The doctests under nltk.test still ship (PR #​3954)

Security test and CI infrastructure

Other changes

  • Added RTL language syntactic tree visualization support (PR #​3472)
  • Fix #​3394: Ensure punkt_tab is downloaded when punkt is requested (PR #​3505)
  • Show README.md as the PyPI long description (PR #​3746)
  • Add stopwords.words("english-extended") (PR #​3747)
  • Krippendorff's alpha: treat placeholder labels as missing data (#​2865, #​2732) (PR #​3752)
  • Fix shared defaults in chat80 Concept (PR #​3773)
  • Fix Java wrappers decoding str output from java() (universal_newlines) (PR #​3777)
  • Prevent IndexError in Hungarian stemmer on empty string (PR #​3785)
  • Isolate MTE tag filters per view (PR #​3792)
  • Fix newline in ellipsis tokens in TweetTokenizer (PR #​3819)
  • Isolate default WordNet reference relations (PR #​3872)
  • Fix resolution paths that cancel distinct literals (PR #​3878)
  • Fix UTF-8 text preprocessing in NKJP corpus reader (PR #​3879)
  • Remove shadowed FeatStruct._walk stub and preserve its docstring (PR #​3893)
  • Count all increasing pairs in RIBES kendall_tau (PR #​3900)
  • Fix the TweetTokenizer ZWJ emoji pattern capturing adjacent whitespace (PR #​3913)
  • Surface the CoreNLP server's reason for a non-2xx answer (PR #​3942)
  • Omit unaligned (NULL target) pairs from Alignment strings, so IBM model output prints (PR #​3967)
  • Fix DependencyGraph cycle detection, which returned False on every parsed graph (PR #​3978)
  • Show, range and draw an alignment with an unaligned pair on every surface (PR #​3987)

Thanks to the following contributors to 3.10.4: Zhewen Tan, Yanhaoxi, Yazan Balawneh (Cystack.ps),
Abdulmoyn Sommakieh, Golitsin Vyacheslav, Mingzhe Yu, 宁岑, Tai An, 区梓灏, Tom Aarsen, Raffi Enficiaud,
JJ, Artemiy, Cherno.x, 0xEaS, sarvesh patil, Isaac David, Arthur Gervais, leduckhuong, Ibrahim zain,
Athul Jayaram, Chiencp, Ziyu Lin, Michael Lip, GOLDBERG8, Litesh Ghute, Kartik G, Thai Son Dinh,
infy, 0xRenSec, Joshgun Abdullayev, Arpit Jain, Mohammad Favas S, Jace, nguyencanhthuong,
kokomaru167, jankesec, Daniel Coles, Fodhil Benhiba, Ubaid Ur Rehman, Maciej Zmitrukiewicz,
Gecko Security, Bugbunny, Liling Tan, Huanyi Xie, ahcrm-core, Eric Kafe, Steven Bird.

What's Changed

[!IMPORTANT]
✂ PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate CLI.

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| pypi       | nltk    | 3.10.3 | 3.10.4 |
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added the type/digest Dependency digest updates label Nov 1, 2026
@dreadnode-renovate-bot
dreadnode-renovate-bot Bot added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 46e4c6b Nov 1, 2026
9 checks passed
@dreadnode-renovate-bot
dreadnode-renovate-bot Bot deleted the renovate/pypi-nltk-vulnerability branch November 1, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/digest Dependency digest updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants