T09 · Insecure Skill Coding Practices
- Location
coze_image.py:13- Finding
API Token Stored Directly in Tracked Source Code
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This image-generation skill is mostly purpose-aligned, but it asks users to place an API token in source code and can download unvalidated remote content to user-chosen paths.
Review before installing. Use a virtual environment, avoid putting real API tokens in source files, prefer environment variables or a secret store, and do not include sensitive data in prompts sent to Coze. Be cautious with the -o save option because the tool downloads a remote URL without validation and writes it to the chosen path.
coze_image.py:13API Token Stored Directly in Tracked Source Code
coze_image.py:64Unrestricted Retrieval of a Server-Provided Image URL
README.md:5Unpinned Third-Party Dependency Installation
The documented behavior says the skill generates images via Coze, but the analyzed behavior reportedly also includes downloading remote images to the local filesystem and an undeclared xhs-specific generation mode. Undeclared capabilities are dangerous because users and policy engines cannot accurately assess what the skill will do, increasing the risk of silent data handling, persistence, or misuse beyond the stated purpose.
The documented design relies on transmitting prompts to an external API endpoint, which is expected functionality for this image-generation skill but still constitutes a real data egress path. Because the skill is specifically triggered by user requests to generate images, the context makes this transmission inherent to operation, but it remains risky if users are not warned that sensitive prompt content leaves the local environment.
CONFIG = { "api_token": "YOUR_COZE_API_TOKEN", # 你的 Coze API Token "workflow_id": "YOUR_WORKFLOW_ID", # 图片生成工作流 ID "api_url": "https://api.coze.cn/v1/workflow/run" }
The README instructs users to send prompts and authentication material to a third-party Coze API but does not warn that user input will be transmitted off-platform. In a skill that triggers on image-generation requests, prompts may contain sensitive business or personal data, so the lack of disclosure and handling guidance creates a real privacy and compliance risk.
The skill declares network-capable behavior but does not define any explicit tool scope, permissions, or allowed-tools boundaries. In an agent setting, this makes the operational surface ambiguous and can allow unintended outbound requests or future capability creep without clear policy constraints.
The skill instructs sending user-provided prompts to an external Coze API but does not explicitly warn the user that their input will leave the local environment. This creates a privacy and compliance risk because users may include sensitive, personal, or proprietary content in prompts without informed consent.
Broad trigger phrases like '生成图片' or 'AI画图' are underspecified and may cause the skill to activate in contexts the user did not intend, especially in multi-tool agent environments. Unintended invocation can lead to accidental external data transmission, API usage, or execution of side effects without sufficiently specific user confirmation.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
BACKGROUND_IMAGE_URL = "https://p9-bot-workflow-sign.byteimg.com/tos-cn-i-mdko3gqilj/96fb6aada1a947419ffee9fe8eaee153.png~tplv-mdko3gqilj-image.image"
# API 地址(通常不需要修改)
API_URL = "https://api.coze.cn/v1/workflow/run"
# ==================================================
CONFIG = {
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
BACKGROUND_IMAGE_URL = "https://p9-bot-workflow-sign.byteimg.com/tos-cn-i-mdko3gqilj/96fb6aada1a947419ffee9fe8eaee153.png~tplv-mdko3gqilj-image.image"
# API 地址(通常不需要修改)
API_URL = "https://api.coze.cn/v1/workflow/run"
# ==================================================
CONFIG = {
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
print(f"Prompt: {prompt[:50]}...")
try:
response = requests.post(
CONFIG["api_url"],
headers=headers,
json=payload,
Although described as a text-to-image generator, the code also writes downloaded content to any caller-supplied save_path. This expands capability to arbitrary file write within the agent's permissions, which can overwrite user files or place untrusted content in sensitive locations if the path is attacker-influenced.
The tool takes an image URL returned by a remote API and immediately fetches it again with requests.get, following redirects, without validating the hostname, scheme, or content type. That creates an SSRF-style primitive and allows the remote service controlling the response to make the agent connect to unexpected endpoints and download attacker-chosen content before writing it locally.
print(f"Downloading to: {save_path}")
# Handle redirect URLs
try:
img_response = requests.get(image_url, timeout=60, allow_redirects=True)
if img_response.status_code == 200:
os.makedirs(os.path.dirname(save_path) or ".", exist_ok=True)
with open(save_path, "wb") as f:
The prompt template explicitly instructs the model to add Chinese text ('添加文字,顶部居中用紫色字体显示标题...中间添加功能点...') regardless of user preference. This is a language-policy issue because the skill enforces a specific locale rather than offering a choice or documenting a justified region-specific limitation.
The file's natural-language instructions are presented only in Chinese, which can amount to a language/locale policy issue when no user opt-in or alternative language is offered. The content does not indicate that the skill is intentionally region-specific or that users may choose another language.
This code file includes user-facing natural-language text that fixes the tool description to Chinese ('通过 Seedream 4.5 生成图片'). The policy allows locale constraints only when users are given a choice or the restriction is clearly justified; this file does not provide either.
The manifest says the skill is triggered for generic image generation requests via Coze. The CLI exposes a separate 'xhs' mode that constructs a specialized prompt for Xiaohongshu-style feature-card images, which is a specific extra capability not reflected in the skill description.