T09 · Insecure Skill Coding Practices
- Location
comfyui_generator.py:57- Finding
Untrusted Workflows Are Submitted Without a Node Allowlist
- Content
View full analysis
Vulnerability Details
File Location:
comfyui_generator.py:57-75,comfyui_generator.py:303-307; equivalent behavior also appears in__init__.py:43-58and__init__.py:130-143
Vulnerability Type: Insufficient validation of executable workflow content
Risk Level: HighVulnerable Code
python # Validate required nodes has_clip_text_encode = False has_save_image = False for node_id, node in workflow.items(): class_type = node.get('class_type') if class_type == 'CLIPTextEncode': has_clip_text_encode = True elif class_type == 'SaveImage': has_save_image = True if not has_clip_text_encode: raise ValueError("Workflow is missing the required CLIPTextEncode node") if not has_save_image: raise ValueError("Workflow is missing the required SaveImage node") return workflowThe validated workflow is subsequently submitted in its entirety:
python url = f"{COMFYUI_SERVER}/prompt" data = json.dumps({"prompt": workflow}).encode('utf-8') req = urllib.request.Request( url, data=data, headers={'Content-Type': 'application/json'} ) response = urllib.request.urlopen(req) prompt_id = json.loads(response.read())['prompt_id']Technical Analysis
Workflow validation only confirms the presence of one
CLIPTextEncodenode and oneSaveImagenode. It does not reject unknown node classes, custom nodes, dangerous input values, or additional nodes unrelated to image generation.A ComfyUI workflow is effectively executable configuration. ComfyUI custom nodes can perform filesystem operations, make network requests, load arbitrary resources, or execute other behavior implemented by installed extensions. Consequently, a caller-controlled workflow can include the two required nodes to pass validation while retaining additional unsafe nodes. The complete workflow is then sent to the ComfyUI service for execution.
Exploitability ...[truncated 1401 chars]
- Remediation
View remediation
Remediation Suggestions
- Treat workflow files as executable, trusted configuration rather than ordinary data.
- Restrict
workflow_pathto a canonicalized, administrator-controlled directory:- Resolve the path with
Path.resolve(). - Confirm that it remains beneath the approved workflow root.
- Reject symlinks and user-writable workflow files where practical.
- Resolve the path with
- Define a strict allowlist of approved
class_typevalues and reject every unknown or custom node. - Validate each permitted node's input names, types, ranges, and path values against a schema.
- Prefer immutable, pre-reviewed workflow templates. Allow callers to supply only narrowly scoped values such as prompt text and safe generation parameters.
- Run ComfyUI under a dedicated, minimally privileged account with restricted filesystem and outbound network access.
- Apply resource limits to workflow execution, including queue, memory, runtime, and GPU limits.
