/

CVE-2026-56672

Severity:

HIGH RISK

(8.2)

Stored XSS (CWE-79) in ComfyUI userdata endpoint

CVE-2026-56672

Awaiting Analysis

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Stored Cross-Site Scripting leading to token theft and account takeover

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A stored cross-site scripting (XSS) flaw in ComfyUI's /userdata endpoint allowed user-uploaded HTML and SVG files to be served with executable content types.

When a victim visited these file URLs, attacker-controlled scripts ran in the ComfyUI origin, exposing browser-stored API tokens, settings, and enabling authenticated-equivalent actions.

Affected context

The vulnerability arises in ComfyUI deployments that expose the /userdata/{file} route and permit users or external tools to upload arbitrary content into the userdata directory.

The handler directly served files via web.FileResponse(path) and relied on file extensions to derive MIME types, meaning .html and .svg uploads were returned as text/html and image/svg+xml.

In environments where users can share or bookmark /userdata URLs, other users or operators could be tricked into opening these URLs, causing untrusted scripts to execute within the ComfyUI web origin.

Exploit preconditions

  • Attack surface: HTTP interface of ComfyUI, specifically the GET /userdata/{file} endpoint.
  • Required access: Ability to upload or otherwise place files into the userdata directory via POST /userdata or equivalent mechanisms.
  • User interaction: A victim must be induced to browse to the malicious /userdata/{file} URL (e.g., via shared links, bookmarks, or embedded frames).
  • Why exploitation is possible: The server reflects user-controlled files with extension-derived content types, allowing HTML/SVG content to be interpreted as active web documents in the same origin as the main ComfyUI application.

Why this happens

The core issue is that untrusted, user-controlled content is being served as active web pages under the same origin as the application.

By using web.FileResponse(path) and trusting file extensions to determine MIME types, the /userdata handler turns uploaded .html and .svg files into fully executable documents.

This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where untrusted data is delivered to a browser in a way that allows script execution in a trusted origin.

Conceptually, the bug is an unsafe content-hosting pattern: a user content bucket is exposed without forcing downloads or isolating it under a separate origin, thus collapsing the trust boundary between application code and user content.

Potential impact

  • Malicious scripts can read and exfiltrate browser-stored API tokens associated with ComfyUI.
  • Attackers may access or modify user settings, workflows, and other sensitive data accessible through the ComfyUI API.
  • Execution of authenticated-equivalent API calls, potentially automating or manipulating workflows on behalf of the victim.
  • Persistent compromise of a user's ComfyUI environment when shared links or widely distributed URLs are used.
  • Potential pivot to broader account or environment misuse if ComfyUI tokens are reused elsewhere.

General mitigation guidance

Effective mitigation focuses on isolating or deactivating active content in user-controlled storage areas.

Typical defensive patterns include:

  • Forcing potentially dangerous MIME types (such as text/html, image/svg+xml, and other script-capable types) to be delivered as downloads or with a safe, non-executable content type.
  • Serving user-uploaded files from a separate origin or domain so that scripts, if any, cannot access primary application cookies or APIs.
  • Applying strict allowlists for file types that may be rendered inline and treating all other content as attachments.
  • Adding a default Content-Security-Policy that restricts inline scripts and limits the ability of user-controlled pages to execute arbitrary code, recognizing that CSP is a defense-in-depth measure rather than a sole control.
  • Minimizing the storage of high-value secrets in browser-accessible contexts and favoring scoped or short-lived tokens with least privilege.

How teams detect issues like this

Detection often relies on recognizing unsafe content serving patterns during development and review.

Example approaches include:

  • Static analysis checks and linting rules that flag frameworks or helpers (like generic file response handlers) when they serve content directly from user-controlled directories.
  • Code reviews that specifically look for endpoints exposing file systems, download handlers, or "user content" directories without MIME-type or origin isolation.
  • Automated security tests that upload HTML/SVG payloads and confirm whether they execute as active documents in the application origin.
  • Logging and monitoring for unusual access patterns to /userdata paths, especially URLs that appear to be shared or accessed by multiple users.

Sources

SourceLink
github.comgithub.com/Comfy-Org/ComfyUI/commit/96e0e3585b41e1417442eaa14ec57f7b4ffcb5e0
github.comgithub.com/Comfy-Org/ComfyUI/releases/tag/v0.28.0
github.comgithub.com/Comfy-Org/ComfyUI/security/advisories/GHSA-53g8-45wq-pcv8

Frequently asked

questions

Yes. If ComfyUI is exposed over a network, a remote attacker who can upload files (or influence the userdata directory) and share links can cause victims to load malicious pages and execute scripts in their browsers.

The attacker needs the ability to store or upload arbitrary content into the userdata directory, typically via POST /userdata or an equivalent mechanism. They also need a way to get a victim to visit the generated /userdata/{file} URL.

The safest pattern is to prevent user-controlled files from being rendered as active documents in the main application origin. This can be achieved by forcing dangerous MIME types to download, serving user content from an isolated origin, and applying strict MIME-type and extension allowlists.

Design user-content features with clear trust boundaries: avoid hosting arbitrary user files under the same origin as sensitive application interfaces, enforce conservative MIME-type handling by default, integrate security-focused code reviews for new file-serving endpoints, and use automated tests or tools to probe for executable user content.

Find out what's already
exploitable in your codebase.