CVE-2025-66469
JSON

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 packageVersionsReported by
zauberzeug nicegui< 3.4.0, before 3.4.0CVE List, NVD
nicegui (PyPI)before 3.4.0GitHub Advisory Database, PyPA Advisory Database

All scores

GitHub_M6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
GitHub6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
PyPA Advisory Database6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Classification

CWE-79

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, or ui.add_sass with 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

SourceRecordLicence
CVE ListCVE-2025-66469 changed 2025-12-09CVE Terms of Use
GitHub Advisory DatabaseGHSA-72qc-wxch-74mg changed 2026-07-07CC-BY-4.0
NVDCVE-2025-66469 changed 2026-10-19Public domain
PyPA Advisory DatabasePYSEC-2026-1697 changed 2026-07-07CC-BY-4.0