nltk: Improper Link Resolution Before File Access ('Link Following') (CVE-2026-128135)
Published Last modified Sources: EUVD, OSV, Hersteller, CVE.org
What is affected, what to do
Update nltk to version 3.10.4.
Not sure whether and how you are affected? Ask a question about this vulnerability
Metrics
7.1
XIEM Effective CVSS
Highest available CVSS rating from NVD and vendor data.
Source: Vendor (CNA), CVSS v3
7.1
CVSS v3
Severity High on the scale from 0 to 10.
Source: EUVD, OSV, Hersteller, CVE.org
—
EPSS score
No value is available for this vulnerability.
Show all metrics
- Severity
- High
Priority (0–325)
The priority score is a consolidated metric that condenses several individual signals into a single, action-guiding ranking: technical severity (CVSS), exploitation likelihood (EPSS), known-exploited status (KEV) and the context of the affected asset. The aim is to answer the only truly important question in vulnerability management: what first?
Read in glossary- 65.50 Methodology
Exploit maturity
An exploit is code or a technique that specifically uses a concrete vulnerability to force unintended behaviour — such as executing code or escalating privileges. It is the tool that turns a theoretical flaw into a practical attack.
Read in glossary- no public PoC known
XIEM Effective CVSS
XIEM® is the tiered managed-security operating model from NEOSEC and a registered trademark of NEOSEC GmbH. It extends classic SIEM — the central collection, normalisation and correlation of security-relevant events — with endpoint forensics, network visibility and deception technology, and consolidates them into three building tiers: Sentry, Orchestrate and Command.
Read in glossary- 7.1 Methodology
CVSS v3
CVSS is the globally established, open standard for assessing the technical severity of a vulnerability on a scale from 0 to 10. It describes how easily a flaw can be exploited and what damage it can cause — but not how likely its actual exploitation is. CVSS and the complementary EPSS deliberately answer different questions.
Read in glossary- 7.1
KEV status
The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.
Read in glossary- —
- Published
CWE
CWE is a catalogue of typical weakness types in software and hardware — such as flawed input validation, unsafe memory handling or poor authentication. Where a CVE names a concrete vulnerability in a concrete product, a CWE describes the underlying class of defect.
Read in glossary- CWE-59, CWE-73
Detection rules
No NEOSEC detection rule is available for this vulnerability yet.
Classification under NIS2 and CRA
Rule-based classification from exploitation status and severity. It does not replace a case-by-case assessment.
NIS2
NIS2 is EU Directive (EU) 2022/2555 to raise the level of cybersecurity across the Union. It substantially broadens obligations compared with the first NIS directive: more sectors, mandatory risk management, staged reporting duties and personal accountability of senior management.
Read in glossary- High technical severity: assess and remediate the vulnerability in vulnerability handling under Art. 21(2)(e) NIS2 and document the decision.
CRA
The CRA is EU Regulation (EU) 2024/2847 setting horizontal cybersecurity requirements for „products with digital elements“ — from industrial controllers and software to connected consumer devices. For the first time manufacturers must ensure security across the entire product lifecycle, handle vulnerabilities and provide security updates.
Read in glossary- From 11.12.2027, Annex I Part II CRA requires manufacturers of affected products with digital elements to handle vulnerabilities without delay and provide security updates.
ISO/IEC 27001
ISO/IEC 27001 is the internationally leading standard for an information security management system (ISMS). It describes a risk-based, process-oriented framework to systematically plan, implement, review and improve information security.
Read in glossary- Control A.8.8, management of technical vulnerabilities: assess relevance to your systems, plan remediation and keep evidence.
Description
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.
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:
- Register a data root with
nltk.data.pathand create an extraction subtree inside it. - Create a victim file outside the data root.
- Pre-plant an in-root hardlink at the member path the archive will write.
- Extract the archive through
nltk.pathsec.ZipFile.extract.
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())
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
- Exposure:
nltk.download()(andpython -m nltk.downloader) is the shipped, default entry point; extraction of.zippackages into a data root is default behavior and is reachable by a local actor who can write inside a shared or predictable data root. - 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. - 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_rootcheck and_validate_member(which usesrealpath, so a hardlink stays in-root), then throughvalidate_zip_archive(which usesresolve()), to the extraction write. - Guard: every guard on the path inspects names or resolved paths; none performs the
st_nlink > 1fstat.resolve(),realpath(), andO_NOFOLLOWall fail to detect a hardlink because a hardlink is an ordinary regular file with a legitimate in-root name. - Primitive: the member write opens the pre-existing hardlink and truncates plus overwrites the outside-root inode.
- 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_nlinkpath: refuted by inspecting the released wheel (ZipFile.extractdelegates to the standard library, no override, nost_nlinkon the extraction path) and by dynamic reproduction (hardlink overwrote the outside file; symlink refused). - Hypothesis that
validate_zip_archiveor_validate_membercatch the hardlink: refuted because both useresolve()/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
Source: ENISA EUVD, OSV (Open Source Vulnerabilities), GitHub Security Advisories, cvelistv5, CVE.org (MITRE), NVD (NIST)
Affected products
The following versions are affected. Older releases of the same product line are also vulnerable unless stated otherwise.
| Affected versions | Fixed in | ||
|---|---|---|---|
| nltk | nltk |
|
|
| pip | nltk |
|
|
| pypi | nltk |
|
|
Vendors and products
Weakness classes (CWE)
CWE-59Improper Link Resolution Before File Access ('Link Following')
Base
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.
Entry at MITRE CWE-59CWE-73External Control of File Name or Path
Base
The product allows user input to control or influence paths or file names that are used in filesystem operations.
Entry at MITRE CWE-73
References & sources
- github.comnltk/nltk/commit/0e9898b7615b4ab3b023e868212316a489ece4f0x_refsource_MISC, euvd, web
- github.comnltk/nltk/commit/cf12a5e6a439fe1d722acd53d4309911faaaaf78x_refsource_MISC, euvd, web
- github.comnltk/nltk/pull/3753x_refsource_MISC, euvd, web
- github.comnltk/nltk/releases/tag/v3.10.4x_refsource_MISC, euvd, web
- github.comnltk/nltk/security/advisories/GHSA-wr3g-j6qj-xpghx_refsource_CONFIRM, euvd, web
- NVD (NIST)vuln/detail/CVE-2026-128135advisory, euvd
- github.comnltk/nltkpackage
Changes to this CVE
Who changed this CVE and when: NVD (analysis, affected products, CVSS), the CVE publisher (CNA) and additional providers such as CISA (ADP).
ReceivedGitHub
CVSS V3.1: AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H
Weakness type: CWE-59, CWE-73
Description added or changed
Show 10 original changes
Individual changes of this event as published by NVD Type Action Before After Description added —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.9.4 to 3.10.3, NLTK ZIP package extraction can write through an existing in-root hardlink whose other link points outside the NLTK data root. A local attacker who can prepare the extraction target can cause a package member write to overwrite an out-of-root file, violating the pathsec containment boundary and affecting integrity and availability. This issues is fixed in version 3.10.4.CVSS added —AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:HWeakness type (CWE) added —CWE-59Weakness type (CWE) added —CWE-73Affected versions (publisher) added —New affected value received. <a href="https://github.com/CVEProject/cvelistV5/blob/main/cves/2026/128xxx/CVE-2026-128135.json">CVE-2026-128135</a>Reference added —https://github.com/nltk/nltk/commit/0e9898b7615b4ab3b023e868212316a489ece4f0Reference added —https://github.com/nltk/nltk/commit/cf12a5e6a439fe1d722acd53d4309911faaaaf78Reference added —https://github.com/nltk/nltk/pull/3753Reference added —https://github.com/nltk/nltk/releases/tag/v3.10.4Reference added —https://github.com/nltk/nltk/security/advisories/GHSA-wr3g-j6qj-xpghSource identifier: security-advisories@github.com
Embed badge
Show the severity and KEV status of this vulnerability on your site – with a link back here. The image is updated hourly.
<a href="https://intel.neosec.eu/en/cve/CVE-2026-128135"><img src="https://intel.neosec.eu/badge/cve/CVE-2026-128135.svg?lang=en" alt="CVE-2026-128135 – NEOSEC Intel" height="20"></a>