{"id":"CVE-2026-70626","aliases":["CVE-2026-70626","GHSA-r6gq-whwq-mvg9","PYSEC-2026-3732"],"related":[],"kind":"vulnerability","state":"published","title":"NLTK before 3.9.4 Symlink Escape via CorpusReader","summary":"NLTK versions before 3.9.4 contain a symlink escape vulnerability in CorpusReader.open() that allows local attackers to read arbitrary files outside the corpus root. The vulnerability exists because path validation is lexical and does not account for symlink resolution, enabling attackers to place symlinks inside the corpus root to access files outside the intended boundary.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"NLTK versions before 3.9.4 contain a symlink escape vulnerability in CorpusReader.open() that allows local attackers to read arbitrary files outside the corpus root. The vulnerability exists because path validation is lexical and does not account for symlink resolution, enabling attackers to place symlinks inside the corpus root to access files outside the intended boundary.","source":"cvelist"},{"lang":"en","text":"### Summary\n`nltk.corpus.reader.api.CorpusReader.open()` can be used to read files outside the intended corpus root via a symlink placed inside that root. Although NLTK blocks absolute paths and `..` traversal, the current boundary check is only lexical and does not account for symlink resolution. This leads to an arbitrary local file read / filesystem sandbox bypass for applications that rely on `CorpusReader` or `FileSystemPathPointer` to restrict file access.\n\n### Details\nThe vulnerable flow is:\n\n- [`nltk/corpus/reader/api.py:222`](/mnt/Data/my_brains/test/nltk/nltk/corpus/reader/api.py#L222)\n  - `CorpusReader.open()` blocks absolute paths and `..`, then calls `self._root.join(file).open()`\n\n- [`nltk/data.py:398`](/mnt/Data/my_brains/test/nltk/nltk/data.py#L398)\n  - `FileSystemPathPointer.join()` joins the requested file ID and checks whether the resulting path still appears to remain under the configured root\n\nThe problem is that the check is based on the lexical path after `os.path.normpath()`, not on the resolved path after following symlinks.\n\nCurrent behavior:\n\n1. `CorpusReader.open()` rejects:\n   - absolute paths\n   - `..` path traversal\n2. `FileSystemPathPointer.join()` computes:\n   - `joined = os.path.normpath(os.path.join(self._path, fileid))`\n   - `root = os.path.normpath(self._path)`\n3. It allows the access if `joined` starts with `root`\n\nThis misses the case where a path stays inside the root lexically, but resolves outside the root via a symlink already present under the allowed directory.\n\nExample:\n\n```text\nJOINED=/tmp/nltk-root/link/secret.txt\nREALPATH=/tmp/outside/secret.txt\n```\n\n`JOINED` still appears to be inside the root, but `REALPATH` is outside it.\n\nThis is distinct from simple `../` traversal:\n\n- the file ID is not absolute\n- the file ID does not contain `..`\n- the escape only happens after filesystem resolution of a symlink under the allowed root\n\n### PoC\nReproduced in an isolated Docker sandbox using the local `nltk` clone.\n\nMinimal Python PoC:\n\n```python\nimport os\nimport tempfile\nfrom nltk.corpus.reader.api import CorpusReader\n\nroot = tempfile.mkdtemp(prefix=\"nltk-root-\")\noutside_dir = tempfile.mkdtemp(prefix=\"nltk-out-\")\noutside_file = os.path.join(outside_dir, \"secret.txt\")\n\nwith open(outside_file, \"w\") as f:\n    f.write(\"secret-data\")\n\nos.symlink(outside_dir, os.path.join(root, \"link\"))\n\ncorpus = CorpusReader(root, [\"link/secret.txt\"])\nwith corpus.open(\"link/secret.txt\") as f:\n    print(f.read())\n```\n\nObserved result:\n\n```text\nsecret-data\n```\n\nDocker re-test output:\n\n```text\nROOT=/tmp/nltk-root-jjxay3if\nOUTSIDE_DIR=/tmp/nltk-out-1kef36e0\nJOINED=/tmp/nltk-root-jjxay3if/link/secret.txt\nREALPATH=/tmp/nltk-out-1kef36e0/secret.txt\nREAD_OK=secret-data\nINSIDE_ROOT=True\nREAL_INSIDE_ROOT=False\n```\n\nAdditional impact validation using a system file:\n\n```text\nROOT=/tmp/nltk-root-_h5x4m19\nJOINED=/tmp/nltk-root-_h5x4m19/hostfile\nREALPATH=/etc/hostname\nHOSTNAME_READ=48dafb244af3\nINSIDE_ROOT=True\nREAL_INSIDE_ROOT=False\n```\n\nThis shows that the issue is not limited to attacker-created files outside the root; it can also read existing system files that are readable by the application user.\n\n### Impact\nThis is an arbitrary local file read / symlink escape issue.\n\nWho is impacted:\n\n- applications that accept attacker-controlled corpus directories, extracted datasets, or package contents\n- applications that rely on NLTK corpus readers as a trust boundary for file access\n- any deployment where an attacker can place or influence files inside the allowed corpus root\n\nPractical impact includes disclosure of:\n\n- application secrets stored on disk\n- local configuration files\n- private datasets\n- process-exposed files such as `/proc/self/environ`\n- system files readable by the running user\n\nThe issue is best described as a filesystem sandbox bypass caused by improper link resolution before file access.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Las versiones de NLTK anteriores a la 3.9.4 contienen una vulnerabilidad de escape de enlace simbólico en CorpusReader.open() que permite a atacantes locales leer archivos arbitrarios fuera de la raíz del corpus. La vulnerabilidad existe porque la validación de rutas es léxica y no tiene en cuenta la resolución de enlaces simbólicos, lo que permite a los atacantes colocar enlaces simbólicos dentro de la raíz del corpus para acceder a archivos fuera del límite previsto.","source":"nvd"}],"published":"2026-08-22T14:12:44.983Z","modified":"2026-10-14T13:10:00.187Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":6.2,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":6.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/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"}],"cwes":["CWE-59"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"3.9.4","status":"affected"},{"type":"semver","version":"3.9.4","status":"unaffected"}],"vendor":"nltk","product":"nltk","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.9.4"}],"ecosystem":"PyPI","package":"nltk","purl":"pkg:pypi/nltk","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.9.4"}],"vendor":"nltk","product":"nltk","cpe":"cpe:2.3:a:nltk:nltk:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.9.4"}],"ecosystem":"PyPI","package":"nltk","purl":"pkg:pypi/nltk","source":"pysec"}],"references":[{"url":"https://github.com/nltk/nltk/security/advisories/GHSA-r6gq-whwq-mvg9","tags":["evidence","exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.vulncheck.com/advisories/nltk-before-symlink-escape-via-corpusreader","tags":["advisory","third-party-advisory","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-70626","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/nltk/nltk/pull/3522","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/nltk/nltk/commit/1b0e519e2324bc1a273d56edee63e44d0ad85b48","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/nltk/nltk","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/nltk/nltk/releases/tag/3.9.4","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3732.yaml","tags":["web"],"sources":["ghsa"]}],"credits":["leduckhuong"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-08-24T19:49:24.557Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-70626","url":"https://www.cve.org/CVERecord?id=CVE-2026-70626","licence":"CVE Terms of Use","modified":"2026-08-24T19:49:30.565Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-r6gq-whwq-mvg9","url":"https://github.com/advisories/GHSA-r6gq-whwq-mvg9","licence":"CC-BY-4.0","modified":"2026-09-08T15:30:07.726Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-70626","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-70626","licence":"Public domain","modified":"2026-10-14T13:10:00.187Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-3732","url":"https://osv.dev/vulnerability/PYSEC-2026-3732","licence":"CC-BY-4.0","modified":"2026-09-01T09:15:04.067Z"}],"updatedAt":"2026-11-25T22:59:34.878Z","epss":{"score":0.00205,"percentile":0.11119,"date":"2026-12-01T12:00:22.000Z"}}