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:
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()Run the app:
python app.pyIn the browser, input the following payload:
<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
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
CVE-2025-53354 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.0.0); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2025-53354? CVE-2025-53354 is a medium-severity cross-site scripting (XSS) vulnerability in nicegui (pip), affecting versions < 3.0.0. It is fixed in 3.0.0. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- How severe is CVE-2025-53354? CVE-2025-53354 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of nicegui are affected by CVE-2025-53354? nicegui (pip) versions < 3.0.0 is affected.
- Is there a fix for CVE-2025-53354? Yes. CVE-2025-53354 is fixed in 3.0.0. Upgrade to this version or later.
- Is CVE-2025-53354 exploitable, and should I be worried? Whether CVE-2025-53354 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2025-53354 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2025-53354? Upgrade
niceguito 3.0.0 or later.