Vulnerabilities in pkg:pypi/nltk

PACKAGE
Advisory Identifier: GHSA-wr3g-j6qj-xpgh
Advisory Summary

CVE-2026-128135 is a HIGH (CVSS 7.1) zip package extraction follows in-root vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting NLTK libraries in the PyPI ecosystem. The issue involves zip package extraction follows in-root hardlinks and overwrites files outside the nltk data root. Remediation is available by upgrading affected packages to version 3.10.4.

115 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/nltk

115 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/nltk. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-wr3g-j6qj-xpgh CVE-2026-128135 HIGH NLTK: ZIP package extraction follows in-root hardlinks and overwrites files outside the NLTK data root
GHSA-c59x-vh6j-3w8v CVE-2026-128136 MODERATE NLTK: AllowlistUnpickler does not deny numpy submodule-local file-I/O sinks
GHSA-g58v-j9g9-5gfg CVE-2026-128137 MODERATE NLTK corpus-reader view methods bypass the scoped root sandbox via intermediate-directory symlinks
GHSA-x8q7-6c7m-52gw CVE-2026-128138 CRITICAL NLTK incomplete fix: additional JVM/JAR sandbox bypass through unvalidated launcher tokens in java() command arguments
GHSA-j8g8-j4j7-8j54 CVE-2026-128139 HIGH NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service
GHSA-pcm8-fqjx-rvx8 CVE-2026-128140 MODERATE NLTK: Downloader cyclic collection indices cause an infinite closure walk
GHSA-9ffx-rrgx-mhgx CVE-2026-129221 MODERATE NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels
GHSA-rh8m-wqhc-qmrf CVE-2026-129222 HIGH Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()
GHSA-8846-p9w9-5frf CVE-2026-129223 HIGH Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal
GHSA-3h95-x772-4765 CVE-2026-129224 MODERATE NLTK: Uncontrolled recursion in CCG lexicon parser causes denial of service via deeply nested category input
GHSA-xfcv-m889-fmqg CVE-2026-129225 MODERATE NLTK: Uncontrolled recursion in DependencyGraph traversal causes denial of service via deep dependency chains
GHSA-w3pv-xfw4-ghr7 CVE-2026-129226 MODERATE NLTK: Uncontrolled recursion in semantic-logic type parser causes denial of service via nested type strings
GHSA-63wh-5r5m-wxr7 CVE-2026-129227 MODERATE NLTK: Uncontrolled recursion in Tree.fromlist causes denial of service via deeply nested list input
GHSA-f2h2-f4fc-p978 CVE-2026-129228 MODERATE NLTK: Uncontrolled recursion in Toolbox settings helpers causes denial of service via deeply nested input
GHSA-32p6-cwhc-8r78 CVE-2026-129229 HIGH NLTK: Compile-time regex DoS in NLTK search/tokenizer sinks: quadratic regex-engine compile bypasses the match-only timeout
GHSA-53pg-5qp8-mhvr CVE-2026-129230 MODERATE NLTK: Uncontrolled recursion in WordNet Synset hypernym walkers (max_depth/min_depth/hypernym_paths/hypernym_distances) causes DoS
GHSA-q4c8-9gwf-255x CVE-2026-129231 MODERATE NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan
GHSA-cj8f-5fp3-6m88 CVE-2026-129232 MODERATE NLTK: Quadratic CPU exhaustion in NLTK XMLCorpusView.read_block via deeply nested XML corpus tags
GHSA-w674-vqhw-g3pg CVE-2026-129233 MODERATE NLTK: StreamBackedCorpusView constructor os.stat leaks out-of-root file existence, size, and mtime bypassing pathsec ENFORCE
GHSA-cc5r-64rf-75hg CVE-2026-129234 HIGH NLTK: Untrusted search path in prover9/mace4 config allows local code execution via relative binary_location
GHSA-8fx7-8jr8-84rv CVE-2026-126303 HIGH NLTK: Unbounded CPU consumption in SteppingRecursiveDescentParser.parse() with ambiguous or self-embedding grammars
GHSA-89p3-fcch-88ph CVE-2026-126299 HIGH NLTK: Quadratic-time CPU denial of service in CCG lexicon parser (fromstring) on wide bracket bodies and operator chains
GHSA-r53h-rw34-8h97 CVE-2026-126298 HIGH NLTK: Quadratic-time CPU denial of service in Tree.chomsky_normal_form right-factor binarization via list.pop(0)
GHSA-6665-2vj3-h76r - HIGH Duplicate Advisory: Quadratic-time CPU denial of service in Tree.chomsky_normal_form right-factor binarization via list.pop(0)
GHSA-v8f3-6phw-6mh9 CVE-2026-126297 HIGH NLTK: Quadratic-time CPU denial of service in ConllCorpusReader SRL instance builder via nested span rescan
GHSA-qvhx-rvgc-jhwf - HIGH Duplicate Advisory: Quadratic-time CPU denial of service in ConllCorpusReader SRL instance builder via nested span rescan
GHSA-fg9w-wfp5-j933 CVE-2026-126295 MODERATE NLTK: BllipParser passes caller-supplied model paths to the bllipparser C extension with no pathsec check, enabling arbitrary read
GHSA-f7j6-hf97-9v99 - HIGH Duplicate Advisory: BllipParser passes caller-supplied model paths to the bllipparser C extension with no pathsec check, enabling arbitrary read
GHSA-jh6r-h4rx-2j3w - HIGH Duplicate Advisory: Quadratic-time CPU denial of service in NLTK CCG lexicon parser (fromstring) on wide bracket bodies and operator chains
GHSA-g5wx-957h-f4wj - MODERATE Duplicate Advisory: Path Traversal in save_maxent_params / load_maxent_params Allow Arbitrary File READ/WRITE
GHSA-gpwc-27cw-rh9r - MODERATE NLTK: Quadratic CPU exhaustion in LegalitySyllableTokenizer.tokenize via unguarded onset reversal loop
GHSA-ffr9-mgrr-wcvr CVE-2026-126300 MODERATE NLTK: Quadratic CPU exhaustion in TreebankWordTokenizer.span_tokenize via list.pop(0) in quote-restore loop
GHSA-rg32-vgf9-927c - MODERATE Duplicate Advisory: Quadratic CPU exhaustion in TreebankWordTokenizer.span_tokenize via list.pop(0) in quote-restore loop
GHSA-4hvg-fv5c-9936 - HIGH Duplicate Advisory: Unbounded CPU consumption in NLTK SteppingRecursiveDescentParser.parse() with ambiguous or self-embedding grammars
GHSA-qg35-44qx-7vrr CVE-2026-126304 HIGH NLTK: Symlink escape in YCOECorpusReader lets a psd/pos directory symlink read files outside the corpus root within the data sandbox
GHSA-7r4r-6ppg-7ff8 - HIGH Duplicate Advisory: Symlink escape in YCOECorpusReader lets a psd/pos directory symlink read files outside the corpus root within the data sandbox
GHSA-2jhm-w3mp-jcwr CVE-2026-12372 LOW NLTK network URL validation permits SSRF to RFC 6598 shared-address-space hosts
GHSA-ffj6-66c4-86gw CVE-2026-12261 MODERATE NLTK downloader allows cross-package resource and model poisoning
GHSA-9r6g-266r-89x4 CVE-2026-12252 HIGH NLTK Stanford wrapper classes execute untrusted JAR files without verification
GHSA-gf32-cmjh-8m9v CVE-2026-63310 CRITICAL Duplicate Advisory: NLTK: Missing Post-Download Integrity Verification Allows Malicious Package Injection
GHSA-8mpw-7fpc-4gqj CVE-2026-81725 MODERATE NLTK: Pl196xCorpusReader has quadratic ReDoS on malformed TEI blocks
GHSA-w3v8-gmh9-3wv7 CVE-2026-80206 HIGH NLTK: ReDoS in nltk.tgrep via unvalidated user-supplied regular expressions
GHSA-rrv8-h7p8-rx55 CVE-2026-80205 HIGH NLTK: ReDoS in nltk.text.Text.findall() via unvalidated user-supplied regular expressions
GHSA-2rrw-hpqm-36pv - HIGH Duplicate Advisory: ReDoS in nltk.text.Text.findall() via unvalidated user-supplied regular expressions
GHSA-3gq4-3j92-5w49 CVE-2026-79674 HIGH NLTK: Corpus Reader Sandbox Bypass
GHSA-p4rw-rvv2-7xwr CVE-2026-79676 HIGH NLTK: Corpus readers follow symlinks outside trusted roots despite pathsec enforcement
GHSA-x99w-6fgc-pmfw CVE-2026-79657 CRITICAL NLTK: Allowlisted pickle loaders still permit code execution in current source
GHSA-97qj-x29f-37w7 CVE-2026-78681 HIGH NLTK: Entity-expansion DoS (billion laughs) via remaining raw ElementTree parses
GHSA-6ww7-3frv-cqxh CVE-2026-78682 HIGH NLTK: pathsec SSRF protection can be bypassed when a proxy is configured
GHSA-rhp5-r9x4-f5g2 CVE-2026-78683 CRITICAL NLTK: Unsafe Pickle Deserialization in TransitionParser Allows Remote Code Execution
GHSA-3hhw-38pf-pxj6 CVE-2026-62383 MODERATE NLTK: Symlink-based arbitrary file read in IPIPANCorpusReader, bypasses nltk.pathsec entirely
GHSA-f833-7jw8-xwrv CVE-2026-62384 HIGH NLTK: Symlink-based sandbox bypass in FramenetCorpusReader (bypasses the fix for CVE-2026-54292)
GHSA-568f-pv23-39p4 CVE-2026-62385 HIGH NLTK: Stable FrameNet and NKJP readers parse outside-root XML
GHSA-qp76-pq9f-gr9m - HIGH Duplicate Advisory: Stable FrameNet and NKJP readers parse outside-root XML in 3.9.4
GHSA-5wp5-5229-5g6q CVE-2026-12259 MODERATE NLTK: Missing Post-Download Integrity Verification Allows Malicious Package Injection
GHSA-x5ph-mj9p-rfr8 CVE-2026-63312 HIGH NLTK: StreamBackedCorpusView Bypasses pathsec.ENFORCE - Arbitrary Local File Read
GHSA-72r2-7mfr-5xr9 CVE-2026-65915 MODERATE NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol
GHSA-r6gq-whwq-mvg9 CVE-2026-70626 HIGH NLTK: Symlink escape in CorpusReader allows arbitrary local file read outside the corpus root
GHSA-p3m8-78j2-g5p3 CVE-2026-62388 HIGH NLTK: Default ENFORCE=False Disables All pathsec Security Controls
GHSA-8vh5-mgjj-w6hg - HIGH Duplicate Advisory: [CWE-1188] Default ENFORCE=False Disables All pathsec Security Controls
GHSA-3gqm-fcw5-w839 CVE-2026-63311 MODERATE NLTK: SSRF Fail-Open in validate_network_url() via DNS Resolution Failure
GHSA-qg9p-xrhj-435m - MODERATE Duplicate Advisory: nltk: SSRF Fail-Open in validate_network_url() via DNS Resolution Failure
GHSA-rf74-v2fm-23pw CVE-2026-66393 MODERATE Natural Language Toolkit (NLTK) has unbounded recursion in JSONTaggedDecoder.decode_obj() may cause DoS
GHSA-cv2g-m8rr-888c - HIGH Duplicate Advisory: Natural Language Toolkit (NLTK) has unbounded recursion in JSONTaggedDecoder.decode_obj() may cause DoS
GHSA-cv22-g7mw-8v73 CVE-2026-71514 LOW NLTK CrubadanCorpusReader path traversal allows arbitrary file disclosure
GHSA-5gh2-94qg-qppq CVE-2026-71513 HIGH NLTK AllowlistUnpickler dotted-name validation bypass allows remote code execution
GHSA-qx2g-xrx7-vfh8 CVE-2026-72818 HIGH NLTK TweetTokenizer vulnerable to denial of service through catastrophic regex backtracking
GHSA-3m7f-6hxv-6796 - MODERATE Duplicate Advisory: Pl196xCorpusReader has quadratic ReDoS on malformed TEI blocks
GHSA-vf76-f5cp-9846 - HIGH Duplicate Advisory: ReDoS in nltk.tgrep via unvalidated user-supplied regular expressions
GHSA-w5q8-6jpp-4246 - HIGH Duplicate Advisory: Corpus readers follow symlinks outside trusted roots despite pathsec enforcement
GHSA-rcw8-9qrw-27m2 - HIGH Duplicate Advisory: NLTK: Corpus Reader Sandbox Bypass
GHSA-8w48-h75v-cxpv - HIGH Duplicate Advisory: Security Report: StreamBackedCorpusView Bypasses pathsec.ENFORCE - Arbitrary Local File Read
GHSA-8h9m-22mv-qv5r - HIGH Duplicate Advisory: Symlink escape in CorpusReader allows arbitrary local file read outside the corpus root
GHSA-qq3h-cgj8-w3fx - HIGH Duplicate Advisory: Symlink-based sandbox bypass in FramenetCorpusReader (bypasses the fix for CVE-2026-54292)
GHSA-79ph-w9m5-4v5m - HIGH Duplicate Advisory: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol
GHSA-343m-9fqq-97c7 - MODERATE Duplicate Advisory: NLTK: Symlink-based arbitrary file read in IPIPANCorpusReader, bypasses nltk.pathsec entirely
GHSA-vp9c-2pjm-8925 - CRITICAL Duplicate Advisory: Allowlisted pickle loaders still permit code execution in current source
GHSA-gx65-c5hj-vpv5 - CRITICAL Duplicate Advisory: [CWE-502] Unsafe Pickle Deserialization in TransitionParser Allows Remote Code Execution
GHSA-crp9-r7rq-c8cg - HIGH Duplicate Advisory: pathsec SSRF protection can be bypassed when a proxy is configured
GHSA-jx89-3qg8-p2mr - HIGH Duplicate Advisory: Entity-expansion DoS (billion laughs) via remaining raw ElementTree parses (CWE-776)
GHSA-ww6m-cw3f-q94g CVE-2026-81722 MODERATE NLTK: Quadratic-time DoS in PorterStemmer via long runs of 'y'
GHSA-8x48-8g7j-rqxp - HIGH Duplicate Advisory: Quadratic-time DoS in PorterStemmer via long runs of 'y'
GHSA-f794-5jv7-7672 CVE-2026-81727 MODERATE NLTK: Downloader.download follows hardlinks and overwrites outside-root files
GHSA-4xw3-jf9x-x7mf - MODERATE Duplicate Advisory: Downloader.download follows hardlinks and overwrites outside-root files
GHSA-8mgp-746c-j5xp CVE-2026-81726 HIGH NLTK: Model-artifact APIs bypass pathsec and touch files outside allowed roots
GHSA-hqj7-phwp-c3fp - HIGH Duplicate Advisory: Model-artifact APIs bypass pathsec and touch files outside allowed roots
GHSA-vp2x-qp44-57v7 CVE-2026-81723 MODERATE NLTK: Quadratic CPU Exhaustion in `XMLCorpusView._read_xml_fragment()`
GHSA-hqv3-xm29-p9hq - MODERATE Duplicate Advisory: Quadratic CPU Exhaustion in `XMLCorpusView._read_xml_fragment()`
GHSA-ff5c-cp5c-9wjf CVE-2026-12876 MODERATE NLTK: Uncontrolled resource consumption in RecursiveDescentParser via ambiguous or left-recursive grammars
GHSA-cw6x-m8jw-qmrh CVE-2026-81724 MODERATE NLTK: Uncontrolled recursion in nltk.featstruct.FeatStructReader causes unhandled RecursionError (DoS) via deeply nested feature-structure input
GHSA-pf76-q698-37v8 - MODERATE Duplicate Advisory: Uncontrolled recursion in nltk.featstruct.FeatStructReader causes unhandled RecursionError (DoS) via deeply nested feature-structure input
GHSA-m4rf-3fr8-xwx3 CVE-2026-79675 CRITICAL NLTK: JVM argument injection bypass via per-call options in the NLTK Stanford wrappers (incomplete fix of CVE-2026-12841)
GHSA-3h2g-j4wp-7qqq - CRITICAL Duplicate Advisory: JVM argument injection bypass via per-call options in the NLTK Stanford wrappers (incomplete fix of CVE-2026-12841)
GHSA-pv39-qrfq-g8gc - MODERATE Duplicate Advisory: NLTK: Missing Post-Download Integrity Verification Allows Malicious Package Injection
GHSA-6hwm-xvph-95vm CVE-2026-78680 HIGH NLTK: Uncontrolled search path when invoking the Graphviz 'dot' binary
GHSA-54xp-3ww7-6wjg - HIGH Duplicate Advisory: Uncontrolled search path when invoking the Graphviz 'dot' binary (CWE-426/CWE-427)
GHSA-m42h-3232-vpv3 CVE-2026-12243 HIGH nltk: Arbitrary File Read via Path Traversal in nltk.data.load() through Percent-Encoded Sequences
GHSA-q5h6-fcf5-49g9 - HIGH Duplicate Advisory: Arbitrary File Read via Path Traversal in nltk.data.load() through Percent-Encoded Sequences
GHSA-848c-c2cx-j7qx CVE-2025-71408 HIGH NLTK vulnerable to Eval Injection via collocations CLI arguments
GHSA-qvv7-cg9c-w4x3 CVE-2026-12075 HIGH Natural Language Toolkit (NLTK): DNS-rebinding SSRF filter bypass in nltk.pathsec.urlopen (nltk.download / nltk.data.load) defeats ENFORCE mode
GHSA-fg7f-2386-8897 CVE-2026-12061 HIGH Natural Language Toolkit (NLTK): ReDoS in NLTK ReviewsCorpusReader FEATURES regex
GHSA-6hm5-jgcp-p838 CVE-2026-12072 HIGH Natural Language Toolkit (NLTK): Path Traversal in NKJPCorpusReader leads to Arbitrary File Read and bypasses the nltk.pathsec sandbox (ENFORCE=True)
GHSA-xh95-f55m-82fw CVE-2026-12074 HIGH Natural Language Toolkit (NLTK) has path traversal in FramenetCorpusReader.frame() that allows arbitrary XML file read, bypassing the nltk.pathsec sandbox (ENFORCE=True)
GHSA-p4gq-832x-fm9v CVE-2026-54293 HIGH Natural Language Toolkit (NLTK): URL-Encoded Path Traversal in nltk.data.load() Allows Arbitrary Local File Read
GHSA-h8wq-7xc4-p3qx CVE-2026-0846 HIGH NLTK has Arbitrary File Read via Absolute Path Input in nltk.util.filestring()
GHSA-68j8-pq59-fqgm CVE-2026-0847 HIGH NLTK has a Path Traversal issue
GHSA-7p94-766c-hgjp CVE-2025-14009 CRITICAL NLTK has a Zip Slip Vulnerability
GHSA-jm6w-m3j8-898g CVE-2026-33231 HIGH Unauthenticated remote shutdown in nltk.app.wordnet_app
GHSA-469j-vmhf-r6v7 CVE-2026-33236 HIGH NLTK has a Downloader Path Traversal Vulnerability (AFO) - Arbitrary File Overwrite
GHSA-gfwx-w7gr-fvh7 CVE-2026-33230 MODERATE Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in nltk
GHSA-cgvx-9447-vcch CVE-2024-39705 HIGH ntlk unsafe deserialization vulnerability
GHSA-2ww3-fxvq-293j CVE-2021-3828 HIGH NLTK Vulnerable to REDoS
GHSA-mr7p-25v2-35wr CVE-2019-14751 HIGH NLTK Vulnerable To Path Traversal
GHSA-f8m6-h2c7-8h9x CVE-2021-43854 HIGH Inefficient Regular Expression Complexity in nltk (word_tokenize, sent_tokenize)
GHSA-rqjh-jp2r-59cj CVE-2021-3842 HIGH NLTK Vulnerable to REDoS

CVE-2026-128135 at a Glance

CVE Identifier CVE-2026-128135
GHSA Identifier GHSA-wr3g-j6qj-xpgh
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product NLTK
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-128135

To remediate this vulnerability, upgrade all affected NLTK dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nltk fixed: 3.10.4
pip install nltk>=3.10.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show nltk

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-128135, inspect your installed packages using pip:

pip show nltk

Analyze the terminal output to locate any version of NLTK in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.10.4), your application is affected.

Note: The pip show nltk command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In NLTK, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary NLTK ships a security wrapper, `nltk.pathsec.ZipFile`, that is meant to confine archive extraction to trusted data roots and to block link-based escapes. When `nltk.download()` installs a package, the extraction write opens each member's target path without checking whether that path is a hardlink to a file located outside the data root. A local actor who can write inside a shared or predictable NLTK data root (for example `~/nltk_data`, a group-writable `/usr/share/nltk_data`, or a shared container volume) can pre-plant an in-root hardlink at a member path that a soon-to-be-installed package will write. When the victim later runs the download, extraction truncates and overwrites the outside-root target through that hardlink. This is the same weakness class as the previously fixed downloader hardlink issue, but the fix did not reach the package-extraction write sink, so the latest published release remains exploitable through this path. ## Root Cause The prior fix added an `st_nlink > 1` refusal to the file-open helpers (`nltk.pathsec.open` / `_hardened_open`) and routed the downloader temporary-file write through that hardened opener, so a multiply-linked inode is refused on those paths. The extraction write sink was never given the same check. On published releases, `nltk.pathsec.ZipFile.extract` validates member names with `validate_zip_archive` and then delegates to the standard library extractor, whose plain `open(targetpath, "wb")` opens and truncates a pre-existing hardlink. The containment guard `validate_zip_archive` relies on `Path.resolve()` and name checks; `resolve()` follows symlinks (so a symlinked member is correctly refused) but a hardlink has a legitimate in-root name and in-root resolved path, so it passes. No code on the extraction path performs the `st_nlink` fstat that the sibling open helper performs. ```text Affected component: nltk.pathsec (archive extraction), driven by nltk.downloader Released sink (<= 3.10.3): nltk/pathsec.py ZipFile.extract -> stdlib zipfile._extract_member -> open(targetpath, "wb") Containment guard that fails open for hardlinks: nltk/pathsec.py validate_zip_archive (name checks + Path.resolve()) Development-branch sink: nltk/pathsec.py ZipFile._extract_member leaf reopen with O_WRONLY|O_TRUNC|O_NOFOLLOW (no st_nlink fstat) ``` ## Impact An unprivileged local user who can create a file inside a data root that the victim's NLTK installation will extract into can cause the victim's process to truncate and overwrite a file outside that root. The attacker chooses which outside file is destroyed by selecting the hardlink target, so the integrity impact is complete for the chosen path (arbitrary outside-root file destruction). Where the victim resolves packages through an attacker-influenced mirror or index, the overwritten bytes are also attacker-chosen, which plausibly enables targeted file replacement and later code execution if the victim subsequently consumes the replaced file; that escalation is plausible rather than demonstrated here. Practical exploitation requires either that kernel hardlink protection (`fs.protected_hardlinks`) is disabled, or that the outside target is one the planting actor is permitted to hardlink (owned, writable, or group-shared), which is the same precondition carried by the previously accepted advisory for this weakness class. ## Proof of Concept `Dependencies: a released nltk (3.10.3) installed from PyPI. The demonstration creates a data root, a victim file outside it, and a package archive whose member path is pre-planted as a hardlink to the victim file, then extracts through the security wrapper. It runs as a single user and succeeds even with fs.protected_hardlinks=1.` Steps: 1. Register a data root with `nltk.data.path` and create an extraction subtree inside it. 2. Create a victim file outside the data root. 3. Pre-plant an in-root hardlink at the member path the archive will write. 4. Extract the archive through `nltk.pathsec.ZipFile.extract`. ```python import os, sys, tempfile, zipfile import nltk import nltk.pathsec as ps work = tempfile.mkdtemp() data_root = os.path.join(work, "nltk_data") extract_root = os.path.join(data_root, "corpora") os.makedirs(os.path.join(extract_root, "pkgid")) nltk.data.path.insert(0, data_root) outside = os.path.join(work, "victim.txt") open(outside, "w").write("ORIGINAL-VICTIM-CONTENT") zippath = os.path.join(data_root, "pkg.zip") with zipfile.ZipFile(zippath, "w") as z: z.writestr("pkgid/target", "PWNED-BY-EXTRACTION") member_abs = os.path.join(extract_root, "pkgid/target") os.link(outside, member_abs) # pre-planted in-root hardlink with ps.ZipFile(zippath, "r") as z: z.extract("pkgid/target", path=extract_root) print("victim now:", open(outside).read()) ``` ```text victim now: PWNED-BY-EXTRACTION ``` The equivalent test using a symlink instead of a hardlink is refused by `validate_zip_archive` with a Security Violation, isolating the missing guard to hardlinks on the extraction write. ## Attack Chain 1. **Exposure:** `nltk.download()` (and `python -m nltk.downloader`) is the shipped, default entry point; extraction of `.zip` packages into a data root is default behavior and is reachable by a local actor who can write inside a shared or predictable data root. 2. **Control:** the attacker controls the target inode by pre-planting an in-root hardlink at `<download_dir>/<subdir>/<pkg_id>/<member>`, and (under an attacker-influenced mirror) the written bytes; the member name stays `<pkg_id>/...` so it satisfies every name guard. 3. **Path:** the install path does not wipe the destination before extraction (the tree is only removed on a STALE status, and that cleanup unlinks names rather than truncating the victim inode), so the planted hardlink survives to the write. The value flows through the downloader `expected_root` check and `_validate_member` (which uses `realpath`, so a hardlink stays in-root), then through `validate_zip_archive` (which uses `resolve()`), to the extraction write. 4. **Guard:** every guard on the path inspects names or resolved paths; none performs the `st_nlink > 1` fstat. `resolve()`, `realpath()`, and `O_NOFOLLOW` all fail to detect a hardlink because a hardlink is an ordinary regular file with a legitimate in-root name. 5. **Primitive:** the member write opens the pre-existing hardlink and truncates plus overwrites the outside-root inode. 6. **Result:** the victim-owned file chosen by the planting actor is destroyed and replaced with the extracted member's bytes, crossing from the managed data root out to the general filesystem. ## Bypass Evidence The prior remediation for this weakness is the canonical reference here: it added `st_nlink > 1` refusals to `nltk.pathsec.open` / `_hardened_open` and routed the downloader temporary-file write through that opener. The new evidence is that the extraction write sink was never covered by that fix. On the released 3.10.3 wheel obtained from PyPI, the only `st_nlink` occurrences are inside the open helper; `ZipFile.extract` validates names and then calls the standard library extractor with no `st_nlink` check. Attempts to disprove the finding were made and failed: - Hypothesis that the released 3.10.3 routes extraction through a hardened or `st_nlink` path: refuted by inspecting the released wheel (`ZipFile.extract` delegates to the standard library, no override, no `st_nlink` on the extraction path) and by dynamic reproduction (hardlink overwrote the outside file; symlink refused). - Hypothesis that `validate_zip_archive` or `_validate_member` catch the hardlink: refuted because both use `resolve()` / `realpath()`, which cannot reveal a hardlink; the symlink-refused versus hardlink-overwritten asymmetry was reproduced. - Hypothesis that the download flow wipes the destination before extraction: refuted because the wipe runs only on a STALE status and uses name unlink, which does not truncate the victim inode. - Hypothesis that `O_NOFOLLOW` / `O_EXCL` on the development branch block it: refuted because `O_NOFOLLOW` guards only against a symlink final component and `O_EXCL` merely diverts to the truncate reopen branch; neither performs the `st_nlink` fstat. - Hypothesis that kernel hardlink protection makes it a non-issue: retained as a severity bound, not a disqualifier, because the same precondition applies to the previously accepted advisory for this weakness class. ## Affected Versions - `Ecosystem: pip` - `Package: nltk` - `Confirmed affected range: >= 3.9.4, <= 3.10.3` - `Latest release checked: 3.10.3 (PyPI, nltk-3.10.3-py3-none-any.whl)` - `Fix status: not fixed (latest published release is affected; no fixed version exists)` The latest published release (3.10.3) carries the open-helper fix for the related downloader issue yet remains exploitable through the extraction sink, so the upper bound is the current release and no fixed version exists. Releases 3.9.4 through 3.10.2 have no `st_nlink` guard at all and follow the hardlink through the same extraction path (confirmed by wheel inspection); the range floor 3.9.4 is the earliest release carrying this `nltk.pathsec` extraction path. The development branch adds a hardened extraction override that still omits the `st_nlink` check, so the same vector persists there through a different sink symbol; a fixed release should not be inferred from that development-branch change. ## Suggested Fix Enforce the invariant that an extraction write must never land on a multiply-linked inode. Extend the existing `st_nlink > 1` refusal (as implemented in the hardened open helper) to the extraction write descriptor: after opening or creating the leaf target, `fstat` the descriptor and refuse an inode with `st_nlink > 1` before truncating or writing. Apply this on both the released delegation path and the development-branch `_extract_member` override, or alternatively have `validate_zip_archive` / the downloader member validator `fstat` each existing target and refuse a multiply-linked inode. As an interim mitigation, operators should ensure `fs.protected_hardlinks=1` is enabled and avoid shared, group-writable, or predictable data roots for accounts that run untrusted downloads. Reported by zx (GitHub: @manus-pi). ## Fix status (2026-09-28) Status: IN PROGRESS (fix on an open pull request, not yet on develop). PR: #3753 "[Do not merge yet] Fix GHSA-8mgp-746c-j5xp: URL-scheme bypass of pathsec.validate_path", open; head da55cab0e at the time of this note (a develop merge on top of 238f81500, the head on which the verdicts below were measured). Fix commit: cf12a5e6a (pathsec.ZipFile._extract_member resolves member names to ZipInfo so the hardened extraction path actually runs, refuses a target with st_nlink greater than 1, and replaces through unlink plus O_EXCL; the downloader adds an lstat pre-check). Probe: nltk/test/unit/security_probes/ghsa_wr3g_j6qj_xpgh.py (on the PR). Verdict on the PR head: FIXED (hardlinked member target refused with PermissionError). The same probe run against develop 2fa3f48fe: VULNERABLE (extraction wrote through the hardlink to the outside secret). Release: none.

CVE-2026-128135 Affected NLTK Versions

1 component(s)
Fixed Versions:
3.10.4
Product / Package Ecosystem Affected Versions Fixed Version
nltk
PyPI
≥ 3.9.4
< 3.10.4
3.10.4

References

Frequently Asked Questions

What is CVE-2026-128135?
CVE-2026-128135 is a security vulnerability in NLTK involving ZIP package extraction follows in-root hardlinks and overwrites files outside the NLTK data root under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which NLTK versions are affected?
Affected versions include releases prior to 3.10.4 across affected packages: nltk.
What version fixes CVE-2026-128135?
Upgrading to 3.10.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nltk affected?
Yes, nltk is affected in releases prior to 3.10.4. Upgrade your dependency to 3.10.4 or later.
What is the CVSS score of CVE-2026-128135?
CVE-2026-128135 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2026-128135?
CVE-2026-128135 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check PyPI dependencies for CVE-2026-128135?
Run the dependency tree command: 'pip show nltk'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wr3g-j6qj-xpgh",
  "modified" : "2026-11-19T23:59:15Z",
  "published" : "2026-11-19T23:59:15Z",
  "aliases" : [ "CVE-2026-128135" ],
  "summary" : "NLTK: ZIP package extraction follows in-root hardlinks and overwrites files outside the NLTK data root",
  "details" : "## Summary\n\nNLTK ships a security wrapper, `nltk.pathsec.ZipFile`, that is meant to confine archive extraction to trusted data roots and to block link-based escapes. When `nltk.download()` installs a package, the extraction write opens each member's target path without checking whether that path is a hardlink to a file located outside the data root. A local actor who can write inside a shared or predictable NLTK data root (for example `~/nltk_data`, a group-writable `/usr/share/nltk_data`, or a shared container volume) can pre-plant an in-root hardlink at a member path that a soon-to-be-installed package will write. When the victim later runs the download, extraction truncates and overwrites the outside-root target through that hardlink. This is the same weakness class as the previously fixed downloader hardlink issue, but the fix did not reach the package-extraction write sink, so the latest published release remains exploitable through this path.\n\n## Root Cause\n\nThe prior fix added an `st_nlink > 1` refusal to the file-open helpers (`nltk.pathsec.open` / `_hardened_open`) and routed the downloader temporary-file write through that hardened opener, so a multiply-linked inode is refused on those paths. The extraction write sink was never given the same check. On published releases, `nltk.pathsec.ZipFile.extract` validates member names with `validate_zip_archive` and then delegates to the standard library extractor, whose plain `open(targetpath, \"wb\")` opens and truncates a pre-existing hardlink. The containment guard `validate_zip_archive` relies on `Path.resolve()` and name checks; `resolve()` follows symlinks (so a symlinked member is correctly refused) but a hardlink has a legitimate in-root name and in-root resolved path, so it passes. No code on the extraction path performs the `st_nlink` fstat that the sibling open helper performs.\n\n```text\nAffected component: nltk.pathsec (archive extraction), driven by nltk.downloader\nReleased sink (<= 3.10.3): nltk/pathsec.py ZipFile.extract -> stdlib zipfile._extract_member -> open(targetpath, \"wb\")\nContainment guard that fails open for hardlinks: nltk/pathsec.py validate_zip_archive (name checks + Path.resolve())\nDevelopment-branch sink: nltk/pathsec.py ZipFile._extract_member leaf reopen with O_WRONLY|O_TRUNC|O_NOFOLLOW (no st_nlink fstat)\n```\n\n## Impact\n\nAn unprivileged local user who can create a file inside a data root that the victim's NLTK installation will extract into can cause the victim's process to truncate and overwrite a file outside that root. The attacker chooses which outside file is destroyed by selecting the hardlink target, so the integrity impact is complete for the chosen path (arbitrary outside-root file destruction). Where the victim resolves packages through an attacker-influenced mirror or index, the overwritten bytes are also attacker-chosen, which plausibly enables targeted file replacement and later code execution if the victim subsequently consumes the replaced file; that escalation is plausible rather than demonstrated here. Practical exploitation requires either that kernel hardlink protection (`fs.protected_hardlinks`) is disabled, or that the outside target is one the planting actor is permitted to hardlink (owned, writable, or group-shared), which is the same precondition carried by the previously accepted advisory for this weakness class.\n\n## Proof of Concept\n\n`Dependencies: a released nltk (3.10.3) installed from PyPI. The demonstration creates a data root, a victim file outside it, and a package archive whose member path is pre-planted as a hardlink to the victim file, then extracts through the security wrapper. It runs as a single user and succeeds even with fs.protected_hardlinks=1.`\n\nSteps:\n1. Register a data root with `nltk.data.path` and create an extraction subtree inside it.\n2. Create a victim file outside the data root.\n3. Pre-plant an in-root hardlink at the member path the archive will write.\n4. Extract the archive through `nltk.pathsec.ZipFile.extract`.\n\n```python\nimport os, sys, tempfile, zipfile\nimport nltk\nimport nltk.pathsec as ps\n\nwork = tempfile.mkdtemp()\ndata_root = os.path.join(work, \"nltk_data\")\nextract_root = os.path.join(data_root, \"corpora\")\nos.makedirs(os.path.join(extract_root, \"pkgid\"))\nnltk.data.path.insert(0, data_root)\n\noutside = os.path.join(work, \"victim.txt\")\nopen(outside, \"w\").write(\"ORIGINAL-VICTIM-CONTENT\")\n\nzippath = os.path.join(data_root, \"pkg.zip\")\nwith zipfile.ZipFile(zippath, \"w\") as z:\n    z.writestr(\"pkgid/target\", \"PWNED-BY-EXTRACTION\")\n\nmember_abs = os.path.join(extract_root, \"pkgid/target\")\nos.link(outside, member_abs)  # pre-planted in-root hardlink\n\nwith ps.ZipFile(zippath, \"r\") as z:\n    z.extract(\"pkgid/target\", path=extract_root)\n\nprint(\"victim now:\", open(outside).read())\n```\n\n```text\nvictim now: PWNED-BY-EXTRACTION\n```\n\nThe equivalent test using a symlink instead of a hardlink is refused by `validate_zip_archive` with a Security Violation, isolating the missing guard to hardlinks on the extraction write.\n\n## Attack Chain\n\n1. **Exposure:** `nltk.download()` (and `python -m nltk.downloader`) is the shipped, default entry point; extraction of `.zip` packages into a data root is default behavior and is reachable by a local actor who can write inside a shared or predictable data root.\n2. **Control:** the attacker controls the target inode by pre-planting an in-root hardlink at `<download_dir>/<subdir>/<pkg_id>/<member>`, and (under an attacker-influenced mirror) the written bytes; the member name stays `<pkg_id>/...` so it satisfies every name guard.\n3. **Path:** the install path does not wipe the destination before extraction (the tree is only removed on a STALE status, and that cleanup unlinks names rather than truncating the victim inode), so the planted hardlink survives to the write. The value flows through the downloader `expected_root` check and `_validate_member` (which uses `realpath`, so a hardlink stays in-root), then through `validate_zip_archive` (which uses `resolve()`), to the extraction write.\n4. **Guard:** every guard on the path inspects names or resolved paths; none performs the `st_nlink > 1` fstat. `resolve()`, `realpath()`, and `O_NOFOLLOW` all fail to detect a hardlink because a hardlink is an ordinary regular file with a legitimate in-root name.\n5. **Primitive:** the member write opens the pre-existing hardlink and truncates plus overwrites the outside-root inode.\n6. **Result:** the victim-owned file chosen by the planting actor is destroyed and replaced with the extracted member's bytes, crossing from the managed data root out to the general filesystem.\n\n## Bypass Evidence\n\nThe prior remediation for this weakness is the canonical reference here: it added `st_nlink > 1` refusals to `nltk.pathsec.open` / `_hardened_open` and routed the downloader temporary-file write through that opener. The new evidence is that the extraction write sink was never covered by that fix. On the released 3.10.3 wheel obtained from PyPI, the only `st_nlink` occurrences are inside the open helper; `ZipFile.extract` validates names and then calls the standard library extractor with no `st_nlink` check. Attempts to disprove the finding were made and failed:\n\n- Hypothesis that the released 3.10.3 routes extraction through a hardened or `st_nlink` path: refuted by inspecting the released wheel (`ZipFile.extract` delegates to the standard library, no override, no `st_nlink` on the extraction path) and by dynamic reproduction (hardlink overwrote the outside file; symlink refused).\n- Hypothesis that `validate_zip_archive` or `_validate_member` catch the hardlink: refuted because both use `resolve()` / `realpath()`, which cannot reveal a hardlink; the symlink-refused versus hardlink-overwritten asymmetry was reproduced.\n- Hypothesis that the download flow wipes the destination before extraction: refuted because the wipe runs only on a STALE status and uses name unlink, which does not truncate the victim inode.\n- Hypothesis that `O_NOFOLLOW` / `O_EXCL` on the development branch block it: refuted because `O_NOFOLLOW` guards only against a symlink final component and `O_EXCL` merely diverts to the truncate reopen branch; neither performs the `st_nlink` fstat.\n- Hypothesis that kernel hardlink protection makes it a non-issue: retained as a severity bound, not a disqualifier, because the same precondition applies to the previously accepted advisory for this weakness class.\n\n## Affected Versions\n\n- `Ecosystem: pip`\n- `Package: nltk`\n- `Confirmed affected range: >= 3.9.4, <= 3.10.3`\n- `Latest release checked: 3.10.3 (PyPI, nltk-3.10.3-py3-none-any.whl)`\n- `Fix status: not fixed (latest published release is affected; no fixed version exists)`\n\nThe latest published release (3.10.3) carries the open-helper fix for the related downloader issue yet remains exploitable through the extraction sink, so the upper bound is the current release and no fixed version exists. Releases 3.9.4 through 3.10.2 have no `st_nlink` guard at all and follow the hardlink through the same extraction path (confirmed by wheel inspection); the range floor 3.9.4 is the earliest release carrying this `nltk.pathsec` extraction path. The development branch adds a hardened extraction override that still omits the `st_nlink` check, so the same vector persists there through a different sink symbol; a fixed release should not be inferred from that development-branch change.\n\n## Suggested Fix\n\nEnforce the invariant that an extraction write must never land on a multiply-linked inode. Extend the existing `st_nlink > 1` refusal (as implemented in the hardened open helper) to the extraction write descriptor: after opening or creating the leaf target, `fstat` the descriptor and refuse an inode with `st_nlink > 1` before truncating or writing. Apply this on both the released delegation path and the development-branch `_extract_member` override, or alternatively have `validate_zip_archive` / the downloader member validator `fstat` each existing target and refuse a multiply-linked inode. As an interim mitigation, operators should ensure `fs.protected_hardlinks=1` is enabled and avoid shared, group-writable, or predictable data roots for accounts that run untrusted downloads.\n\nReported by zx (GitHub: @manus-pi).\n\n## Fix status (2026-09-28)\n\nStatus: IN PROGRESS (fix on an open pull request, not yet on develop).\n\nPR: #3753 \"[Do not merge yet] Fix GHSA-8mgp-746c-j5xp: URL-scheme bypass of pathsec.validate_path\", open; head da55cab0e at the time of this note (a develop merge on top of 238f81500, the head on which the verdicts below were measured).\n\nFix commit: cf12a5e6a (pathsec.ZipFile._extract_member resolves member names to ZipInfo so the hardened extraction path actually runs, refuses a target with st_nlink greater than 1, and replaces through unlink plus O_EXCL; the downloader adds an lstat pre-check).\n\nProbe: nltk/test/unit/security_probes/ghsa_wr3g_j6qj_xpgh.py (on the PR). Verdict on the PR head: FIXED (hardlinked member target refused with PermissionError). The same probe run against develop 2fa3f48fe: VULNERABLE (extraction wrote through the hardlink to the outside secret).\n\nRelease: none.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "nltk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.9.4"
      }, {
        "fixed" : "3.10.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.10.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nltk/nltk/security/advisories/GHSA-wr3g-j6qj-xpgh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-128135"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nltk/nltk/pull/3753"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nltk/nltk/commit/0e9898b7615b4ab3b023e868212316a489ece4f0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nltk/nltk/commit/cf12a5e6a439fe1d722acd53d4309911faaaaf78"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nltk/nltk"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nltk/nltk/releases/tag/v3.10.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-59", "CWE-73" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T23:59:15Z",
    "nvd_published_at" : "2026-11-19T18:18:05Z"
  }
}