Miggo Logo

CVE-2025-53354: NiceGUI has a Reflected XSS

6.1

CVSS Score
3.1

Basic Information

EPSS Score
-
Published
10/3/2025
Updated
10/3/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
niceguipip< 3.0.03.0.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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
This constructor is responsible for rendering HTML content. Before the patch, it directly rendered the provided `content` string as HTML without any form of sanitization. If an attacker could control this content, they could inject malicious scripts, leading to a reflected Cross-Site Scripting (XSS) vulnerability. The vulnerable implementation made it easy for developers to unknowingly introduce this flaw by passing unsanitized user input to this element.
nicegui.elements.chat_message.ChatMessage.__init__
nicegui/elements/chat_message.py
This constructor is used to create chat messages. When the `text_html=True` parameter was used, the function would render the message content as raw HTML by using the `nicegui.elements.html.Html` element internally without sanitization. This created an XSS vulnerability if the chat message content was derived from user input. The patch addresses this by requiring an explicit `sanitize` option, preventing the default unsafe behavior.

WAF Protection Rules

WAF Rule

### Summ*ry * *ross-Sit* S*riptin* (XSS) risk *xists in Ni***UI w**n **v*lop*rs r*n**r un*s**p** us*r input into t** *OM usin* `ui.*tml()`. ***or* v*rsion *.*, Ni***UI *o*s not *n*or** *TML or J*v*S*ript s*nitiz*tion, so *ppli**tions t**t *ir**tly *

Reasoning

T** vuln*r**ility is * *l*ssi* R**l**t** *ross-Sit* S*riptin* (XSS) issu* wit*in t** Ni***UI *r*m*work. T** root **us* li*s in t** `ui.*tml()` *n* `ui.***t_m*ss***()` *ompon*nts, w*i** *r* wr*pp*rs *roun* t** `*tml` *n* `***tM*ss***` *l*ss*s r*sp**ti