Summary
ComfyUI contained a stored cross-site scripting (XSS) flaw where uploaded SVG files were rendered inline at the /view endpoint without treating them as potentially dangerous content types.
If an attacker can upload or influence SVG content, they could persist malicious scripts that execute in users' browsers whenever the affected files are viewed within the ComfyUI origin.
Affected context
This vulnerability arises in ComfyUI deployments that allow users or automated processes to upload image assets that are later viewed through the /view endpoint.
The issue specifically involves SVG and related XML-based image content types that are displayed inline in the browser, rather than being treated as potentially active content.
It becomes relevant in environments where multiple users share the same ComfyUI origin or where uploaded assets are reused, linked, or previewed within the web interface.
Exploit preconditions
- Attack surface: Web-based
/viewendpoint serving uploaded files - Required access: Ability to upload or otherwise cause storage of SVG/XML image content accessible via
/view - Trigger point: A victim user visits a page or resource in ComfyUI that renders the crafted SVG inline under the ComfyUI origin
- Why exploitation is possible: SVG files are capable of embedding script-like behavior, and the lack of dangerous-content-type handling for
image/svg+xmlallows these files to be served in a way that the browser executes embedded scripts in the page context
Why this happens
The underlying issue is a failure to treat script-capable image types, such as image/svg+xml, as potentially dangerous content that must be sanitized or isolated.
ComfyUI's dangerous-content-type handling did not include SVG and related XML content types, so uploaded SVGs were served inline through the /view endpoint.
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-controlled SVG data is embedded into pages without proper neutralization or containment, allowing arbitrary script execution in the browser.
Potential impact
- Malicious scripts can execute in the context of the ComfyUI web origin
- Attackers may steal session data or user-specific tokens accessible via the browser
- User interface manipulations could deceive users into performing unintended actions
- Stored payloads can affect multiple users who later view or interact with the compromised SVG assets
General mitigation guidance
Effective mitigation focuses on reducing trust in user-supplied content and constraining how active content types are handled.
Common defensive patterns include:
- Treating
image/svg+xmland related XML-based content types as potentially dangerous and serving them with headers that prevent inline execution (for example, downloading instead of rendering) - Applying server-side sanitization or transformation to uploaded SVGs to strip active or script-like elements
- Restricting which file types can be uploaded, favoring inert raster formats where appropriate
- Enforcing a clear separation between untrusted content and the main application origin, such as serving untrusted assets from a distinct, locked-down domain or path
- Applying least-privilege principles to browser-accessible data, avoiding exposure of sensitive information through client-side scripts
How teams detect issues like this
High-level detection approaches for this class of issue include:
- Static and dynamic review of routes that serve user-uploaded files, focusing on content-type handling and response headers
- Code review checks for inline rendering of SVG or XML-based image formats without sanitization or containment
- Security testing that attempts to upload crafted SVG payloads and observes whether scripts execute when viewed in the UI
- Automated tooling or CI policies that flag additions to file-serving endpoints which do not treat script-capable types as dangerous

