6.1medium
NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection
- Severity
- 6.1medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.29% (higher than 23% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-72qc-wxch-74mgPYSEC-2026-1697
Description
NiceGUI is a Python-based UI framework. Versions 3.3.1 and below are vulnerable to Reflected XSS through its ui.add_css, ui.add_scss, and ui.add_sass functions. The functions 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. This issue is fixed in version 3.4.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| zauberzeug nicegui | < 3.4.0, before 3.4.0 | CVE List, NVD |
| nicegui (PyPI) | before 3.4.0 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| GitHub | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| PyPA Advisory Database | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
NiceGUI is a Python-based UI framework. Versions 3.3.1 and below are vulnerable to Reflected XSS through its ui.add_css, ui.add_scss, and ui.add_sass functions. The functions 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. This issue is fixed in version 3.4.0.
GitHub Advisory Database
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><img src=x onerror=alert(document.domain)><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).
NVD (es)
NiceGUI es un framework de interfaz de usuario (UI) basado en Python. Las versiones 3.3.1 e inferiores son vulnerables a XSS Reflejado a través de sus funciones ui.add_css, ui.add_scss y ui.add_sass. Las funciones carecen de una sanitización o codificación adecuada para el contexto de JavaScript que generan. Un atacante puede escapar de las etiquetas <style> o [script_tag] previstas inyectando etiquetas de cierre (por ejemplo, </style> o </script>), lo que permite la ejecución de JavaScript arbitrario. Este problema se ha solucionado en la versión 3.4.0.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-66469 changed 2025-12-09 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-72qc-wxch-74mg changed 2026-07-07 | CC-BY-4.0 |
| NVD | CVE-2025-66469 changed 2026-10-19 | Public domain |
| PyPA Advisory Database | PYSEC-2026-1697 changed 2026-07-07 | CC-BY-4.0 |