Insertion of Sensitive Information into Externally-Accessible File or Directory Affecting nltk package, versions [3.10.0,3.10.4)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.42% (28th percentile)

Do your applications use this vulnerable package?

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 applications
  • Snyk IDSNYK-PYTHON-NLTK-22733171
  • published22 Nov 2026
  • disclosed19 Nov 2026
  • creditDaniel Coles

Introduced: 19 Nov 2026

NewCVE-2026-129233  (opens in a new tab)
CWE-538  (opens in a new tab)

How to fix?

Upgrade nltk to version 3.10.4 or higher.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Insertion of Sensitive Information into Externally-Accessible File or Directory via the StreamBackedCorpusView.__init__ constructor in nltk/corpus/reader/util.py, which calls os.stat(self._fileid).st_size on a caller-supplied plain string path with no pathsec validation. When an attacker can influence the fileid string passed to the constructor, the eager stat discloses whether an arbitrary out-of-root file exists, its exact byte size, and its modification time, even when nltk.pathsec.ENFORCE is True. On a missing or inaccessible path the constructor raises a ValueError whose message embeds the underlying OS error, allowing the attacker to distinguish ENOENT, EACCES, and ENOTDIR, providing a filesystem existence and permission oracle. File content is not disclosed: iteration of the view still routes through the sandboxed _open and is refused by pathsec.

Note: This is only exploitable when application code passes an attacker-influenced plain string directly to the StreamBackedCorpusView public constructor; in-tree corpus readers pass validated PathPointer objects and take the guarded branch.

PoC

Requires nltk 3.10.0 through 3.10.3 installed (the pathsec-hardened line). No non-default configuration; pathsec ENFORCE defaults to True. Reproduced against the published PyPI sdist nltk==3.10.3.

  1. Construct the public corpus view with an out of root path string.
  2. Read the eagerly computed _eofpos (the leaked size) without iterating the view.
  3. Observe that iterating the view (which would read content) is blocked by the sandbox.
import os
import nltk.pathsec as ps
from nltk.corpus.reader.util import StreamBackedCorpusView as V

print("ENFORCE", ps.ENFORCE) # True (default)

v = V("/etc/passwd", lambda s: [s.read()]) print("size leaked", v._eofpos, "real", os.stat("/etc/passwd").st_size)

try: "".join(list(v)) # attempt content read except Exception as e: print("content blocked", type(e).name)

ENFORCE True
size leaked 1850 real 1850
content blocked PermissionError    # Security Violation [pathsec.open]: Unauthorized path /etc/passwd

A nonexistent path instead raises ValueError: Unable to open or access '/etc/nonexistent_xyz' -- [Errno 2] No such file or directory, providing the existence and error class oracle.

Note: Reproduced against the published PyPI sdist nltk==3.10.3 with no non-default configuration and pathsec ENFORCE defaulting to True.

CVSS Base Scores

version 4.0
version 3.1