T09 · Insecure Skill Coding Practices
- Location
scripts/civitai.py:284- Finding
CivitAI Bearer Token Can Be Disclosed to an Arbitrary Download Host
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is mostly a local ComfyUI/CivitAI automation tool, but it gives chat-triggered workflows broad local process, network, credential, and file-write authority without enough scoping or safeguards.
Review before installing. Use this only in a controlled local environment, remove the catch-all Discord trigger, make Discord posting opt-in, bind ComfyUI to localhost, replace the all-python shutdown with PID-scoped shutdown, and harden CivitAI downloads so tokens are sent only to approved CivitAI hosts and files cannot be written outside the intended model directory.
scripts/civitai.py:284CivitAI Bearer Token Can Be Disclosed to an Arbitrary Download Host
scripts/civitai.py:287Model Download Filename Allows Writes Outside the Checkpoint Directory
scripts/comfyui_manager.py:45ComfyUI Shutdown Forcefully Terminates All Windows Python Processes
scripts/comfyui_manager.py:24ComfyUI API Is Bound to All Network Interfaces Without Access Controls
scripts/comfyui_manager.py:27Unescaped Configuration Values Are Interpolated into a PowerShell Command
The trigger conditions are so broad that any message in the designated Discord art channel activates the skill, even when the user did not intend to start local generation or model operations. This increases the chance of unauthorized or accidental execution of resource-intensive actions and can be abused to repeatedly start workloads.
声明描述覆盖了较广的功能:ComfyUI 画图工作流 + CivitAI 集成,包含模型搜索/下载/更新检查/自动调参,以及文生图/图生视频。提供的代码片段只包含一个生成脚本:读取配置,构建 ComfyUI prompt,调用本地 API /api/prompt 和 /api/queue,等待任务完成后从本地输出目录获取最新 PNG 图片。它没有任何与 CivitAI 相关的网络请求、搜索、下载、模型更新检查代码,也没有视频生成或图生视频流程;也未看到真正的自动参数优化逻辑。虽然“本地 ComfyUI 生成图片”这一部分与声明部分吻合,但整体声明显著高于代码实际行为,因此属于描述与行为不一致,且主要是过度声明功能。
The activation rules include broad keyword triggers and a catch-all condition for any message in a Discord art channel, which can cause the skill to run on unrelated or accidental messages. In this skill's context, unintended invocation is more dangerous because execution may start local services, generate content, download models, or send outputs externally.
The workflow states that generated images are sent to a specific Discord channel, but the description does not prominently warn users that outputs will be transmitted off the local machine. Because image prompts and outputs may contain sensitive, personal, or NSFW content, automatic posting creates a substantial privacy and compliance risk if users expect purely local generation.
The stop behavior kills every Python process on the machine, which is substantially broader than 'control local ComfyUI' and can cause denial of service against unrelated software. Because this is a local agent skill intended for routine image generation, users are unlikely to expect or consent to host-wide termination of Python workloads.
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
},
}
return prompt
def submit(prompt: dict) -> str:
The file presents the skill specification and user-facing trigger guidance entirely in Chinese, including operational expectations for invocation. This can constitute a language policy issue when the skill appears intended for broader use but does not offer user language choice or explain that it is restricted to a Chinese-speaking environment.
Code issues a request to a loopback, link-local, or private-range host. This can reach internal services not meant to be exposed and is a common SSRF pivot.
import json, urllib.request
data = json.dumps({"prompt": prompt_dict}).encode()
req = urllib.request.Request("http://localhost:8188/api/prompt", data=data, headers={"Content-Type": "application/json"})
resp = urllib.request.urlopen(req)
The shutdown command Get-Process python ... | Stop-Process -Force indiscriminately kills all Python processes on the host, far exceeding the skill’s intended scope of managing a single ComfyUI instance. In this environment, that could terminate unrelated services, developer jobs, bots, or security tooling, causing denial of service and possible data loss.
The design allows automatic start and stop of a local process without any user-facing notice or confirmation. Silent process management can surprise users, consume local GPU/CPU resources, and make it easier for a remote chat message to manipulate host state without informed consent.
The design says generated images are automatically sent to Discord but does not warn users that prompts and outputs will be posted to a channel. That creates privacy and content-disclosure risk, especially if users assume generation is local/private or include sensitive prompts or images.
The skill declares executable behaviors spanning shell, network, file read/write, and environment access, but provides no explicit tool scope or permission boundary. That makes the effective privilege set ambiguous and increases the chance the agent can start processes, download files, and modify local state without clear user consent or policy enforcement.
The manifest description and operational instructions are written as if the skill is intended for Chinese-language triggering and channel use, with no indication that users may choose another language. This can be a language/locale policy issue when a skill effectively constrains interaction language without opt-in or documented justification.
The skill advertises CivitAI integration including download and config update operations but does not surface a prominent warning that it may retrieve remote model files and modify local configuration. Remote downloads and automatic local changes materially affect system integrity and storage, and users may not realize those side effects from the top-level description.
This code performs safety-relevant actions by stopping ComfyUI and deleting the .last_used file, but there is no confirmation prompt, no warning log before the action, and no explanatory comment describing user impact beyond internal control-flow notes. For a code file, these operations qualify as destructive or state-changing behavior that should include some form of user disclosure.
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.
return os.environ.get("CIVITAI_API_KEY", "")
def _api_get(endpoint, params=None, use_auth=False):
"""Make a GET request to CivitAI API using curl (more reliable than urllib).
"""
url = f"{API_BASE}/{endpoint}"
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
cmd.append(url)
result = subprocess.run(cmd, capture_output=True, text=True, timeout=20)
if result.returncode != 0:
raise RuntimeError(f"curl failed: {result.stderr}")
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def get_autov2_hash(filepath):
"""Compute AutoV2 hash (first 10 chars of SHA256, uppercase) for a model file."""
result = subprocess.run(
["sha256sum", filepath],
capture_output=True, text=True, timeout=300
)
The function places downloaded model artifacts directly into ComfyUI's checkpoints directory without an approval gate, quarantine step, or safety warning. In this skill's image-generation context, that is more dangerous than a generic file download because the downloaded artifact is likely to be consumed automatically or semi-automatically by a local ML toolchain, increasing the chance of executing or trusting unreviewed third-party content.
This code downloads attacker-controlled remote content and writes it directly to the local model directory using a URL that may come from user input or remote API data, with no allowlist, content validation, size check, or integrity verification. In the ComfyUI context, model files are high-risk artifacts because loading untrusted models can lead to downstream code execution or compromise through deserialization or plugin/model handling bugs.
cmd.append(url)
print(f"Downloading to {dest}...", file=sys.stderr)
result = subprocess.run(cmd, capture_output=True, text=True, timeout=1800)
if result.returncode != 0:
raise RuntimeError(f"Download failed: {result.stderr}")
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
f"-ArgumentList '{COMFY['main_path']}','--listen','0.0.0.0','--port','{COMFY['port']}' "
f"-WorkingDirectory '{COMFY['work_dir']}' -WindowStyle Hidden"
)
subprocess.run([POWERSHELL, "-Command", cmd], capture_output=True, timeout=15)
# 等待启动
for _ in range(timeout // 2):
The skill includes host-level process-control via PowerShell, including forceful termination capability, which expands privilege and operational scope beyond simple image-generation API integration. In this skill context, such capability is more dangerous because it can affect the broader system, not just the local ComfyUI service the user expects to control.
Force-stopping processes without any warning or confirmation increases the likelihood of accidental disruption and data loss, especially since the command affects all Python processes rather than a single managed service. In an agent-operated skill, silent destructive behavior is particularly risky because users may invoke 'stop' expecting a narrow, reversible action.
This subprocess call forcefully terminates all Python processes on the host, not just the ComfyUI instance managed by this skill. In a local automation context, that can disrupt unrelated applications, developer tools, agents, or security services, making the behavior far broader and more dangerous than the skill description suggests.
def stop() -> bool:
subprocess.run(
[POWERSHELL, "-Command",
"Get-Process python -ErrorAction SilentlyContinue | Stop-Process -Force"],
capture_output=True, timeout=10
The submit function sends the user-provided prompt content to a remote/local HTTP API via urllib without any visible confirmation prompt, print/log disclosure, or warning comment/docstring indicating that prompt text will be transmitted. Because this is a code file and the operation involves network transmission of user data, it meets the missing-warning criteria.
No suspicious patterns detected.