VulnWatch by ve1ve2
medium 6.5 EPSS 0.20%

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

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

https://github.com/advisories/GHSA-xmfg-f9cm-w86q ↗

ghsapipCWE-22CWE-59

NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases ## Summary `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. ## Root Cause The 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. ```text nltk/sem/chat80.py -> sql_query(): path = nltk.data.find(dbname); sqlite3.connect(str(path)) nltk/data.py -> find(): lexical name guards only; returns FileSystemPathPointer nltk/data.py -> FileSystemPathPointer.__init__(): os.path.abspath + os.path.exists (no symlink resolution) nltk/data.py -> FileSystemPathPointer.open() -> nltk.pathsec.open (the containment guard that sql_query never calls) ``` ## Impact An 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 Affected packages: pip:nltk Patched: nltk 3.10.4

Linked vulnerabilities (2)

CVE-2026-126302 medium 3.3 EPSS 0.20% (p10) NVDCVE.orgGHSA
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N

nltk: nltk: Information disclosure via symbolic link sandbox bypass

CWE: CWE-59, CWE-22Aliases: GHSA-xmfg-f9cm-w86q
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N

NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases

CWE: CWE-22, CWE-59Aliases: CVE-2026-126302