T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:84- Finding
API Key Persisted in Plaintext Configuration
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill appears to be a legitimate Volcengine image-generation helper, but it handles API keys in ways users should review before installing.
Review before installing if you would use a real Volcengine API key. Prefer `VOLCENGINE_API_KEY` or session-only entry, avoid saving the key in `config.json`, do not use the config display option with a stored key, and avoid submitting sensitive prompts or private images unless third-party processing by Volcengine is acceptable.
scripts/generate.py:84API Key Persisted in Plaintext Configuration
scripts/config.py:19Configuration Utility Can Print and Persist the Complete API Key
README.md:22Mutable Latest Package Is Downloaded and Executed During Installation
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
"""下载图片到本地"""
try:
req = urllib.request.Request(url)
with urllib.request.urlopen(req, timeout=60) as response:
img_data = response.read()
with open(output_path, 'wb') as f:
f.write(img_data)
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
print(f"正在调用 API...")
with urllib.request.urlopen(req, timeout=120) as response:
result = json.loads(response.read().decode('utf-8'))
# 处理 Images API 响应
The skill description, headings, examples, and configuration guidance are presented entirely in Chinese, which imposes a specific language on users without any opt-in or alternative locale guidance. Under the policy, a skill should not force a language or locale unless it is clearly justified as region-specific or offers user choice.
The README instructs users to run npx clawhub@latest install ..., which pulls and executes the latest remote package version at install time rather than a pinned, reviewed release. If the upstream package is compromised or a breaking/malicious version is published, users installing the skill could execute untrusted code on their system.
The skill clearly integrates with Volcengine Ark image-generation endpoints, but the description does not explicitly warn users that prompts and input images are transmitted to a remote third-party service. This can lead users to disclose sensitive text or images under the false assumption processing is local, creating privacy, confidentiality, and compliance risks.
The script stores the API key in a local JSON file in plaintext without warning the user or applying any protection. If the working directory is shared, backed up, committed to version control, or readable by other local users/processes, the credential can be exposed and abused to access the associated API account.
The code offers to persist the API key in a local config.json file in plaintext, without any warning about credential exposure or file-permission hardening. On multi-user systems, shared workspaces, backups, or accidental commits, this can leak the API key and enable unauthorized API usage.
The script writes downloaded content to a user-supplied output_path without restricting the destination, allowing arbitrary file overwrite within the permissions of the running user. In a local skill context this is not remote code execution, but it can still clobber sensitive files or place files in unintended locations if a caller supplies a dangerous path.
req = urllib.request.Request(url)
with urllib.request.urlopen(req, timeout=60) as response:
img_data = response.read()
with open(output_path, 'wb') as f:
f.write(img_data)
return img_data
except Exception as e:
In image-to-image mode, the script reads the local image, base64-encodes it, and includes it in a request to the external Ark API. The code prints that it is calling the API, but it does not explicitly disclose that the user's local image data will be uploaded to a third-party service.
Base64-decoded image data from the remote API is written directly to a caller-controlled output path. This creates the same arbitrary file overwrite risk as other write sites: a local or integrated caller can cause the program to write to unintended filesystem locations.
if image_b64:
img_data = base64.b64decode(image_b64)
if output_path:
with open(output_path, 'wb') as f:
f.write(img_data)
return output_path
This write path saves image data extracted from chat/completions content to a user-controlled filesystem path, again permitting arbitrary file writes under the current user's privileges. The danger is moderate because exploitation requires local/user control of arguments, but in agent or automation contexts that may be enough to overwrite important files.
if match:
img_data = base64.b64decode(match.group(1))
if output_path:
with open(output_path, 'wb') as f:
f.write(img_data)
return output_path
The natural-language instructions throughout the skill are presented exclusively in Chinese, including setup and usage guidance, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the stated policy, forcing a specific language without user opt-in can be a locale-policy issue.
All natural-language prompts and descriptions in this script are presented in Chinese, and there is no indication that the user can select another language. This can violate a language/locale policy when a skill imposes a specific language without opt-in.
The script's user-facing docstring and interactive prompts are written in Chinese throughout, implying a fixed language experience. There is no opt-in, locale selection, or documented justification for restricting the interface to a specific language.
The docstring states that generate_image uses the /api/v3/images/generations endpoint, which is only true for text-to-image mode. In actual code, when an input image is provided, the function switches to the /chat/completions endpoint for vision-based editing, so the documentation is materially inaccurate about the function's behavior.