Back to skill

Security audit

Comfyui

Security checks for vulnerabilities and agentic risk

Overview

This skill mostly matches a ComfyUI image-generation purpose, but it includes high-impact behaviors users should review carefully before installing.

Install only if you are comfortable with it controlling a local ComfyUI server, writing generated images to disk, using Feishu credentials for image delivery, and downloading/running helper executables. Review or remove the pget auto-install path and the taskkill-all-python shutdown behavior before using it on a workstation with important Python jobs.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T03 · Remote Payload Retrieval and Execution

Error
Location
scripts/download_weights.py:69
Finding

Unverified Remote Executable Download and Execution

Content
View full analysis

Vulnerability Details

File Location: scripts/download_weights.py, lines 69–92 and 123–128
Vulnerability Type: Remote payload retrieval and execution without integrity verification
Risk Level: High

Vulnerable Code

python
# Install to ~/.local/bin
local_bin = os.path.expanduser("~/.local/bin")
pget_path = os.path.join(local_bin, "pget")
if os.path.isfile(pget_path) and os.access(pget_path, os.X_OK):
    return pget_path
os.makedirs(local_bin, exist_ok=True)
sysname = platform.system()
machine = platform.machine()
if machine == "aarch64":
    machine = "arm64"
elif machine == "x86_64":
    machine = "x86_64"
# Replicate releases: pget_Linux_x86_64, pget_Darwin_arm64, etc.
asset = f"pget_{sysname}_{machine}"
url = f"{PGET_RELEASE}/{asset}"
try:
    req = urllib.request.Request(url, headers={"User-Agent": "ComfyUI-Skill/1.0"})
    with urllib.request.urlopen(req, timeout=60) as resp:
        with open(pget_path, "wb") as f:
            f.write(resp.read())
    os.chmod(pget_path, 0o755)
    return pget_path
except Exception as e:
    print(f"Could not install pget ({e}); falling back to built-in download.", file=sys.stderr)
    return None
python
def download_with_pget(manifest_path: str, pget_bin: str, overwrite: bool) -> bool:
    cmd = [pget_bin, "multifile", manifest_path]
    if overwrite:
        cmd.append("-f")
    r = subprocess.run(cmd)
    return r.returncode == 0

Technical Analysis

When pget is unavailable, the script automatically retrieves a native executable from a mutable GitHub latest/download URL, writes it to ~/.local/bin/pget, grants it executable permissions, and subsequently launches it with subprocess.run().

The downloaded executable is not pinned to a specific release and is not authenticated using a hard-coded cryptographic digest or trusted digital signature. HTTPS protects data in transit but does not inde ...[truncated 1743 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not automatically install or execute pget; use the built-in Python downloader by default.
  2. Require explicit user consent before downloading any executable dependency.
  3. Pin pget to a specific reviewed release version rather than using latest.
  4. Maintain a platform-specific allowlist of expected SHA-256 hashes and verify the complete artifact before granting execute permission.
  5. Prefer verification using a trusted publisher signature in addition to hash validation.
  6. Download to a securely created temporary file, validate it, and then atomically move it into place.
  7. Reject redirects to origins outside an explicit allowlist.
  8. Remove an incomplete or invalid artifact after any download or verification failure.
  9. Document the external executable, its source, version, integrity controls, and execution behavior in the Skill documentation.
  10. Run model downloads with the lowest practical filesystem and operating-system privileges.

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/comfyui_service.py:121
Finding

ComfyUI Shutdown Forcibly Terminates All Python Processes

Content
View full analysis

Vulnerability Details

File Location: scripts/comfyui_service.py, lines 121–141
Vulnerability Type: Excessive process-control scope and violation of least privilege
Risk Level: High

Vulnerable Code

python
# 强制结束进程
if state.get("pid"):
    try:
        subprocess.run(["taskkill", "/F", "/PID", str(state["pid"])], 
                      capture_output=True, timeout=10)
    except Exception:
        pass

# 清理所有 ComfyUI 相关进程
try:
    subprocess.run(["taskkill", "/F", "/IM", "ComfyUI.exe"], 
                  capture_output=True, timeout=10)
except Exception:
    pass

try:
    subprocess.run(["taskkill", "/F", "/IM", "python.exe"], 
                  capture_output=True, timeout=10)
except Exception:
    pass

Technical Analysis

The service shutdown routine first attempts to terminate the recorded PID but then unconditionally runs taskkill /F /IM python.exe. This command is not restricted to the ComfyUI process or its descendants. It forcibly terminates every matching Python process that the caller has permission to terminate.

The behavior exceeds the declared requirement to stop the managed ComfyUI server. Unrelated Python applications, notebooks, development servers, automation agents, background jobs, and scripts can be terminated even when they have no relationship to ComfyUI.

The state file also supplies a PID without verifying that the PID still belongs to the originally launched ComfyUI process. PID reuse or modification of the state file could cause the initial PID-based termination to target an unrelated process.

Attack Path

  1. The host runs ComfyUI alongside one or more unrelated Python processes.
  2. A user, automation task, or Agent invokes comfyui_service.py stop, restart, or an automatic shutdown path that calls stop_server().
  3. The shutdown API request and recorded-PID termination are attempted.
  4. The routine unconditionally execut ...[truncated 1042 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the image-wide taskkill /F /IM python.exe command.
  2. Terminate only the process created by start_server() and, where necessary, its verified child process tree.
  3. Before terminating a stored PID, verify the process creation time, executable path, command line, and expected parent-child relationship.
  4. Protect the state file against untrusted modification and store sufficient process identity information to detect PID reuse.
  5. Prefer the ComfyUI shutdown API followed by a bounded graceful wait.
  6. If graceful shutdown fails, terminate only the validated ComfyUI PID or process tree.
  7. Do not use broad executable-name matching as a fallback.
  8. Return a clear shutdown failure instead of silently escalating to termination of unrelated processes.
  9. Avoid suppressing all exceptions so that failed validation and shutdown attempts remain visible and auditable.
  10. Add tests confirming that unrelated python.exe processes survive stop, restart, and automatic shutdown operations.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (56)

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 · CONTRIBUTING.md (reported line 48)May include surrounding context.

md
## Updating the Skill

- When ComfyUI’s API or workflow format changes, update SKILL.md and the run script.
- Keep the “If the server isn’t reachable” section in sync with current ComfyUI install/run instructions.
- Bump version when publishing a new release to ClawHub.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

This variant identifies outbound Feishu message sending that is not central to the declared capability set. External transmission of generated images or prompts creates confidentiality and privacy risk, especially when users may assume the skill is purely local.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill advertises silent Feishu sending without a clear warning that user prompts, uploaded images, and generated outputs may be transmitted automatically to an external service. This is dangerous because users may reasonably expect a local image-generation skill to keep data local, leading to privacy leakage and unauthorized disclosure.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
96% confidence
Finding

The skill communicates over HTTP with a local ComfyUI service, but the finding states network capability is not declared. Even localhost-only networking is a sensitive capability because it can interact with privileged local services and expands the attack surface beyond simple prompt processing.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
96% confidence
Finding

The skill communicates over HTTP with a local ComfyUI service, but the finding states network capability is not declared. Even localhost-only networking is a sensitive capability because it can interact with privileged local services and expands the attack surface beyond simple prompt processing.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
96% confidence
Finding

The skill communicates over HTTP with a local ComfyUI service, but the finding states network capability is not declared. Even localhost-only networking is a sensitive capability because it can interact with privileged local services and expands the attack surface beyond simple prompt processing.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The metadata explicitly advertises '飞书静默发送' (silent Feishu sending) without any user-facing warning, consent flow, or disclosure of what data may be transmitted. In an image-generation skill, prompts, generated images, workflow parameters, and possibly locally supplied input images could be sent to an external messaging platform without the user's clear awareness, creating a significant privacy and data exfiltration risk.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
100% confidence
Finding

The stop logic indiscriminately kills all python.exe processes, which is destructive and unrelated to the minimum actions needed for image-server management. Because this skill is meant to run on a local workstation with other Python-based tools likely present, the context makes the behavior more dangerous and capable of causing broad denial of service.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

Force-killing all python.exe processes without a clear warning or explicit user consent creates a high-risk destructive action that users are unlikely to anticipate from a 'stop server' command. This increases the chance of accidental termination of unrelated workloads and unsaved work.

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 · scripts/download_weights.py (reported line 173)May include surrounding context.

python
ap.add_argument(
        "--overwrite",
        action="store_true",
        help="Overwrite existing files",
    )
    ap.add_argument(
        "--no-pget",

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The changelog explicitly advertises 'Feishu silent send (NO_REPLY on success)', which indicates generated content may be transmitted to an external messaging platform without a visible user-facing confirmation or warning in this documentation. In an image-generation skill, prompts and outputs can contain sensitive business, personal, or proprietary material, so silent exfiltration-by-integration materially increases privacy and data-handling risk.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README advertises very broad natural-language triggers such as '生成图片、画图、绘制、AI 绘画、文生图、图生图', which are common phrases likely to appear in normal conversation. In an agent environment, this can cause unintended invocation of the skill, leading to unwanted local server startup, image generation, GPU consumption, and downstream actions like silent Feishu delivery without clear user intent confirmation.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger phrases are very broad everyday language such as '生成图片', '画图', and '绘制', which can cause accidental invocation in normal conversation. In a skill with Bash/exec permissions and possible outbound actions, overbroad activation increases the chance of unintended execution and unintended data handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The workflow contains a SaveImage node that writes generated outputs to disk using the prefix "z-image", but this file provides no user-facing notice, consent mechanism, or retention guidance. In an image-generation skill that can produce sensitive or adult content, silent local persistence increases privacy risk because outputs may remain on disk unexpectedly and be accessible to other local users, backups, or later automation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file’s top-level docstring, usage text, and user-facing descriptions are entirely in Chinese, which imposes a specific language on users. Under the policy, locale or language constraints should either be optional for the user or clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill can start a local executable and forcibly terminate processes, which is a sensitive host-management capability not typical of a narrow prompt-to-image helper. In this context the behavior is related to operating ComfyUI, but it still increases danger because a compromised or modified skill could abuse the same mechanism for denial of service or to run unapproved binaries.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · comfyui.py (reported line 66)May include surrounding context.

python
try:
        # 启动桌面版
        process = subprocess.Popen(
            ["G:\\comfyui\\ComfyUI.exe"],
            cwd="G:\\comfyui",
            creationflags=subprocess.CREATE_NO_WINDOW,

Static analysis

No suspicious patterns detected.