NiceGUI has a Reflected XSS
Summary
A Cross-Site Scripting (XSS) risk exists in NiceGUI when developers render unescaped user input into the DOM using ui.html(). Before version 3.0, NiceGUI does not enforce HTML or JavaScript sanitization, so applications that directly combine components like ui.input() with ui.html() without escaping may allow attackers to execute arbitrary JavaScript in the user’s browser. Same holds for ui.chat_message with HTML content.
Applications that directly reflect user input via ui.html() (or ui.chat_message in HTML mode) are affected. This may lead to client-side code execution (e.g., session hijacking or phishing). Applications that do not pass untrusted input into ui.html() are not affected.
Details
NiceGUI allows developers to bind user input directly into the DOM using ui.html() or ui.chat_message(). However, the library does not enforce any HTML or JavaScript sanitization, which potentially creates a dangerous attack surface for developers unaware of this behavior.
The vulnerable code path appears when combining these:
ui.input("XSS Input:", on_change=inject)
def inject(e):
ui.html(f'{e.value}')
In this setup, any input provided by the user is rendered verbatim into the page’s DOM via innerHTML, enabling injection of script-based payloads.
PoC (Proof of Concept)
-
Create a simple app:
pythonfrom nicegui import ui @ui.page('/') def main(): def inject(e): ui.html(f'{e.value}') # vulnerable use ui.input("XSS Input:", on_change=inject) ui.run() -
Run the app:
bashpython app.py -
In the browser, input the following payload:
html<img src=x onerror=alert('XSS')> -
Observe the JavaScript alert popup:
XSS
Impact
- Vulnerability type: Reflected Cross-Site Scripting (XSS)
- Attack vector: User input rendered as raw HTML
- Affected users: Any NiceGUI-based application using
ui.html()orui.chat_message()with HTML content from user input
Betroffene Software
Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.
| Plattform | Paket | Anfällige Versionen | Behoben in |
|---|---|---|---|
| Python (PyPI) | nicegui | < 3.0.0 | 3.0.0 |
Verweise
- https://github.com/zauberzeug/nicegui/security/advisories/GHSA-8c95-hpq2-w46f
- https://nvd.nist.gov/vuln/detail/CVE-2025-53354
- https://github.com/zauberzeug/nicegui/commit/4673dc35c94a0c7339e2164378b0977332e60775
- https://github.com/zauberzeug/nicegui
- https://pypi.org/project/nicegui
- https://github.com/advisories/GHSA-8c95-hpq2-w46f
- CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N- Schwäche (CWE)
CWE-79- Plattform
- Python (PyPI)
- Paket
nicegui- Veröffentlicht
- 03.10.2025
- Aktualisiert
- 11.10.2026 13:19
Quellen und Lizenzen
OSV / GitHub Advisory Database - PYSEC-2026-1699 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-8c95-hpq2-w46f - CC BY 4.0
Schwachstellenhistorie: nicegui
Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.
- Einträge insgesamt
- 17
- Erste → letzte
- 04.2024 05.2026
- Ohne Fix
- 0
- In Angriffen ausgenutzt
- 0
Verteilung nach Schweregrad
- Hoch 6
- Mittel 11
Veröffentlichungen pro Jahr
- 2024: 1
- 2025: 5
- 2026: 11
-
NiceGUI has a Reflected XSS dieser Eintrag
Erkennen Sie Schwachstellen in Ihrer Anwendung
Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.