---
schema_version: '1.0'
id: security-20260812-60bb8b
title: 'CVE-2025-66469: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass
  via Style Injection'
url: https://osv.dev/vulnerability/GHSA-72qc-wxch-74mg
url_hash: 60bb8b9bcc5cda511c046b147a0fcf07451df475887e3486dc9cfa1ab86514fa
canonical_url: https://osv.dev/vulnerability/GHSA-72qc-wxch-74mg
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2025-66469
- GHSA-72qc-wxch-74mg
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- nicegui
- PyPI
lang: en
published_at: '2025-12-08T21:30:20Z'
fetched_at: '2026-08-12T16:00:04.459922Z'
updated_at: '2026-08-22T14:41:29Z'
status: published
content_hash: 690b49464d24b41093a0b333bb9aff9b4dcd16f7fdc547838cf23c6ea48b79c5
content_changed_at: '2026-08-22T13:15:21.545419Z'
license_note: full
summary: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style
  Injection
summary_source: rss
summary_en: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via
  Style Injection
summary_omitted_reason: null
redistribution: true
keywords_en:
- and
- CVE
- CVE-2025-66469
- GHSA-72qc-wxch-74mg
- Injection
- library vulnerability
- nicegui
- PyPI
- Reflected
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- software security
- Style
- ui.add_css
- ui.add_sass
- ui.add_scss
- via
- XSS
entities_en:
- name: CVE
  type: data
- name: PyPI
  type: artifact
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: CVE
  type: data
- name: PyPI
  type: artifact
related_auto:
- name: Portal
  type: organization
  weight: 1.0
- name: Hugging Face
  type: organization
  weight: 1.0
computed_at: '2026-08-22T14:41:24Z'
---

# CVE-2025-66469: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection

## TL;DR
NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection

## Key Points
- cve / CVE-2025-66469 / GHSA-72qc-wxch-74mg / severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N / nicegui / PyPI

## Details
**Severity:** CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
**Advisory:** GHSA-72qc-wxch-74mg (CVE-2025-66469)

**Details:**
### 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.

```python
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).

**References:**
- https://github.com/zauberzeug/nicegui/security/advisories/GHSA-72qc-wxch-74mg
- https://nvd.nist.gov/vuln/detail/CVE-2025-66469
- https://github.com/zauberzeug/nicegui/commit/a8fd25b7d5e23afb1952d0f60a1940e18b5f1ca8
- https://github.com/zauberzeug/nicegui

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-72qc-wxch-74mg_

## Source
元記事: [CVE-2025-66469: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection](https://osv.dev/vulnerability/GHSA-72qc-wxch-74mg) — published 2025-12-08T21:30:20Z
