CVE-2026-65915: NLTK FileSystemPathPointer.open() Sandbox Check Is Dead Vulnerability
MODERATECVE-2026-65915 is a MODERATE (CVSS 6.5) filesystempathpointer.open() sandbox check is dead vulnerability (CWE-284: Improper Access Control) affecting NLTK libraries in the PyPI ecosystem. The issue involves filesystempathpointer.open() sandbox check is dead code — arbitrary file read via file:// protocol. Remediation is available by upgrading affected packages to version 3.10.0.
CVE-2026-65915 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2026-65915
To remediate this vulnerability, upgrade all affected NLTK dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install nltk>=3.10.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show nltk
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-65915, inspect your installed packages using pip:
pip show nltk
Analyze the terminal output to locate any version of NLTK in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.10.0), your application is affected.
Note: The pip show nltk command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In NLTK, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-65915 Affected NLTK Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nltk
|
PyPI |
< 3.10.0
|
3.10.0
|
References
Frequently Asked Questions
What is CVE-2026-65915?
Which NLTK versions are affected?
What version fixes CVE-2026-65915?
Is nltk affected?
What is the CVSS score of CVE-2026-65915?
What CWE is associated with CVE-2026-65915?
How can I check PyPI dependencies for CVE-2026-65915?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-72r2-7mfr-5xr9",
"modified" : "2026-09-08T15:27:12Z",
"published" : "2026-09-08T15:27:12Z",
"aliases" : [ "CVE-2026-65915" ],
"summary" : "NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol",
"details" : "### Summary\n\nThere's a logic bug in `FileSystemPathPointer.open()` inside `nltk/data.py`\nthat makes the sandbox check permanently inert. The guard condition is always\n`False` — meaning any file the process can read is accessible by passing a\n`file://` URL to `nltk.data.load()`.\n\n---\n\n### Details\n\nIn `nltk/data.py`, `FileSystemPathPointer.open()` was patched at some point\nwith a comment saying \"SECURITY PATCH ENFORCING SANDBOX\", but the check\ndoesn't work:\n```python\ndef open(self, encoding=None):\n path = os.path.normpath(self._path)\n\n # Block raw absolute reads such as \"/\" \"C:\\\\Windows\" etc.\n if os.path.isabs(path) and path != os.path.normpath(self._path):\n raise ValueError(f\"Direct absolute file access blocked: {path}\")\n\n stream = open(self._path, \"rb\")\n```\n\n`path` is set to `os.path.normpath(self._path)` on line 1, then compared\nagainst `os.path.normpath(self._path)` again in the condition. They are\nalways equal. The `ValueError` never fires.\n\nOn top of that, `__init__` already calls `os.path.abspath()` before storing\n`self._path`, so it's normalized before `open()` is even called. Running\n`normpath` on it again changes nothing.\n\nThe `stream = open(self._path, \"rb\")` line is always reached regardless of\nwhat path was passed in.\n\n---\n\n### PoC\n\nTested on Python 3.11, NLTK 3.9.1, Ubuntu 22.04.\n```python\nimport nltk\nfrom nltk.data import FileSystemPathPointer\n\n# direct construction\nptr = FileSystemPathPointer(\"/etc/passwd\")\nwith ptr.open() as f:\n print(f.read(300))\n\n# via load() using file:// URL\ndata = nltk.data.load(\"file:///etc/passwd\", format=\"raw\")\nprint(data[:300])\n```\n\nBoth print file contents. No exception is raised.\n\n---\n\n### Impact\n\nAny app that lets users influence the string passed to `nltk.data.load()` or\n`nltk.data.find()` is exposed — web APIs, notebook servers, multi-tenant\npipelines. An attacker can read any file the process user has access to:\n`/etc/passwd`, `.env` files, private keys, `~/.aws/credentials`, etc.\n\n## Suggested Fix\n\n**File:** `nltk/data.py` — `FileSystemPathPointer.open()` (lines 378–390)\n\n### What's wrong\n\nLine 387 compares `normpath(self._path)` against itself — always equal,\nso the `ValueError` never fires. The check is dead code.\n`__init__` already calls `abspath()` on construction, so re-running\n`normpath` inside `open()` changes nothing either.\n\n---\n\n### Fix\n\nValidate against the actual list of permitted data directories instead:\n```python\ndef open(self, encoding=None):\n import nltk.data as _d\n allowed = [os.path.abspath(p) for p in _d.path if p]\n if allowed and not any(\n os.path.commonpath([self._path, r]) == r for r in allowed\n ):\n raise ValueError(\n f\"Access outside nltk_data blocked: {self._path!r}\"\n )\n stream = open(self._path, \"rb\")\n if encoding is not None:\n stream = SeekableUnicodeStreamReader(stream, encoding)\n return stream\n```\n\n---\n\n### Why `commonpath` not `startswith`\n\n`startswith` is bypassable by a path that shares a prefix:\n```\n/tmp/nltk_data_evil\".startswith(\"/tmp/nltk_data\") → True ✗\ncommonpath([\"/tmp/nltk_data_evil\", \"/tmp/nltk_data\"]) → \"/tmp\" ✓\n```\n\n---\n\n### Diff\n```diff\n- path = os.path.normpath(self._path)\n- if os.path.isabs(path) and path != os.path.normpath(self._path):\n- raise ValueError(f\"Direct absolute file access blocked: {path}\")\n-\n+ import nltk.data as _d\n+ allowed = [os.path.abspath(p) for p in _d.path if p]\n+ if allowed and not any(\n+ os.path.commonpath([self._path, r]) == r for r in allowed\n+ ):\n+ raise ValueError(f\"Access outside nltk_data blocked: {self._path!r}\")\n stream = open(self._path, \"rb\")\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "nltk"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.10.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.9.3"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/security/advisories/GHSA-72r2-7mfr-5xr9"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-65915"
}, {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/pull/3522"
}, {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/commit/69db9911fdba914ceeaca7aec6e892d1b14586a9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nltk/nltk"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3731.yaml"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/a510de7b-ffaf-4a83-9bf8-fa7e63f4bd2d"
}, {
"type" : "WEB",
"url" : "https://www.vulncheck.com/advisories/nltk-before-arbitrary-file-read-via-filesystempathpointer"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-284" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-08T15:27:12Z",
"nvd_published_at" : null
}
}