Back to skill

Security audit

Comfyui Workflow Generator

Security checks for vulnerabilities and agentic risk

Overview

This ComfyUI workflow generator is mostly purpose-aligned, but it has unsafe model-loading defaults and overly broad file-writing controls that users should review before installing.

Install only if you are comfortable running this inside your ComfyUI environment. Use trusted, local model and tokenizer files, avoid Hugging Face model directories that require custom code, leave catalog/output paths at safe defaults, and do not enable workflows from untrusted sources with custom filename_prefix or catalog_directory values.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T08 · Insecure Dependencies

Error
Location
utils/model_loaders/huggingface_loader.py:80
Finding

Arbitrary Python Code Execution Through Trusted Model and Tokenizer Code

Content
View full analysis

Vulnerability Details

File Location: utils/model_loaders/huggingface_loader.py:80-84, 123, 130-149; utils/model_loaders/gguf_loader.py:164-185
Vulnerability Type: Untrusted model-supplied code execution
Risk Level: High

Vulnerable Code

utils/model_loaders/huggingface_loader.py:

python
load_kwargs = {
    "dtype": torch_dtype,
    "trust_remote_code": True,
    "attn_implementation": attn_impl,
}

if device_preference == "cpu":
    load_kwargs["device_map"] = {"": "cpu"}
    logging.debug("Using CPU only")
elif device == "cuda":
    load_kwargs["device_map"] = "auto"
    if max_memory is not None:
        load_kwargs["max_memory"] = max_memory
        logging.debug("Using CUDA with device_map='auto' and max_memory limits")
    else:
        logging.debug("Using CUDA with device_map='auto' (automatic GPU/CPU split)")
else:
    load_kwargs["device_map"] = {"": "cpu"}
    logging.debug("Using CPU only")

load_kwargs.update(kwargs)

self.model = AutoModelForCausalLM.from_pretrained(model_path, **load_kwargs)
python
tokenizer_path_abs = os.path.abspath(tokenizer_load_path) if not os.path.isabs(tokenizer_load_path) else tokenizer_load_path

if os.path.exists(tokenizer_path_abs) and os.path.isdir(tokenizer_path_abs):
    try:
        self.tokenizer = AutoTokenizer.from_pretrained(
            tokenizer_path_abs,
            trust_remote_code=True,
            local_files_only=True
        )
    except (HFValidationError, Exception) as e:
        if isinstance(e, HFValidationError) or "Repo id must use alphanumeric" in str(e):
            logging.warning(f"Tokenizer path validation error, retrying with explicit local path handling: {e}")
        else:
            logging.warning(f"Failed to load tokenizer with local_files_only=True: {e}")
        logging.warning("Trying without local_files_only...")
        self.tokenizer = AutoTokenizer.from_pretr
...[truncated 3671 chars]
Remediation
View remediation

Remediation Suggestions

  1. Set trust_remote_code=False for all model and tokenizer loads.
  2. Enforce local_files_only=True consistently and fail closed rather than retrying without it.
  3. Validate that model and tokenizer paths resolve beneath approved ComfyUI model directories.
  4. Allowlist supported model architectures and reject configurations requiring arbitrary custom Python.
  5. Pin approved model revisions and publish cryptographic hashes for all expected model and tokenizer files.
  6. Verify model files before loading and warn on unexpected Python files such as modeling_*.py or tokenization_*.py.
  7. If custom model code is indispensable, make it an explicit, disabled-by-default option with a clear code-execution warning.
  8. Run custom model code in a separately sandboxed process without credentials, unnecessary filesystem access, or unrestricted network access.

T09 · Insecure Skill Coding Practices

Error
Location
utils/file_utils.py:16
Finding

Output Directory Escape Through Unsanitized Workflow Filename Prefix

Content
View full analysis

Vulnerability Details

File Location: nodes/workflow_builder_node.py:48-52, 101-104, 166-170; utils/file_utils.py:16-82
Vulnerability Type: Path traversal and arbitrary file creation
Risk Level: High

Vulnerable Code

nodes/workflow_builder_node.py:

python
inputs=[
    io.String.Input("workflow_edges", force_input=True, tooltip="Input diagram from Step 1 or Step 2."),
    io.String.Input("catalog_directory", default="catalog", tooltip="Directory containing node catalog files."),
    io.Boolean.Input("save_workflow", default=True, tooltip="Save workflow to file."),
    io.String.Input(
        "filename_prefix",
        default="generated_workflow",
        tooltip="Filename prefix or path for saved workflow."
    ),
]
python
if save_workflow and COMFYUI_AVAILABLE:
    try:
        output_dir = folder_paths.get_output_directory()
        file_path = save_workflow_json(
            workflow_json,
            filename_prefix,
            output_dir
        )
        logging.info(f"WorkflowGenerator WorkflowBuilder: Workflow saved to {file_path}")
    except Exception as e:
        logging.warning(f"Failed to save workflow: {e}")

utils/file_utils.py:

python
original_input = filename_prefix.strip()
ends_with_slash = original_input.endswith("/") or original_input.endswith("\\")

normalized_input = original_input.replace("\\", "/").lstrip("/")
normalized_input = normalized_input.rstrip("/")

if "/" in normalized_input:
    parts = normalized_input.split("/")
    parts = [p for p in parts if p]
    if len(parts) > 1:
        subdirectory = "/".join(parts[:-1])
        base_filename = parts[-1]
    else:
        subdirectory = parts[0] if parts else ""
        base_filename = "generated_workflow"
else:
    if ends_with_slash or not normalized_input:
        subdirectory = normalized_input if normalized_input else ""
        base
...[truncated 3224 chars]
Remediation
View remediation

Remediation Suggestions

  1. Reject absolute paths, drive-qualified paths, UNC paths, empty components, . components, and .. components.
  2. Restrict filename_prefix to a conservative allowlist such as letters, digits, spaces, underscores, and hyphens.
  3. If subdirectories are required, validate every path component separately.
  4. Canonicalize the output root and target parent before writing:
python
from pathlib import Path

output_root = Path(output_dir).resolve()
target_parent = (output_root / safe_subdirectory).resolve()

if not target_parent.is_relative_to(output_root):
    raise ValueError("Output path escapes the configured output directory")
  1. Revalidate containment after directory creation to mitigate symlink-based escapes.
  2. Open files using safe exclusive creation mode, such as "x", to prevent accidental replacement.
  3. Add tests covering ../, mixed separators, absolute paths, Windows drive paths, UNC paths, encoded separators, and symlink traversal.

T09 · Insecure Skill Coding Practices

Error
Location
nodes/update_catalog_node.py:42
Finding

Arbitrary Catalog Directory Permits Unrestricted JSON File Creation and Truncation

Content
View full analysis

Vulnerability Details

File Location: nodes/update_catalog_node.py:42-61, 79-115; config/config.py:55-95; cataloging/catalog.py:326-355
Vulnerability Type: Unrestricted filesystem write path
Risk Level: High

Vulnerable Code

nodes/update_catalog_node.py:

python
inputs=[
    io.String.Input(
        "catalog_directory",
        default="catalog",
        tooltip="Directory to save catalog files."
    ),
    io.Boolean.Input(
        "force_update",
        default=False,
        tooltip="Force update even if files exist."
    ),
]
python
@classmethod
def validate_inputs(cls, catalog_directory: str = "", **kwargs) -> bool | str:
    """
    Validate inputs before execution.

    Returns:
        True if valid, or error message string if invalid
    """
    # Paths are validated during execution, no pre-validation needed
    return True
python
custom_node_path = get_custom_node_path()
catalog_dir = resolve_config_path(catalog_directory, custom_node_path)

node_list_path = os.path.join(catalog_dir, "node_list.json")
node_info_db_path = os.path.join(catalog_dir, "node_info.json")

result = update_node_catalog(
    node_list_path=node_list_path,
    node_info_db_path=node_info_db_path,
    force_update=force_update,
    progress_callback=progress_callback,
)

config/config.py:

python
def resolve_config_path(path: str, base_path: Path | None = None) -> str:
    if base_path is None:
        base_path = get_custom_node_path()

    if os.path.isabs(path) and os.path.exists(path):
        return path

    if path.startswith("custom_nodes/"):
        from ..utils.model_manager import get_comfyui_base_path

        comfyui_base = get_comfyui_base_path()
        if comfyui_base:
            full_path = comfyui_base / path
            if full_path.exists():
                return str(full_path)
            r
...[truncated 3869 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the arbitrary catalog_directory input unless there is a documented operational requirement for it.
  2. Store catalogs in a fixed extension-owned directory, such as <extension>/catalog.
  3. If configurable storage is required, canonicalize the path and enforce containment beneath an approved catalog root.
  4. Reject absolute paths, traversal components, drive-qualified paths, UNC paths, and symlink escapes.
  5. Implement validation in validate_inputs and repeat validation immediately before each write.
  6. Write to temporary files within the approved directory and atomically replace the intended catalog files only after successful serialization.
  7. Avoid destructive truncate() calls until the replacement catalog has been fully generated and validated.
  8. Add tests for absolute paths, ../ traversal, mixed separators, symlink destinations, nonexistent external directories, and permission failures.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
Findings (35)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Initializing HuggingFace causal language models, loading tokenizers from local or compatible sources, and performing model.generate represents hidden inference behavior not reflected in the skill description. That discrepancy matters because local model and tokenizer loading can touch untrusted files, consume significant system resources, and expose host configuration details without clear user awareness.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

Initializing HuggingFace causal language models, loading tokenizers from local or compatible sources, and performing model.generate represents hidden inference behavior not reflected in the skill description. That discrepancy matters because local model and tokenizer loading can touch untrusted files, consume significant system resources, and expose host configuration details without clear user awareness.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

Initializing HuggingFace causal language models, loading tokenizers from local or compatible sources, and performing model.generate represents hidden inference behavior not reflected in the skill description. That discrepancy matters because local model and tokenizer loading can touch untrusted files, consume significant system resources, and expose host configuration details without clear user awareness.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Initializing HuggingFace causal language models, loading tokenizers from local or compatible sources, and performing model.generate represents hidden inference behavior not reflected in the skill description. That discrepancy matters because local model and tokenizer loading can touch untrusted files, consume significant system resources, and expose host configuration details without clear user awareness.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

Initializing HuggingFace causal language models, loading tokenizers from local or compatible sources, and performing model.generate represents hidden inference behavior not reflected in the skill description. That discrepancy matters because local model and tokenizer loading can touch untrusted files, consume significant system resources, and expose host configuration details without clear user awareness.

Content

No source excerpt is available for this finding.

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · cataloging/catalog.py (reported line 319)May include surrounding context.

python
Args:
        node_list_path: Path to save node list JSON
        node_info_db_path: Path to save node info database JSON
        force_update: If True, overwrite existing files

    Returns:
        Dictionary with update statistics

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The loader passes trust_remote_code=True to AutoModelForCausalLM.from_pretrained, which allows execution of arbitrary Python code supplied by a model repository during load time. In a skill whose purpose is only to generate ComfyUI workflows, this capability is not necessary and creates a supply-chain RCE path if a model path or repo is untrusted or compromised.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

Tokenizer loading also uses trust_remote_code=True, enabling repository-provided tokenizer code to execute during initialization. Because tokenizers may be fetched from local-looking paths or remote identifiers, this extends the attack surface and can lead to arbitrary code execution from a malicious or tampered model source.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
80% confidence
Finding

The skill metadata declares no explicit tool scope even though the analyzed implementation reportedly uses environment access plus file read/write capabilities. Undeclared capabilities weaken least-privilege controls and make it harder for users or platforms to assess what the skill can actually touch at runtime.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest description and body text are written entirely in Chinese and present the skill as Chinese-language only, with no indication that users may choose another language. This can violate language/locale policy when a skill implicitly enforces a specific language without user opt-in or a documented regional justification.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest describes a workflow generator that converts natural-language prompts into ComfyUI workflows via a generation/validation/build pipeline. This file instead scans the local ComfyUI runtime for all available node classes and persists a node catalog to JSON and TinyDB, which is a separate cataloging/indexing subsystem rather than workflow generation itself.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code creates directories, writes a JSON file, truncates an existing TinyDB database, and inserts new records. While logging is present, there is no explicit user-facing confirmation prompt or warning in the function docstring/comments about overwriting catalog data when force_update is used or when the database is truncated.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The validator collects and returns debug_info["llm_prompts"], which can contain the full rendered LLM prompt including the user's description and workflow diagram. Returning this data creates a straightforward leakage path to callers, logs, UIs, or downstream telemetry, exposing potentially sensitive natural-language content beyond what is needed for normal operation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

In local-model mode, the code embeds the full user workflow description and full diagram directly into the prompt sent to the model. Even if the model runs locally, this still creates a sensitive-data exposure channel because prompts may contain secrets, proprietary workflow logic, file paths, or personal data, and there is no minimization, masking, or explicit consent boundary in this component.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The prompt construction explicitly serializes the full user description and workflow diagram into model input, which amplifies the exposure risk because the same content can be surfaced in model-side traces, exceptions, debug output, or the returned debug_info. In a workflow-generation skill, prompts may encode private automation logic, internal node names, or user-supplied secrets, so unnecessary inclusion increases confidentiality risk.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The top-level docstring and class docstring repeatedly describe output as "workflow diagrams" and specifically "JSON edge lists." However, the prompt template at L105 asks the model to generate a "ComfyUi workflow" JSON example, and post-processing only checks that the parsed result is a list, without validating that it is actually an edge list. This is an intent/documentation mismatch rather than a mere omission.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

This code writes a generated workflow file to disk when save_workflow is enabled, but the only disclosure is an internal log message after the save succeeds. There is no confirmation prompt, no pre-action user-facing notice in the execution flow, and no comment/docstring here warning that running the node may persist files to the output directory.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The code loads tokenizers with trust_remote_code=True and, on fallback paths, may resolve non-local Hugging Face identifiers. This can execute untrusted Python from a model repository during tokenizer initialization, which is unnecessary risk for a workflow-generation skill and especially dangerous if tokenizer_path is user-influenced or auto-detected from untrusted model assets.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

When local tokenizer loading fails, the code retries without local_files_only, which can silently trigger outbound network access to Hugging Face. This creates supply-chain and privacy risk by contacting external services unexpectedly, and in combination with trust_remote_code=True can escalate from silent fetches to execution of repository-provided code.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The code enables remote custom code execution for model loading without any user-facing warning, consent gate, or documented security boundary. This increases the likelihood that operators will load untrusted repositories believing they are only downloading weights, when they may actually be executing arbitrary Python code.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Tokenizer loading likewise permits execution of custom code with no specific warning or approval step. Since users often regard tokenizers as low-risk metadata, the lack of warning makes accidental execution of malicious repository code more likely.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · wiki/Installation.md (reported line 282)May include surrounding context.

md
**Requirements:**
- **Windows:** Visual Studio Build Tools with C++ support
- **Linux:** build-essential package (`sudo apt install build-essential`)
- Be patient - the compilation will complete

---

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This markdown file states that generated workflows can be loaded or saved and that by default they will be saved in comfyUI/output, but it does not clearly warn users that the skill may write files to local storage. Because file writes can affect user data or system state, the description should disclose this behavior more explicitly.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: setuptools has 10 known advisory(ies) (CVE-2013-1633 (Setuptools vulnerable to Man-in-the-middle attacks); CVE-2025-47273 (setuptools has a path traversal vulnerability in PackageIndex.download that lead); CVE-2024-6345 (setuptools vulnerable to Command Injection via package URL) +7 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
40% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: scikit-learn has 6 known advisory(ies) (CVE-2020-13092 (scikit-learn Deserialization of Untrusted Data); CVE-2024-5206 (scikit-learn sensitive data leakage vulnerability); CVE-2020-28975 (scikit-learn Denial of Service) +3 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
40% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.