CVE-2025-66469: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection
Summary A Cross-Site Scripting (XSS) vulnerability exists in ui.addcss, ui.addscss, and ui.addsass functions in NiceGUI (v3.3.1 and earlier). These functions allow developers to inject styles dynamically. However, they lack proper sanitization or encoding for the JavaScript context they generate.
Published Dec 8, 2025 · Updated Dec 9, 2025
Affected packages
nicegui
- Ecosystem
- PyPI
- Affected
- <= 3.3.1
- Fixed in
- 3.4.0
- Check
pip show nicegui
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
A Cross-Site Scripting (XSS) vulnerability exists in ui.add_css, ui.add_scss, and ui.add_sass functions in NiceGUI (v3.3.1 and earlier).
These functions allow developers to inject styles dynamically. However, they lack proper sanitization or encoding for the JavaScript context they generate. An attacker can break out of the intended <style> or <script> tags by injecting closing tags (e.g., </style> or </script>), allowing for the execution of arbitrary JavaScript.
Details
The vulnerability stems from how these functions inject content into the DOM using client.run_javascript (or add_head_html internally) without sufficient escaping for the transport layer.
- `ui.add_css`: Injects content into a
<style>tag. Input containing</style>closes the tag prematurely, allowing subsequent HTML/JS injection. - `ui.add_scss` / `ui.add_sass`: These rely on client-side compilation within
<script>tags. Input containing</script>breaks the execution context, allowing XSS.
PoC
Scenario: A developer allows users to customize a theme color via a URL parameter.
from nicegui import ui
@ui.page('/')
def main(color: str = 'blue'):
# Vulnerable implementation of dynamic theming
ui.add_css(f'.q-btn {{ background-color: {color} !important; }}')
ui.button('Click Me')
ui.run(port=8082)Attack Vector: Accessing the following URL executes arbitrary JavaScript: http://localhost:8082/?color=red;}</style><style>
Impact
- Type: Reflected XSS
- Severity: Moderate
- Affected Components: Applications using
ui.add_css,ui.add_scss, orui.add_sasswith untrusted input (e.g., dynamic theming based on user input).
Credited to twmoon, evnchn, falkoschindler.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-45553
NiceGUI: Local file disclosure via Docutils file insertion in ui.restructured_text()
high7.5May 18, 2026CVE-2026-45554
NiceGUI: Unauthenticated log-volume denial of service in dynamic resource routes
medium5.3May 18, 2026CVE-2026-39844
NiceGUI: Upload filename sanitization bypass via backslashes allows path traversal on Windows
medium5.9Apr 8, 2026CVE-2026-33332
NiceGUI's unvalidated chunk size parameter in media routes can cause memory exhaustion
medium5.3Mar 19, 2026CVE-2026-27156
NiceGUI vulnerable to XSS via Code Injection during client-side element function execution
medium6.1Feb 24, 2026CVE-2026-25516
NiceGUI's XSS vulnerability in ui.markdown() allows arbitrary JavaScript execution through unsanitized HTML content
medium6.1Feb 5, 2026
