{"vuln_id":"GHSA-xmfg-f9cm-w86q","aliases":["CVE-2026-126302"],"description":"NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases","published_at":"2026-11-16T14:47:23Z","modified_at":"2026-11-16T14:47:24Z","first_seen_at":"2026-11-21T19:15:20.340380Z","severity":"medium","severity_source":"ghsa","cvss_score":6.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N","cwe":["CWE-22","CWE-59"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-xmfg-f9cm-w86q"},"matched_alias":null,"items":[{"id":2610,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-xmfg-f9cm-w86q / CVE-2026-126302: NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases","summary":"NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases\n\n## Summary\n\n`nltk.sem.chat80.sql_query()` opens a SQLite database by handing the result of `nltk.data.find(dbname)` straight to `sqlite3.connect()` without the path-containment check that the NLTK data sandbox (`nltk.pathsec`) is meant to enforce. `nltk.data.find()` applies only lexical checks to the resource name and returns a `FileSystemPathPointer` whose path is normalized with `os.path.abspath` but never resolved for symlinks. As a result, an in-root symbolic link that points at a SQLite file outside every registered NLTK data root is followed by SQLite, and the caller receives query results from the out-of-sandbox database. An attacker who can place a file inside a directory the application trusts as an NLTK data root can read SQLite databases that the pathsec sandbox is supposed to keep out of reach.\n\n## Root Cause\n\nThe security invariant is that file access performed through NLTK data resolution must stay within the configured data roots; the sandbox enforces this in `nltk.pathsec` via `validate_path` and `pathsec.open`, which resolve the real path (`Path(...).resolve()`) and reject targets outside the allowed roots. `sql_query()` never reaches that enforcement point. It calls `nltk.data.find(dbname)`, whose guards operate purely on the resource-name string, and `FileSystemPathPointer.__init__` performs only `os.path.abspath` plus an existence check, which does not collapse symlinks. The pointer is then passed to `sqlite3.connect(str(path))`, so the containment decision that `FileSystemPathPointer.open()` would delegate to `pathsec.open` is bypassed entirely. The sibling functions in the same module that create or write databases (`cities2table`, `val_dump`, `val_load`) obtain their protection from a validation call in later development, but the read sink `sql_query` performs no equivalent check in any published release.\n\n```text\nnltk/sem/chat80.py  -> sql_query(): path = nltk.data.find(dbname); sqlite3.connect(str(path))\nnltk/data.py        -> find(): lexical name guards only; returns FileSystemPathPointer\nnltk/data.py        -> FileSystemPathPointer.__init__(): os.path.abspath + os.path.exists (no symlink resolution)\nnltk/data.py        -> FileSystemPathPointer.open() -> nltk.pathsec.open (the containment guard that sql_query never calls)\n```\n\n## Impact\n\nAn attacker who can write into a directory the application registers as an NLTK data root (a shared or writable corpus directory, or a downloaded corpus) can plant a symbolic link at the expected resource location that points at a SQLite database elsewhere on the filesystem. When the application invokes `sql_query()` (directly or via `sql_demo()`) for that resource, SQLite follows the link and the query executes against the out-of-sandbox database, returning its rows to the caller. This escapes the pathsec confidentiality boundary. The read primitive is bounded to SQLite-format files that are readable by the process user: a non-SQLite target raises `sqlite3.DatabaseError` rather than lea\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-xmfg-f9cm-w86q","published_at":"2026-11-16T14:47:23Z","updated_at":"2026-11-16T14:47:24Z","fetched_at":"2026-11-21T19:15:18.416973Z","severity":"medium","cvss_score":6.5,"epss":0.00199,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-126302","vuln_ids":["CVE-2026-126302","GHSA-XMFG-F9CM-W86Q"],"tags":["ghsa","pip","CWE-22","CWE-59"],"cluster_id":2669,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2610","html":"https://vulnwatch.ve1ve2.com/item/2610"}}]}