/

CVE-2026-68771

Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization (CWE-502) in ComfyUI Load Node

CVE-2026-68771

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

ComfyUI v0.23.0 contains an unsafe deserialization flaw in the LoadTrainingDataset node that allows crafted pickle files to be deserialized using torch.load without safety constraints.

By uploading a malicious .pkl shard via unauthenticated endpoints and referencing it in a queued workflow, an attacker can cause arbitrary Python code execution in the ComfyUI process context.

Affected context

This vulnerability appears in ComfyUI deployments that expose the image upload and workflow queuing endpoints over a network, such as in remote or shared inference environments.

It is most relevant when:

  • The /upload/image endpoint accepts pickle-backed dataset shards
  • The LoadTrainingDataset node is available in user workflows
  • torch.load is used to deserialize uploaded files within the ComfyUI runtime

Risk increases where the ComfyUI process runs with elevated permissions or has access to sensitive data or internal services.

Exploit preconditions

  • Attack surface: HTTP API endpoints, specifically unauthenticated POST requests to /upload/image and /prompt
  • Required access: Network reachability to the ComfyUI instance; no authentication needed under default exposure
  • Trigger point: A workflow graph that uses LoadTrainingDataset and references an attacker-uploaded shard_*.pkl file, causing torch.load to deserialize it
  • Why exploitation is possible: Pickle deserialization via torch.load implicitly trusts file contents and invokes special methods like __reduce__, enabling arbitrary object construction and code execution when the payload is attacker-controlled

Why this happens

The core issue is the use of a general-purpose, code-capable serialization format (Python pickle) for data loading in a context where inputs can be supplied by unauthenticated users.

The LoadTrainingDataset node invokes torch.load on user-uploaded .pkl shards, which internally uses pickle deserialization and executes constructors and reducer functions embedded in the payload.

This aligns with CWE-502: Unsafe Deserialization, where untrusted data is deserialized into live objects without validation, sandboxing, or format restrictions, turning the deserialization step into an execution vector rather than a pure data transformation.

Potential impact

  • Remote execution of arbitrary Python code within the ComfyUI process
  • Reading, modifying, or deleting data accessible to the ComfyUI runtime
  • Lateral movement to other services or hosts reachable from the ComfyUI server
  • Tampering with model weights, training data, or inference output
  • Use of the compromised host for further attacks, such as launching malware or pivoting inside the network

General mitigation guidance

Effective mitigation focuses on avoiding insecure deserialization patterns and reducing trust in user-provided artifacts.

Recommended general approaches include:

  • Replacing pickle-based workflows with data formats that cannot encode executable objects (e.g., JSON, protocol buffers, or domain-specific binary formats)
  • Introducing strict validation and whitelisting for files consumed by training or dataset-loading nodes, ensuring they match expected schemas and types
  • Segregating upload and processing paths so that user-supplied files are never directly fed into deserialization APIs capable of executing code
  • Running ComfyUI with least privilege, minimizing filesystem and network access to limit impact if deserialization is abused
  • Enforcing authentication and authorization on all upload and workflow queuing endpoints to restrict who can introduce new artifacts into the system

How teams detect issues like this

Detection typically centers on identifying unsafe deserialization usage and monitoring runtime behavior.

Useful strategies include:

  • Static analysis rules that flag calls to pickle.load, pickle.loads, or torch.load on data originating from HTTP requests or other untrusted sources
  • Code review practices that require explicit justification and documentation when using executable serialization formats like pickle
  • Runtime logging and anomaly detection around file uploads and dataset loading operations, focusing on unusual .pkl file patterns or unexpected workflow graphs
  • Host-level monitoring for suspicious child processes, file changes, or network connections initiated by the ComfyUI process
  • Incorporating automated security scanning tools into CI pipelines to enforce policies on deserialization APIs and high-risk data flows

Sources

SourceLink
github.comgithub.com/Comfy-Org/ComfyUI
github.comgithub.com/Comfy-Org/ComfyUI/commit/94ee49b1612824366a8631ea069b2a1fa5c73720
github.comgithub.com/Comfy-Org/ComfyUI/pull/14543
vulncheck.comvulncheck.com/advisories/comfyui-unauthenticated-rce-via-loadtrainingdataset-pickle-deserialization

Frequently asked

questions

It can be internet-exposed if the ComfyUI HTTP endpoints are reachable from external networks and remain unauthenticated. In that case, a remote attacker can exploit it without local access.

No, exploitation is possible using unauthenticated POST requests to the upload and workflow queuing endpoints in typical configurations where those endpoints are not guarded.

The safest approach is to eliminate pickle-based deserialization of user-supplied data entirely, replacing it with non-executable data formats and ensuring only trusted, prevalidated artifacts are loaded by training or dataset nodes.

Design systems so that untrusted inputs are never processed by APIs that can instantiate executable code, enforce strict data schemas, and require authentication and least privilege on endpoints that accept or reference user-uploaded files. Regular security reviews and static analysis rules for deserialization APIs add an additional safety net.

Find out what's already
exploitable in your codebase.