Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

CVE-2026-128135: CVE-2026-128135: Sandbox Escape and Arbitrary File Overwrite via Hardlink Following in NLTK ZIP Extraction

CVE-2026-128135: Sandbox Escape and Arbitrary File Overwrite via Hardlink Following in NLTK ZIP Extraction Vulnerability ID: CVE-2026-128135 CVSS Score: 7.1 Published: 2026-11-19 A local sandbox escape vulnerability

CVE-2026-128135: Sandbox Escape and Arbitrary File Overwrite via Hardlink Following in NLTK ZIP Extraction

Vulnerability ID: CVE-2026-128135
CVSS Score: 7.1
Published: 2026-11-19

A local sandbox escape vulnerability exists in the Natural Language Toolkit (NLTK) versions 3.9.4 through 3.10.3 within its ZIP archive extraction implementation. Due to a type mismatch in member resolution and a failure to inspect filesystem link counts (st_nlink > 1), the extraction routine follows pre-planted hardlinks inside the extraction root, allowing a local attacker to truncate and overwrite arbitrary out-of-root files writable by the executing process.

TL;DR

NLTK versions 3.9.4 to 3.10.3 fail to reject multiply-linked files during ZIP package extraction and silently fall back to standard library extraction when handling string member names. A local attacker with write access to the extraction target directory can plant a hardlink pointing to an external file on the same filesystem, causing NLTK to overwrite the external target during package installation. Upgrading to NLTK 3.10.4 resolves the issue.

⚠️ Exploit Status: POC

Technical Details

  • Vulnerability Type: CWE-59: Improper Link Resolution Before File Access ('Link Following')
  • CVSS v3.1 Score: 7.1 High (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H)
  • Attack Vector: Local Filesystem (Pre-planted POSIX Hardlink in NLTK Extraction Directory)
  • Affected Component: nltk.pathsec.ZipFile._extract_member and nltk.downloader._unzip_iter
  • Affected Versions: NLTK >= 3.9.4, < 3.10.4
  • Patched Version: NLTK 3.10.4
  • Impact: Sandbox Escape, Arbitrary Out-of-Root File Truncation and Overwrite
  • Exploit Status: PoC Available (Official Unit Test Regression Probe)

Affected Systems

  • NLTK (Natural Language Toolkit) Python Library (versions 3.9.4 through 3.10.3) on POSIX filesystems
  • nltk: >= 3.9.4, < 3.10.4 (Fixed in: 3.10.4)

Code Analysis

Commit: 0e9898b

Consolidated security patch resolving string member names to ZipInfo in pathsec.ZipFile._extract_member and rejecting targets with st_nlink > 1.

@@ -2135,6 +2135,15 @@ def _extract_member(self, member, targetpath, pwd):
+        if not isinstance(member, zipfile.ZipInfo):
+            try:
+                member = self.getinfo(member)
+            except KeyError:
+                return super()._extract_member(member, targetpath, pwd)
@@ -2179,14 +2198,23 @@ def _extract_member(self, member, targetpath, pwd):
+                if info.st_nlink > 1:
+                    raise PermissionError(
+                        f"Security Violation [pathsec.ZipFile]: refusing "
+                        f"multiply-linked file {leaf!r} (st_nlink="
+                        f"{info.st_nlink}); a hardlink may alias an "
+                        "outside-root inode (CWE-59)"
+                    )
+                os.unlink(leaf, dir_fd=dir_fd)
+                leaf_fd = os.open(leaf, flags, 0o644, dir_fd=dir_fd)

Commit: cf12a5e

Initial security hardening commit introducing hardlink refusal checks and regression probes for GHSA-wr3g-j6qj-xpgh.

Exploit Details

  • GitHub: Official regression test harness and security probe (nltk/test/unit/security_probes/ghsa_wr3g_j6qj_xpgh.py) demonstrating the hardlink overwrite.

Mitigation Strategies

  • Upgrade NLTK to version 3.10.4 or later to enforce st_nlink checks and proper ZipInfo resolution in nltk.pathsec.ZipFile.
  • Isolate NLTK data roots (NLTK_DATA) in private directories with 0700 permissions owned exclusively by the executing service account.
  • Enable kernel-level hardlink restrictions (fs.protected_hardlinks=1 on Linux) on multi-user systems.
  • Mount shared or temporary scratch directories on separate filesystem partitions from sensitive application and user configuration files.

Remediation Steps:

  1. Update the nltk Python package via pip: pip install --upgrade 'nltk>=3.10.4'
  2. Audit existing NLTK data directories for multiply-linked files using: find /path/to/nltk_data -type f -links +1
  3. Remove any unauthorized hardlinks discovered within the corpus or package directories.
  4. Configure directory permissions on all paths listed in nltk.data.path to disallow group or world write access (chmod -R go-w /path/to/nltk_data).

References

Read the full report for CVE-2026-128135 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.