{"id":"CVE-2026-21872","aliases":["CVE-2026-21872","GHSA-m7j5-rq9j-6jj9","PYSEC-2026-1701"],"related":[],"kind":"vulnerability","state":"published","title":"NiceGUI apps are vulnerable to XSS which uses `ui.sub_pages` and render arbitrary user-provided links","summary":"NiceGUI is a Python-based UI framework. From versions 2.22.0 to 3.4.1, an unsafe implementation in the click event listener used by ui.sub_pages, combined with attacker-controlled link rendering on the page, causes XSS when the user actively clicks on the link. This issue has been patched in version 3.5.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"NiceGUI is a Python-based UI framework. From versions 2.22.0 to 3.4.1, an unsafe implementation in the click event listener used by ui.sub_pages, combined with attacker-controlled link rendering on the page, causes XSS when the user actively clicks on the link. This issue has been patched in version 3.5.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nAn unsafe implementation in the `click` event listener used by `ui.sub_pages`, combined with attacker-controlled link rendering on the page, causes an XSS when the user actively clicks on the link. \n\n### Details\n\n1. On `click`, eventually `sub_pages_navigate` event is emitted.\nhttps://github.com/zauberzeug/nicegui/blob/59fa9424c470f1b12c5d368985fa36e21fda706b/nicegui/elements/sub_pages.js#L41-L63\n\n2. SubPagesRouter (used by ui.sub_pages), lisnening on `sub_pages_navigate`, `_handle_navigate` runs.\nhttps://github.com/zauberzeug/nicegui/blob/59fa9424c470f1b12c5d368985fa36e21fda706b/nicegui/sub_pages_router.py#L18-L22\n\n3. `_handle_navigate` runs `run_javascript` with f-string substituting `self.current_path` which is simply surrounded by double-quotes. The string context can be broken out easily. \n\nhttps://github.com/zauberzeug/nicegui/blob/59fa9424c470f1b12c5d368985fa36e21fda706b/nicegui/sub_pages_router.py#L73-L88\n\n### PoC\n\nThe minimal PoC boils down to this:\n\n```py\nfrom nicegui import ui\n\nui.sub_pages({'/': lambda: ui.link('Go to XSS', '/\"+alert(1)+\"')})\n\nui.run()\n```\n\nHowever, it is more likely that the attack takes place with attacker-controlled input, for which this shows it:\n\n```py\nfrom nicegui import app, ui\n\nui.sub_pages({'/': lambda: ui.label('Hello, World!')})\n\nui.textarea('Markdown content').bind_value(app.storage.general, 'markdown_content')\n\nui.markdown().bind_content_from(app.storage.general, 'markdown_content')\n\nui.run()\n```\n\nVulnerable input is `[XSS LINK](/\"+alert(document.domain)+\")` (causes double payload execution, though)\n\n**Both cases require someone to click on the link.** \n\n<img width=\"1428\" height=\"254\" alt=\"image\" src=\"https://github.com/user-attachments/assets/8be4f345-c0cf-4df2-9917-677a2ea72626\" />\n\n### Impact\n\nAny page which uses `ui.sub_pages` and renders arbitrary links on screen (common case of `ui.markdown`) is affected.\n\nThe impact is low since a click is always required from the user, who can on-hover to discover the sketchy content of the link and stop if well-trained. \n\n### Appendix\n\nAI is used safely to judge the CVSS scoring (input is not even provided, just the impact statement).\n\nPlease find the results in https://poe.com/s/y5DvyqgtszDGLUuHin1O\n\n### Scoring update after manual review\n\n- Scope **Changed** is more inline with other posted XSS vulnerabilities\n- Availability **None**: No DDoS is possible with this. Site remains performant as ever.","format":"markdown","source":"ghsa"},{"lang":"es","text":"NiceGUI es un framework de interfaz de usuario (UI) basado en Python. Desde las versiones 2.22.0 hasta la 3.4.1, una implementación insegura en el oyente de eventos de clic utilizado por ui.sub_pages, combinada con la renderización de enlaces controlada por el atacante en la página, causa XSS cuando el usuario hace clic activamente en el enlace. Este problema ha sido parcheado en la versión 3.5.0.","source":"nvd"}],"published":"2026-01-08T09:50:02.801Z","modified":"2026-07-07T17:56:55.537Z","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":">= 2.22.0, < 3.5.0","status":"affected"}],"vendor":"zauberzeug","product":"nicegui","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.22.0","status":"affected","fixed":"3.5.0"}],"ecosystem":"PyPI","package":"nicegui","purl":"pkg:pypi/nicegui","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"2.22.0","fixed":"3.5.0"}],"vendor":"zauberzeug","product":"nicegui","cpe":"cpe:2.3:a:zauberzeug:nicegui:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"2.22.0","status":"affected","fixed":"3.5.0"}],"ecosystem":"PyPI","package":"nicegui","purl":"pkg:pypi/nicegui","source":"pysec"}],"references":[{"url":"https://github.com/zauberzeug/nicegui/security/advisories/GHSA-m7j5-rq9j-6jj9","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/zauberzeug/nicegui/releases/tag/v3.5.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-21872","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-m7j5-rq9j-6jj9","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-01-08T15:12:53.988Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-21872","url":"https://www.cve.org/CVERecord?id=CVE-2026-21872","licence":"CVE Terms of Use","modified":"2026-01-08T15:13:11.652Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-m7j5-rq9j-6jj9","url":"https://github.com/advisories/GHSA-m7j5-rq9j-6jj9","licence":"CC-BY-4.0","modified":"2026-07-07T17:56:55.537Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-21872","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-21872","licence":"Public domain","modified":"2026-06-17T10:19:03.980Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1701","url":"https://osv.dev/vulnerability/PYSEC-2026-1701","licence":"CC-BY-4.0","modified":"2026-07-07T17:46:58.650Z"}],"updatedAt":"2026-11-25T22:59:12.660Z","epss":{"score":0.00345,"percentile":0.20446,"date":"2026-11-30T12:00:22.000Z"}}