CVE-2025-53354: Nicegui Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-8c95-hpq2-w46f
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-2025-53354 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Nicegui libraries in the PyPI ecosystem. The issue involves nicegui has a reflected xss. Remediation is available by upgrading affected packages to version 3.0.0.

CVE-2025-53354 at a Glance

CVE Identifier CVE-2025-53354
GHSA Identifier GHSA-8c95-hpq2-w46f
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Nicegui
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2025-53354

To remediate this vulnerability, upgrade all affected Nicegui dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nicegui fixed: 3.0.0
pip install nicegui>=3.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show nicegui

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-53354, inspect your installed packages using pip:

pip show nicegui

Analyze the terminal output to locate any version of Nicegui in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.0), your application is affected.

Note: The pip show nicegui command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Nicegui, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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

CVE-2025-53354 Affected Nicegui Versions

1 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
nicegui
PyPI
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2025-53354?
CVE-2025-53354 is a security vulnerability in Nicegui involving NiceGUI has a Reflected XSS under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Nicegui versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: nicegui.
What version fixes CVE-2025-53354?
Upgrading to 3.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nicegui affected?
Yes, nicegui is affected in releases prior to 3.0.0. Upgrade your dependency to 3.0.0 or later.
What is the CVSS score of CVE-2025-53354?
CVE-2025-53354 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2025-53354?
CVE-2025-53354 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check PyPI dependencies for CVE-2025-53354?
Run the dependency tree command: 'pip show nicegui'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8c95-hpq2-w46f",
  "modified" : "2025-10-13T15:10:03Z",
  "published" : "2025-10-03T19:19:17Z",
  "aliases" : [ "CVE-2025-53354" ],
  "summary" : "NiceGUI has a Reflected XSS",
  "details" : "### Summary\n\nA 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.\n\nApplications 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.\n\n### Details\n\nNiceGUI 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.\n\nThe vulnerable code path appears when combining these:\n\n```python\nui.input(\"XSS Input:\", on_change=inject)\ndef inject(e):\n    ui.html(f'{e.value}')\n```\n\nIn this setup, any input provided by the user is rendered **verbatim** into the page’s DOM via innerHTML, enabling injection of script-based payloads.\n\n### PoC (Proof of Concept)\n\n1. Create a simple app:\n\n   ```python\n   from nicegui import ui\n\n   @ui.page('/')\n   def main():\n       def inject(e):\n           ui.html(f'{e.value}')  # vulnerable use\n\n       ui.input(\"XSS Input:\", on_change=inject)\n\n   ui.run()\n   ```\n\n2. Run the app:\n\n   ```bash\n   python app.py\n   ```\n\n3. In the browser, input the following payload:\n\n   ```html\n   <img src=x onerror=alert('XSS')>\n   ```\n\n4. Observe the JavaScript alert popup:\n\n   ```\n   XSS\n   ```\n\n### Impact\n\n* **Vulnerability type:** Reflected Cross-Site Scripting (XSS)\n* **Attack vector:** User input rendered as raw HTML\n* **Affected users:** Any NiceGUI-based application using `ui.html()` or `ui.chat_message()` with HTML content from user input",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "nicegui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/security/advisories/GHSA-8c95-hpq2-w46f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-53354"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/commit/4673dc35c94a0c7339e2164378b0977332e60775"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zauberzeug/nicegui"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-10-03T19:19:17Z",
    "nvd_published_at" : "2025-10-03T20:15:33Z"
  }
}