T09 · Insecure Skill Coding Practices
- Location
scripts/set_key.sh:9- Finding
Stored Shell Command Injection Through Sourced Credential File
- Content
View full analysis
"$CONF_FILE" <- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill does what it claims, but its credential script can turn a saved API key file into executable shell code, so users should review it before installing.
Install only if you are comfortable reviewing or changing the helper scripts first. Prefer providing X_API_KEY only for the current session, avoid saving keys with set_key.sh, and do not run generate.sh against a .env file whose contents you did not create and verify.
scripts/set_key.sh:9Stored Shell Command Injection Through Sourced Credential File
scripts/generate.sh:66Request Manipulation Through Unsafe Manual JSON Construction
The skill explicitly instructs the agent to read credentials from conversation input, environment variables, and a local .env file. Accessing and reusing secrets from multiple sources increases the likelihood of unintended credential handling, accidental disclosure, or use of stale/incorrect keys, especially in automated agent contexts.
1. 本次对话显式输入的 x-api-key
2. 环境变量 X_API_KEY
3. 本地持久化文件 ~/.config/seedream5.0/.env
首次配置(只需一次):
The documentation provides concrete instructions for writing the API key into a plaintext .env file under the user's home directory. Even with restrictive permissions, plaintext file storage raises exposure risk through endpoint compromise, shell history mistakes, backups, sync tools, and other local processes running as the same user.
mkdir -p ~/.config/seedream5.0
cat > ~/.config/seedream5.0/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF
chmod 600 ~/.config/seedream5.0/.env
This line is part of the credential persistence workflow around ~/.config/seedream5.0/.env and reinforces use of a local secret file. The surrounding context makes the skill more dangerous because it normalizes durable credential storage for routine use without strong guardrails or lifecycle controls.
cat > ~/.config/seedream5.0/.env << 'EOF' X_API_KEY=你的x-api-key EOF chmod 600 ~/.config/seedream5.0/.env
## 核心接口
The quick-start command advertises a helper script that saves the API key to ~/.config/seedream5.0/.env, making persistent secret storage easy and likely. This convenience increases the probability of widespread insecure key handling across deployments, especially by less experienced users who may not understand the persistence implications.
## 快速执行脚本
- ./scripts/set_key.sh "你的x-api-key":保存 key 到 ~/.config/seedream5.0/.env
- ./scripts/generate.sh --prompt "提示词" [--size "2048x2048"] [--watermark true] [--image "https://example.com/a.png"]
## 目录结构(标准)
The script uses shell source (. "$HOME/.config/seedream5.0/.env") to load the API key file, which executes arbitrary shell commands contained in that file. If an attacker can modify the .env file or place a malicious one there, running the skill will execute attacker-controlled code with the user's privileges.
if [[ -z "${X_API_KEY:-}" && -f "$HOME/.config/seedream5.0/.env" ]]; then
set -a
. "$HOME/.config/seedream5.0/.env"
set +a
fi
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
payload=$(printf '{"prompt":"%s","size":"%s","watermark":%s,"image":%s}' "$prompt" "$size" "$watermark" "$images_json")
response=$(curl -s -m "$TIMEOUT" --location "$API_URL" \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY" \
--data "$payload" 2>&1)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
KEY="$1"
CONF_DIR="$HOME/.config/seedream5.0"
CONF_FILE="$CONF_DIR/.env"
mkdir -p "$CONF_DIR"
cat > "$CONF_FILE" <<EOF
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
KEY="$1"
CONF_DIR="$HOME/.config/seedream5.0"
CONF_FILE="$CONF_DIR/.env"
mkdir -p "$CONF_DIR"
cat > "$CONF_FILE" <<EOF
The skill documents shell-based setup and execution scripts but does not declare any explicit tool scope or allowed-tools boundary. In agent environments, this increases the chance the skill can trigger shell-capable behavior without clear containment, which broadens the attack surface and makes review and enforcement harder.
The activation guidance uses broad, common phrases like '生成图片' and '帮我生成一张图片', which can cause the skill to trigger in situations where the user did not intend to invoke this external API workflow. Unintended activation can lead to unnecessary external data transmission, accidental API use, and exposure of persisted credentials or billing-backed operations.
The skill encourages long-term storage and reuse of the x-api-key in environment variables and a local ~/.config/seedream5.0/.env file, but it does not clearly warn users about persistence risks, shared-machine exposure, backup leakage, or revocation procedures. Because this is an authentication secret, silent persistence materially increases the blast radius if the host, account, logs, or dotfiles are later exposed.
The skill establishes session persistence by creating a configuration directory and saving reusable authentication state across sessions. Persistent auth state is not inherently malicious, but in this context it increases risk by enabling future API calls without fresh user intent and by extending the lifetime of a sensitive credential on disk.
首次配置(只需一次):
mkdir -p ~/.config/seedream5.0
cat > ~/.config/seedream5.0/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
cat > ~/.config/seedream5.0/.env << 'EOF' X_API_KEY=你的x-api-key EOF chmod 600 ~/.config/seedream5.0/.env
## 核心接口
The skill sends user-supplied prompt data, optional image URLs, and an API credential to an external third-party endpoint. External transmission is expected for this skill's purpose, but it still creates privacy and data-handling risk if users are not clearly informed that their content and references leave the local environment.
详细接口说明见 references/api-guide.md。
curl --location 'https://agent.mathmind.cn/minimalist/api/volcengine/ai/fzGenerateImg5' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR_X_API_KEY>' \
--data '{"prompt":"一只猫咪在玩耍","size":"2048x2048","watermark":true,"image":[]}'
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
true[]curl --location 'https://agent.mathmind.cn/minimalist/api/volcengine/ai/fzGenerateImg5' \
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
payload=$(printf '{"prompt":"%s","size":"%s","watermark":%s,"image":%s}' "$prompt" "$size" "$watermark" "$images_json")
response=$(curl -s -m "$TIMEOUT" --location "$API_URL" \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY" \
--data "$payload" 2>&1)
This code sends the assembled JSON payload, including the user prompt and any provided image inputs, to a remote HTTP endpoint via curl. While the operation is central to image generation, the script itself provides no confirmation, logging, or comment warning that user-supplied content is transmitted off-box to an external service.
The script stores a provided API key in a plaintext file under the user's home directory without warning the user about persistent credential storage. Even with restrictive file permissions, writing secrets to disk increases exposure through backups, endpoint compromise, accidental inclusion in support bundles, or later misuse by other local processes running as the same user.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
cat > "$CONF_FILE" <<EOF
X_API_KEY=$KEY
EOF
chmod 600 "$CONF_FILE"
echo "x-api-key saved to $CONF_FILE"
No suspicious patterns detected.