Sanaan Fayaz Wani

Comfy-Org/ComfyUI

CVE-2026-56671

Path traversal in /experiment/models/preview allows arbitrary image file read

CVE-2026-56671

7.5

High

CVSS 3.1 base

  1. 2026-07-15Published by the maintainer

What to do

If you run ComfyUI before 0.28.0, upgrade to 0.28.0 or later.

Anyone who can reach it over the network, with no account and no user interaction, can read sensitive data.Read from the CVSS 3.1 vector

CVSS 3.1 metrics

To exploit it

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None

What it gets

Confidentiality
High
Integrity
None
Availability
None
Scope
Unchanged

Open this vector in the FIRST calculator ↗

Weakness
CWE-22 Improper Limitation of a Pathname to a Restricted Directory
CVE
CVE-2026-56671
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Also in ComfyUI
CVE-2026-56673 7.5

My analysis of this finding: root cause, the vulnerable code, the impact and the fix, in the site’s format. The official advisory of record is linked above.

Affected versions

Package Ecosystem Vulnerable Fixed in
ComfyUI pip < 0.28.0 0.28.0

Summary

ComfyUI exposes an experimental model preview route that joins an attacker controlled path segment straight into os.path.join() with no containment check. By percent encoding the traversal sequence (%2e%2e%2f for ../), I could step out of the model directory and have the server read, render and return arbitrary image files from the host filesystem. This was co-discovered with the CISA coordinated disclosure (VU#150407) and assigned CVE-2026-56671.

Where it lives

The handler is in app/model_manager.py, route /experiment/models/preview/{folder}/{path_index}/{filename:.*}:

@routes.get("/experiment/models/preview/{folder}/{path_index}/{filename:.*}")async def get_model_preview(request):    folder_name = request.match_info.get("folder", None)    path_index = int(request.match_info.get("path_index", None))    filename = request.match_info.get("filename", None)     if folder_name not in folder_paths.folder_names_and_paths:        return web.Response(status=404)     folders = folder_paths.folder_names_and_paths[folder_name]    folder = folders[0][path_index]    full_filename = os.path.join(folder, filename)     previews = self.get_model_previews(full_filename)

The bugpath_index indexes the folder list with no bounds checkThe bugjoins the attacker path segment with no containment check

filename comes from the {filename:.*} match, which captures everything including slashes. There is no commonpath check before the join, unlike the rest of ComfyUI’s file code (for example get_save_image_path() in folder_paths.py, which does validate containment).

The trick that makes it reachable is that aiohttp normalizes real ../ segments in the path but does not decode %2f as a separator during that normalization. So a fully percent encoded payload survives routing and lands in the handler decoded:

GET /experiment/models/preview/checkpoints/0/%2e%2e%2f%2e%2e%2fetc%2fpasswd
  -> filename = "../../etc/passwd"
  -> os.path.join(folder, "../../etc/passwd")  # escapes the model folder

Impact

Every ComfyUI endpoint is unauthenticated by default, so this is a pre-auth primitive. The resolved path is handed to PIL and re-encoded to WEBP before being returned, which gives a reliable read of any image file the server process can open, anywhere on disk. In a multi-user or shared deployment that means reading other users’ generated outputs and input uploads, and the 200 versus 404 response acts as a file-existence oracle for probing filesystem layout.

Two secondary defects sit in the same handler: path_index is cast with int() and indexed with no bounds check, so an out-of-range value throws and returns a 500 (an unauthenticated DoS), and a negative index reaches unexpected directories.

Fix

Resolve the candidate path and confirm it stays inside the intended folder before touching it:

full_filename = os.path.abspath(os.path.join(folder, filename))if os.path.commonpath((os.path.abspath(folder), full_filename)) != os.path.abspath(folder):    return web.Response(status=400)

The fixresolves the joined path before checking itThe fixrejects resolved paths that leave the model folder

The same commonpath discipline already used in get_save_image_path() should apply here, and path_index needs a range check before it indexes folders[0].

The record

Weakness
CWE-22 Improper Limitation of a Pathname to a Restricted Directory
Affected
ComfyUI before 0.28.0
Fixed in
0.28.0
Disclosure
2026-07-15 Published
Advisory
GHSA-pj59-g5vv-74q4
CVE-2026-56671
Also in ComfyUI
CVE-2026-56673 7.5

About this writeup

Sanaan Fayaz Wani (GitHub sfwani) reported this vulnerability to the ComfyUI maintainers under coordinated disclosure and is credited as a reporter in GHSA-pj59-g5vv-74q4, published 2026-07-15.

All published findings: advisory index.