---
schema_version: '1.0'
id: security-20260812-87257b
title: 'CVE-2025-53354: NiceGUI has a Reflected XSS'
url: https://osv.dev/vulnerability/PYSEC-2026-1699
url_hash: 87257bda8d207abcd9814d7afe163975413c19878ac9e1401e099a3f7cef12df
canonical_url: https://osv.dev/vulnerability/PYSEC-2026-1699
source: osv:pypa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2025-53354
- PYSEC-2026-1699
- 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: '2026-07-07T16:03:06Z'
fetched_at: '2026-08-12T16:00:04.497091Z'
updated_at: '2026-08-22T14:41:30Z'
status: published
content_hash: 3da46f2d700bce55dd90325ed259cc932da15ee15e49036824bf1e1b6bbacd5d
content_changed_at: '2026-08-22T13:15:21.584855Z'
license_note: full
summary: NiceGUI has a Reflected XSS
summary_source: rss
summary_en: NiceGUI has a Reflected XSS
summary_omitted_reason: null
redistribution: true
keywords_en:
- CVE
- CVE-2025-53354
- has
- Hashbrown
- library vulnerability
- nicegui
- PyPI
- PYSEC-2026-1699
- Reflected
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- software security
- XSS
entities_en:
- name: CVE
  type: data
- name: Hashbrown
  type: creature
- name: PyPI
  type: artifact
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: CVE
  type: data
- name: PyPI
  type: artifact
- name: Hashbrown
  type: creature
related_auto:
- name: Portal
  type: organization
  weight: 1.0
- name: Hugging Face
  type: organization
  weight: 1.0
- name: Alexa Munoz
  type: UNKNOWN
  weight: 1.0
- name: Helen Woodward Animal Center
  type: organization
  weight: 1.0
- name: Lee Asher
  type: person
  weight: 1.0
computed_at: '2026-08-22T14:41:29Z'
---

# CVE-2025-53354: NiceGUI has a Reflected XSS

## TL;DR
NiceGUI has a Reflected XSS

## Key Points
- cve / CVE-2025-53354 / PYSEC-2026-1699 / 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:** PYSEC-2026-1699 (CVE-2025-53354)

**Details:**
### 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.chat_message` with HTML content.

Applications that directly reflect user input via `ui.html()` (or `ui.chat_message` 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.chat_message()`. 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:", on_change=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:", on_change=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.chat_message()` with HTML content from user input

**References:**
- https://github.com/zauberzeug/nicegui/security/advisories/GHSA-8c95-hpq2-w46f
- https://nvd.nist.gov/vuln/detail/CVE-2025-53354
- https://github.com/zauberzeug/nicegui/commit/4673dc35c94a0c7339e2164378b0977332e60775
- https://github.com/zauberzeug/nicegui
- https://pypi.org/project/nicegui
- https://github.com/advisories/GHSA-8c95-hpq2-w46f

_Data: OSV.dev (upstream: pypa) — https://osv.dev/vulnerability/PYSEC-2026-1699_

## Source
元記事: [CVE-2025-53354: NiceGUI has a Reflected XSS](https://osv.dev/vulnerability/PYSEC-2026-1699) — published 2026-07-07T16:03:06Z
