CVE-2025-53354: NiceGUI is vulnerable to Reflected XSS attack

Published Oct 3, 2025
·
Updated

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.chatmessage with HTML content.

Applications that directly reflect user input via ui.html() (or ui.chatmessage 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.chatmessage(). 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:

python ui.input("XSS Input:", onchange=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)

1. Create a simple app:

python from nicegui import ui

@ui.page('/') def main(): def inject(e): ui.html(f'{e.value}') # vulnerable use

ui.input("XSS Input:", onchange=inject)

ui.run()

2. Run the app:

bash python app.py

3. In the browser, input the following payload:

html <img src=x onerror=alert('XSS')>

4. 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() or ui.chatmessage() with HTML content from user input

Other sources

NiceGUI is a Python-based UI framework. Versions 2.24.2 and below are at risk for Cross-Site Scripting (XSS) when developers render unescaped user input into the DOM using ui.html(). NiceGUI did not enforce HTML or JavaScript sanitization, so applications that directly combine components like ui.input() with ui.html() or ui.chatmessage with HTML content without escaping may allow attackers to execute arbitrary JavaScript in the user’s browser. Applications that do not pass untrusted input into ui.html() are not affected. This issue is fixed in version 3.0.0.

MITRE

Affected Software

2 affected componentsFixes available
NiceGUI NiceGUI<2.24.2
pip/nicegui<3.0.0
3.0.0

Event History

Oct 3, 2025
Advisory Published
via GitHub·07:19 PM
Data Sourced
via GitHub·07:19 PM
DescriptionSeverityWeaknessAffected Software
CVE Published
via MITRE·07:32 PM
Data Sourced
via MITRE·07:32 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:15 PM
DescriptionSeverityWeakness
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-53354?

CVE-2025-53354 has a high severity due to its potential to allow cross-site scripting attacks.

2

How do I fix CVE-2025-53354?

To fix CVE-2025-53354, upgrade NiceGUI to version 3.0.0 or later.

3

What versions of NiceGUI are affected by CVE-2025-53354?

Versions of NiceGUI prior to 3.0.0 are affected by CVE-2025-53354.

4

What risks are associated with CVE-2025-53354?

CVE-2025-53354 poses a risk of executing malicious scripts in the browser, compromising user security.

5

What specific functionality in NiceGUI is responsible for CVE-2025-53354?

The risk in CVE-2025-53354 arises when developers render unescaped user input into the DOM using `ui.html()`.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203