VulnWatch by ve1ve2
high 8.7 EPSS 0.65%

GHSA-w674-vqhw-g3pg / CVE-2026-129233: NLTK: StreamBackedCorpusView constructor os.stat leaks out-of-root file existence, size, and mtime bypassing pathsec ENFORCE

Source:
GitHub Security Advisories
Published:
Fetched:
Updated:
Affects:
nltk

https://github.com/advisories/GHSA-w674-vqhw-g3pg ↗

ghsapipCWE-200CWE-538

NLTK: StreamBackedCorpusView constructor os.stat leaks out-of-root file existence, size, and mtime bypassing pathsec ENFORCE ## Summary `StreamBackedCorpusView`, a public API in `nltk/corpus/reader/util.py`, applies the pathsec sandbox to the file content it reads but not to the file metadata it probes in its constructor. When the view is created with a plain string fileid, `__init__` calls `os.stat(self._fileid).st_size` with no pathsec validation, so an application that passes an attacker influenced path to the constructor discloses whether an arbitrary out of root file exists and, if it does, its exact byte size and modification time, even when `nltk.pathsec.ENFORCE` is `True`. This is the residual metadata channel left open by the fix for CVE-2026-63312 (GHSA-x5ph-mj9p-rfr8), which closed arbitrary content read on the same code path but did not bring the sibling `os.stat` under the sandbox. ## Root Cause The pathsec sandbox is intended to confine all NLTK filesystem access to allowed data roots. The fix for CVE-2026-63312 enforced this for content reads by routing `StreamBackedCorpusView._open` through `nltk.pathsec.open` (`_secure_open`). The constructor, however, computes the end of file position eagerly, and on the non `PathPointer` branch it stats the caller supplied path directly. The `PathPointer` branch is validated (it calls `PathPointer.file_size()`), but the plain string branch reaches `os.stat` with no `validate_path`, `_secure_open`, or `required_root` check. The security invariant "no filesystem access outside allowed roots under ENFORCE" is therefore violated for the metadata channel: `os.stat` is filesystem access, and it is performed on the same untrusted string entry point that the content read fix protected. ```text Affected component: nltk.corpus.reader.util.StreamBackedCorpusView.__init__ Sink: nltk/corpus/reader/util.py, os.stat(self._fileid).st_size on the plain-string branch Guarded sibling: _open() (routes through nltk.pathsec.open); the constructor os.stat is not guarded ``` ## Impact An attacker who can influence the fileid string passed to `StreamBackedCorpusView(...)` (the same attacker model under which CVE-2026-63312 was published for content read) obtains a filesystem oracle that operates across the process visible filesystem regardless of the pathsec data roots and with `ENFORCE=True`: - Existence: a present path returns a size; a missing path raises `ValueError` whose message embeds the underlying OS error, so ENOENT, EACCES, and ENOTDIR are distinguishable, adding a permission and type probe. - Exact size: `st_size` of the target file is exposed (demonstrated below: `1850` for `/etc/passwd`, matching the real size). - Modification time: `st_mtime` is available from the same stat result. File content is not disclosed: iterating the view still routes through the sandboxed open and is refused. The demonstrated capability is therefore metadata only (existence, exact size, mtime, and error class discrimination). Reachability is application conditional: in tree corpus readers construct views from validated `PathPointer` objects Affected packages: pip:nltk Patched: nltk 3.10.4

Linked vulnerabilities (4)

CVE-2026-129233 medium 5.3 EPSS 0.34% (p28) NVDCVE.orgGHSAGHSA
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

nltk: nltk: Information disclosure via unvalidated file path inspection

CWE: CWE-22, CWE-200, CWE-538Aliases: GHSA-w674-vqhw-g3pg, CVE-2026-63312, GHSA-x5ph-mj9p-rfr8NVD: Awaiting Analysis
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

NLTK: StreamBackedCorpusView constructor os.stat leaks out-of-root file existence, size, and mtime bypassing pathsec ENFORCE

CWE: CWE-200, CWE-538Aliases: CVE-2026-129233, CVE-2026-63312, GHSA-x5ph-mj9p-rfr8
CVE-2026-63312 high 8.7 EPSS 0.65% (p52) NVDCVE.org
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

NLTK before 3.10.0 contains an arbitrary local file read vulnerability in StreamBackedCorpusView that bypasses pathsec.ENFORCE by calling builtins.open() directly instead of pathsec.open(). Attackers who control the fileid argument can read arbitrary local files regardless of the ENFORCE setting, including sensitive system files and application credentials.

CWE: CWE-22NVD: Analyzed

Also reported by (1)