Summary
A stored Cross-Site Scripting (XSS) vulnerability in DeepChat's SVG handling allows attackers to execute arbitrary JavaScript in users' browsers by bypassing the SVGSanitizer with HTML entity–encoded payloads.
When a crafted SVG artifact is rendered with Vue's v-html in the SvgArtifact.vue component, the browser decodes the entities after the backend sanitizer has run, enabling unexpected script execution in victims' sessions.
Affected context
This vulnerability arises in DeepChat deployments that accept, store, or display user-provided SVG artifacts that are subsequently rendered in the browser.
The affected path involves:
- SVG content passing through
SVGSanitizer(src/main/lib/svgSanitizer.ts) which uses regex-based checks - The sanitized SVG being bound into the DOM via Vue's
v-htmlinSvgArtifact.vue
The issue appears when the browser's HTML entity decoding behavior diverges from the sanitizer's plain-text assumptions, allowing previously hidden script protocols to become active after rendering.
Exploit preconditions
- Attack surface: Web UI where SVG artifacts or images are uploaded, generated, or otherwise supplied and later viewed by other users.
- Required access: Ability to submit or influence SVG content that DeepChat will store or render (e.g., as an artifact, message attachment, or tool output).
- Trigger point: A victim user (including administrators or operators) loads a page where the malicious SVG artifact is rendered via
v-html, causing the browser to decode HTML entities and interpret script URLs. - Why exploitation is possible: The SVGSanitizer relies on plain-text regular expressions to scrub
javascript:protocols but does not normalize or decode HTML entities before validation. Vue'sv-htmlthen injects the sanitized-but-encoded SVG string into the DOM, where the browser performs entity decoding, reconstituting active script URLs that the sanitizer never saw in their executable form.
Why this happens
The underlying bug is a context mismatch between server-side/logic-layer sanitization and client-side rendering semantics.
The SVGSanitizer implements allow/deny rules using regular expressions over raw SVG strings, assuming that dangerous constructs like javascript: will appear in a straightforward textual form.
However, HTML and SVG specifications permit characters to be encoded using numeric or named entities (e.g., javascript:), which the browser decodes during DOM construction.
Because the sanitizer does not normalize or decode these entities before applying its regex checks, it fails to recognize obfuscated script URLs that become dangerous only after decoding.
This maps to CWE-79 (Improper Neutralization of Input During Web Page Generation), specifically a variant where sanitization does not align with downstream decoding and rendering behavior, leaving a gap attackers can exploit to inject script into the final page.
Potential impact
- Execution of arbitrary JavaScript in the context of the DeepChat web application.
- Theft or exposure of session tokens, API keys, or other sensitive information accessible to the victim's browser.
- Unauthorized actions performed on behalf of victims (e.g., modifying configurations, triggering agent runs, or exfiltrating chat content).
- Manipulation or poisoning of AI agent conversations, tool outputs, or stored artifacts viewed by other users.
- Establishment of long-lived browser hooks or beacons for further attacks (e.g., keylogging or cross-tenant data leakage where applicable).
General mitigation guidance
Effective mitigation typically centers on eliminating the trust gap between sanitization and rendering and avoiding unsafe DOM insertion patterns:
- Normalize and canonicalize SVG/HTML input before validation, including decoding HTML entities and URL-encoding, so sanitization logic operates on the same representation the browser will interpret.
- Use robust, context-aware SVG/HTML sanitization libraries that understand the full parsing rules of browsers, rather than relying on ad hoc regular expressions.
- Avoid direct innerHTML-style insertion (
v-html) for user-controlled or agent-generated content; prefer safe, templated rendering or DOM construction via vetted libraries. - Restrict SVG capabilities where possible by disallowing scripts, external resources, and event handlers, focusing on a minimal subset of safe elements and attributes.
- Apply a defense-in-depth model: even after sanitization, isolate untrusted content in sandboxed iframes, use strict Content Security Policy (CSP) to block inline scripts and
javascript:URLs, and limit ambient access to sensitive data. - Minimize the privileges and data accessible from any single browser context, so that a successful XSS yields the least possible damage.
How teams detect issues like this
Detection approaches can combine code-level analysis with runtime monitoring:
- Static analysis: Search for uses of
v-html,innerHTML, or similar sinks where data derived (directly or indirectly) from user or agent-controlled SVG/HTML is inserted into the DOM. Flag cases where sanitization is regex-based, lacks normalization, or does not consider entity decoding. - Pattern-based rules: Implement checks in linters or SAST tools that specifically look for
javascript:protocol handling in sanitizers and verify that canonicalization (HTML entity decoding, URL normalization) occurs before validation. - Code review signals: During manual review, treat any custom sanitizer as suspicious, especially for complex formats like SVG. Reviewers should verify that sanitization logic is aligned with browser parsing rules and that rendering uses safe patterns instead of raw HTML injection.
- Runtime monitoring: Instrument CSP violation reporting endpoints to capture attempts to load
javascript:URLs, inline scripts, or other blocked resources from pages rendering SVG artifacts, which may indicate exploitation attempts. - Automated regression tests: Maintain a suite of adversarial SVG and HTML payloads (including entity-encoded scripts) that are run against the sanitizer and UI rendering pipeline in CI to prevent reintroduction of similar flaws.

