T09 · Insecure Skill Coding Practices
- Location
scripts/generate_image.py:385- Finding
Unrestricted DashScope API endpoint permits credential disclosure
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This image-generation skill mostly matches its stated purpose, but it needs review because it can send prompts, images, and API credentials to external services, including a user-configured DashScope endpoint that is not validated.
Install only if you are comfortable sending prompts and any input images to the listed external providers. Use dedicated, low-privilege API keys; keep DASHSCOPE_API_BASE to cn, sg, us, or a trusted HTTPS Aliyun endpoint; avoid sensitive images or secrets in prompts; and prefer a virtual environment with reviewed pinned dependencies.
scripts/generate_image.py:385Unrestricted DashScope API endpoint permits credential disclosure
scripts/generate_image.py:586Unvalidated image URLs permit server-side request forgery and unsafe downloads
SKILL.md:289Third-party dependencies are installed without version or integrity pinning
The skill advertises executable behavior that can read environment variables, read/write files, and make network requests, but it does not declare any explicit tool scope or permissions boundary. That weakens least-privilege controls and makes it harder for a host agent or reviewer to understand what capabilities will be exercised before activation.
The skill does not clearly warn that user prompts, and potentially local images or image URLs, will be transmitted to third-party image-generation providers across multiple platforms. This creates a privacy and data-governance risk because users may provide sensitive text or images without informed consent about external processing.
The auto-activation rules are broad enough to trigger on many ordinary image-related requests, including generic mentions of photography, posters, or Chinese support. Over-broad triggering can cause the agent to invoke a networked third-party skill unexpectedly, increasing the chance of unnecessary data disclosure and unintended file/network operations.
Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.
python ~/.claude/skills/imagenCN/scripts/generate_image.py --dry-run --platform ark "Test prompt"
python ~/.claude/skills/imagenCN/scripts/generate_image.py --list-models
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
## Config File (Optional)
Create `~/.imagenCN.json` for personal defaults, or `.imagenCN.json` in a project
directory for per-project overrides. API keys stay in environment variables for
security.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
1 — usage error (bad arguments, unknown model)
2 — auth / config error (missing or invalid API key)
3 — API error (upstream failure, rate limit, quota)
4 — I/O error (cannot write output file, download failed)
"""
import argparse
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
try:
response = requests.get(url, timeout=60)
response.raise_for_status()
output_path.write_bytes(response.content)
return True
except Exception as e:
if _FMT == "json":
This script sends user prompts and optional input images to third-party cloud providers across multiple platforms, but it does not provide an explicit privacy/disclosure warning at the point of use. In an agent or automation context, users may not realize sensitive prompts, embedded secrets, or local image contents are being transmitted to external services, which can create confidentiality and compliance risk.
At this point the script selects a remote provider endpoint as part of actual execution and later transmits user prompts and possibly input images to that external service. In the context of an agent skill, this is a genuine external data transmission risk because potentially sensitive user content leaves the local environment without an explicit just-in-time disclosure or restriction mechanism.
endpoint = "https://tokenhub.tencentmaas.com/v1/images/generations"
elif platform == "zhipu":
api_type = "Zhipu (OpenAI-compatible)"
endpoint = "https://api.z.ai/api/paas/v4/images/generations"
elif platform == "stepfun":
api_type = "StepFun (OpenAI-compatible)"
endpoint = "https://api.stepfun.com/v1/images/generations"
This execution path similarly configures an external StepFun endpoint that will receive user-supplied prompts and optional related metadata during generation. In a multi-provider skill, the expanded set of destinations increases the chance of unintentional disclosure, especially when used by automation or agents on behalf of users.
endpoint = "https://api.z.ai/api/paas/v4/images/generations"
elif platform == "stepfun":
api_type = "StepFun (OpenAI-compatible)"
endpoint = "https://api.stepfun.com/v1/images/generations"
elif model in SYNTHESIS_MODELS:
api_type = "ImageSynthesis"
endpoint = dashscope.base_http_api_url
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
name = "Hunyuan"
env_var = "HUNYUAN_API_KEY"
env_model_var = "HUNYUAN_MODEL"
api_base = "https://api.hunyuan.cloud.tencent.com/v1/images/generations"
default_model = "hy-image-v3.0"
models = {"hy-image-v3.0"}
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
name = "StepFun"
env_var = "STEP_API_KEY"
env_model_var = "STEP_MODEL"
api_base = "https://api.stepfun.com/v1/images/generations"
default_model = "step-2x-large"
models = {"step-2x-large", "step-image-edit-2"}
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
name = "StepFun"
env_var = "STEP_API_KEY"
env_model_var = "STEP_MODEL"
api_base = "https://api.stepfun.com/v1/images/generations"
default_model = "step-2x-large"
models = {"step-2x-large", "step-image-edit-2"}
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
name = "Zhipu"
env_var = "ZHIPUAI_API_KEY"
env_model_var = "ZHIPUAI_MODEL"
api_base = "https://api.z.ai/api/paas/v4/images/generations"
default_model = "cogview-4"
models = {"cogview-4", "cogview-4-250304", "glm-image"}
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
name = "Zhipu"
env_var = "ZHIPUAI_API_KEY"
env_model_var = "ZHIPUAI_MODEL"
api_base = "https://api.z.ai/api/paas/v4/images/generations"
default_model = "cogview-4"
models = {"cogview-4", "cogview-4-250304", "glm-image"}
The generate method sends the user prompt and authorization header to an external provider API. While this is functionally central to the provider, this file contains no user-visible notice, confirmation, or logging that prompt content and credentials are being sent off-host.
The download method performs a file write to an arbitrary output path, creating parent directories and saving remote content to disk. Although the docstring describes the behavior for developers, there is no user-facing confirmation, print/log disclosure, or other visible warning in this file about the write operation.
Sensitive environment-variable access is in scope for this rule when there is no warning or disclosure. Although the top-level docstring names ARK_API_KEY as required configuration, it does not explicitly warn that the skill reads and uses a secret credential for external API requests.
The function delegates to a download helper that saves data to disk, which is a file-write operation covered by the missing-warning rule for code files. This file contains no confirmation prompt, logging, or inline comment/docstring warning users that invoking this helper will write an image to the provided path.