{"id":"CVE-2025-53354","aliases":["CVE-2025-53354","GHSA-8c95-hpq2-w46f","PYSEC-2026-1699"],"related":[],"kind":"vulnerability","state":"published","title":"NiceGUI is vulnerable to Reflected XSS attack","summary":"NiceGUI is a Python-based UI framework. Versions 2.24.2 and below are at risk for Cross-Site Scripting (XSS) when developers render unescaped user input into the DOM using ui.html(). NiceGUI did not enforce HTML or JavaScript sanitization, so applications that directly combine components like ui.input() with ui.html() or  ui.chat_message with HTML content without escaping may allow attackers to execute arbitrary JavaScript in the user’s browser. Applications that do not pass untrusted input into ui.html() are not affected. This issue is fixed in version 3.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"NiceGUI is a Python-based UI framework. Versions 2.24.2 and below are at risk for Cross-Site Scripting (XSS) when developers render unescaped user input into the DOM using ui.html(). NiceGUI did not enforce HTML or JavaScript sanitization, so applications that directly combine components like ui.input() with ui.html() or  ui.chat_message with HTML content without escaping may allow attackers to execute arbitrary JavaScript in the user’s browser. Applications that do not pass untrusted input into ui.html() are not affected. This issue is fixed in version 3.0.0.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"NiceGUI es un framework de UI basado en Python. Las versiones 2.24.2 e inferiores están en riesgo de cross-site scripting (XSS) cuando los desarrolladores renderizan entrada de usuario sin escapar en el DOM usando ui.html(). NiceGUI no aplicaba la sanitización de HTML o JavaScript, por lo que las aplicaciones que combinan directamente componentes como ui.input() con ui.html() o ui.chat_message con contenido HTML sin escapar pueden permitir a los atacantes ejecutar JavaScript arbitrario en el navegador del usuario. Las aplicaciones que no pasan entrada no confiable a ui.html() no se ven afectadas. Este problema está solucionado en la versión 3.0.0.","source":"nvd"}],"published":"2025-10-03T19:19:17.000Z","modified":"2026-10-08T22:10:00.563Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 3.0.0","status":"affected"}],"vendor":"zauberzeug","product":"nicegui","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.0.0"}],"ecosystem":"PyPI","package":"nicegui","purl":"pkg:pypi/nicegui","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.0.0"}],"ecosystem":"PyPI","package":"nicegui","purl":"pkg:pypi/nicegui","source":"pysec"}],"references":[{"url":"https://github.com/zauberzeug/nicegui/security/advisories/GHSA-8c95-hpq2-w46f","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/zauberzeug/nicegui/commit/4673dc35c94a0c7339e2164378b0977332e60775","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-53354","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/zauberzeug/nicegui","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/nicegui","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-8c95-hpq2-w46f","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-10-03T19:41:55.791Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-53354","url":"https://www.cve.org/CVERecord?id=CVE-2025-53354","licence":"CVE Terms of Use","modified":"2025-10-03T19:42:40.273Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8c95-hpq2-w46f","url":"https://github.com/advisories/GHSA-8c95-hpq2-w46f","licence":"CC-BY-4.0","modified":"2026-07-07T17:57:19.036Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-53354","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-53354","licence":"Public domain","modified":"2026-10-08T22:10:00.563Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1699","url":"https://osv.dev/vulnerability/PYSEC-2026-1699","licence":"CC-BY-4.0","modified":"2026-07-07T17:46:58.212Z"}],"updatedAt":"2026-11-25T22:59:05.503Z","epss":{"score":0.00204,"percentile":0.10911,"date":"2026-12-01T12:00:22.000Z"}}