CVE-2025-53354: NiceGUI has a Reflected XSS
6.1
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version | 
|---|---|---|---|
| nicegui | pip | < 3.0.0 | 3.0.0 | 
Vulnerability Intelligence Miggo AI
Miggo AI
 Root Cause Analysis
Root Cause Analysis
The vulnerability is a classic Reflected Cross-Site Scripting (XSS) issue within the NiceGUI framework. The root cause lies in the ui.html() and ui.chat_message() components, which are wrappers around the Html and ChatMessage classes respectively. Before the patch, these components would render raw HTML content passed to them without any default escaping or sanitization. This design meant that any application passing user-controlled input to these components was immediately vulnerable to XSS.
The investigation of the fixing commit 4673dc35c94a0c7339e2164378b0977332e60775 confirms this. The core changes are in the __init__ methods of nicegui.elements.html.Html and nicegui.elements.chat_message.ChatMessage. The patch fundamentally changes the API by introducing a mandatory sanitize parameter for both. Developers are now forced to make a security decision: either provide a sanitization function or explicitly declare the content as safe by passing sanitize=False. This change moves the library from a default-insecure to a default-secure posture, effectively mitigating the vulnerability by preventing developers from accidentally rendering unsafe user input.
Vulnerable functions
nicegui.elements.html.Html.__init__nicegui/elements/html.py
nicegui.elements.chat_message.ChatMessage.__init__nicegui/elements/chat_message.py