nicegui
Affected
- introduced
0, fixed3.0.0(ecosystem)
Fixed versions
3.0.0
Fix
- Fixed version
3.0.0pip install --upgrade nicegui==3.0.0
Advisory
Also known as: CVE-2025-53354, GHSA-8c95-hpq2-w46f
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)
from 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()
python app.py
<img src=x onerror=alert('XSS')>
XSS
Impact
ui.html() or ui.chat_message() with HTML content from user inputMedium Basis: CVSS v3 score 6.1, vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
0, fixed 3.0.0 (ecosystem)3.0.0
3.0.0pip install --upgrade nicegui==3.0.0Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: PyPA Advisory Database · CC BY 4.0