T09 · Insecure Skill Coding Practices
- Location
scripts/image_generate.py:153- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a straightforward Juhe image-generation helper, but users should handle the API key carefully and understand it downloads provider-returned image URLs.
Install only if you are comfortable sending prompts and your Juhe API key to Juhe's image API. Prefer a platform secret store or environment variable for JUHE_IMAGE_KEY; avoid the --key command-line option and avoid committing scripts/.env. Use --no-download or a contained output directory if you do not want automatic downloads from provider-returned image links.
scripts/image_generate.py:153API Key Exposure Through Command-Line Arguments
scripts/image_generate.py:118Unvalidated API-Controlled Image URL Download
The documentation encourages storing the API key in a local .env file under the scripts directory, which is a common path that may be accidentally committed, packaged, or exposed to other tooling. In a skill context that already uses filesystem access, this increases the risk of credential leakage and unauthorized third-party API use.
# 方式一:环境变量(推荐,一次配置永久生效)
export JUHE_IMAGE_KEY=你的AppKey
# 方式二:.env 文件(在脚本目录创建)
echo "JUHE_IMAGE_KEY=你的AppKey" > scripts/.env
# 方式三:每次命令行传入
The skill explicitly tells users to write JUHE_IMAGE_KEY into scripts/.env, a plaintext location adjacent to executable code. This makes accidental disclosure more likely through source control, backups, logs, or other agents/tools that can read the workspace, enabling API key theft and quota abuse.
export JUHE_IMAGE_KEY=你的AppKey
# 方式二:.env 文件(在脚本目录创建)
echo "JUHE_IMAGE_KEY=你的AppKey" > scripts/.env
# 方式三:每次命令行传入
python scripts/image_generate.py --key 你的AppKey "一只猫咪在草地上玩耍"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
API Key 配置(任选其一,优先级从高到低):
1. 环境变量: export JUHE_IMAGE_KEY=your_api_key
2. 脚本同目录的 .env 文件: JUHE_IMAGE_KEY=your_api_key
3. 直接传参: python image_generate.py --key your_api_key "提示词"
免费申请 API Key: https://www.juhe.cn/docs/api/id/824
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
API Key 配置(任选其一,优先级从高到低):
1. 环境变量: export JUHE_IMAGE_KEY=your_api_key
2. 脚本同目录的 .env 文件: JUHE_IMAGE_KEY=your_api_key
3. 直接传参: python image_generate.py --key your_api_key "提示词"
免费申请 API Key: https://www.juhe.cn/docs/api/id/824
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
if env_key:
return env_key
env_file = Path(__file__).parent / ".env"
if env_file.exists():
for line in env_file.read_text(encoding="utf-8").splitlines():
line = line.strip()
The skill instructs use of environment variables, local file access, and outbound network requests, but does not declare any explicit tool scope or permission boundaries. This can lead to over-broad execution in an agent environment, where the skill may gain more access than users or reviewers expect, increasing the chance of unintended secret exposure or filesystem/network misuse.
The entire skill description and usage guidance are written only in Chinese, and examples/instructions assume Chinese-language operation. Under the stated policy, a skill that imposes a specific language without user opt-in can be a natural-language policy violation unless the locale constraint is explicitly justified, which is not documented here.
The module docstring and all usage/help text are written in Chinese, and the script presents Chinese-only prompts and status messages throughout execution. This imposes a specific language on users without any opt-in or documented locale constraint, which matches the language/locale policy-violation category.