CVE-2026-21872Medium· 6.1▾ SunlitNiceGUI apps are vulnerable to XSS which uses `ui.sub_pages` and render arbitrary user-provided links
▾ Sunlit zone — Low / medium · no exploitation signal
impact 33.6 · likelihood 0.1 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
Exploit-prediction probability, daily snapshots since Jul 8.
Disclosure to exploitation, from the record and what we observed since indexing it.
Disclosed via OSV
Last analysed / modified upstream
0.2%
0.2% → 0.3%
An 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.
On click, eventually sub_pages_navigate event is emitted.
https://github.com/zauberzeug/nicegui/blob/59fa9424c470f1b12c5d368985fa36e21fda706b/nicegui/elements/sub_pages.js#L41-L63
SubPagesRouter (used by ui.sub_pages), lisnening on sub_pages_navigate, _handle_navigate runs.
https://github.com/zauberzeug/nicegui/blob/59fa9424c470f1b12c5d368985fa36e21fda706b/nicegui/sub_pages_router.py#L18-L22
_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.
The minimal PoC boils down to this:
from nicegui import ui
ui.sub_pages({'/': lambda: ui.link('Go to XSS', '/"+alert(1)+"')})
ui.run()
However, it is more likely that the attack takes place with attacker-controlled input, for which this shows it:
from nicegui import app, ui
ui.sub_pages({'/': lambda: ui.label('Hello, World!')})
ui.textarea('Markdown content').bind_value(app.storage.general, 'markdown_content')
ui.markdown().bind_content_from(app.storage.general, 'markdown_content')
ui.run()
Vulnerable input is [XSS LINK](/"+alert(document.domain)+") (causes double payload execution, though)
Both cases require someone to click on the link.
<img width="1428" height="254" alt="image" src="https://github.com/user-attachments/assets/8be4f345-c0cf-4df2-9917-677a2ea72626" />Any page which uses ui.sub_pages and renders arbitrary links on screen (common case of ui.markdown) is affected.
The 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.
AI is used safely to judge the CVSS scoring (input is not even provided, just the impact statement).
Please find the results in https://poe.com/s/y5DvyqgtszDGLUuHin1O
nicegui >= 2.22.0, < 3.5.0Upgrade to a patched release:
nicegui 3.5.0Connected by shared product, vendor, weakness, or advisory.
CVE-2026-21874Medium· 5.3NiceGUI has Redis connection leak via tab storage causes service degradation
CVE-2026-21873High· 7.2NiceGUI apps which use `ui.sub_pages` vulnerable to zero-click XSS
CVE-2026-21871Medium· 6.1NiceGUI is vulnerable to XSS via Unescaped URL in ui.navigate.history.push() / replace()
CVE-2026-39844Medium· 5.9NiceGUI: Upload filename sanitization bypass via backslashes allows path traversal on Windows
CVE-2026-33332Medium· 5.3NiceGUI's unvalidated chunk size parameter in media routes can cause memory exhaustion
CVE-2026-25516Medium· 6.1NiceGUI's XSS vulnerability in ui.markdown() allows arbitrary JavaScript execution through unsanitized HTML content