T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_dgryl.py:105- 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 is a straightforward TianAPI quote-fetching skill, with the main caution that its examples can expose the TianAPI API key through command-line history, a local .env file, or provider URL logs.
Install only if you are comfortable giving the skill a TianAPI key and allowing it to contact TianAPI. Prefer the TIANAPI_DGRYL_KEY environment variable or a managed secret store, avoid passing the key on the command line, do not commit scripts/.env, restrict its permissions if used, and rotate the key if it may have appeared in shell history or logs.
scripts/fetch_dgryl.py:105API Key Exposure Through Command-Line Arguments
SKILL.md:27Plaintext API Key Storage Without Enforced File Permissions
scripts/fetch_dgryl.py:76API Key Included in URL Query Parameters
The skill instructs users to place the API key into scripts/.env, which can lead to credentials being stored in the project workspace where they may be accidentally committed, read by other tools, or exposed through logs and debugging. Although common in developer workflows, embedding secrets in local files materially increases credential leakage risk.
# 方式一:环境变量(推荐,一次配置永久生效)
export TIANAPI_DGRYL_KEY=你的APIKey
# 方式二:.env 文件(在脚本目录创建)
echo "TIANAPI_DGRYL_KEY=你的APIKey" > scripts/.env
# 方式三:每次命令行传入
The documentation shows passing the API key directly on the command line, which can expose the secret via shell history, process listings, audit logs, and terminal recordings. In agent or shared-system contexts this is particularly risky because other users or tools may be able to observe command invocations.
export TIANAPI_DGRYL_KEY=你的APIKey
# 方式二:.env 文件(在脚本目录创建)
echo "TIANAPI_DGRYL_KEY=你的APIKey" > scripts/.env
# 方式三:每次命令行传入
python3 scripts/fetch_dgryl.py --key 你的APIKey
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Env Config:
export TIANAPI_DGRYL_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_DGRYL_KEY=your_api_key
"""
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Env Config:
export TIANAPI_DGRYL_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_DGRYL_KEY=your_api_key
"""
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Env Config:
export TIANAPI_DGRYL_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_DGRYL_KEY=your_api_key
"""
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Env Config:
export TIANAPI_DGRYL_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_DGRYL_KEY=your_api_key
"""
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
if env_val: return env_val
# 2. .env 文件
env_file = Path(__file__).parent / ".env"
if env_file.exists():
try:
content = env_file.read_text(encoding="utf-8")
The skill documentation indicates capabilities involving environment variables, file access, and outbound network use, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates a least-privilege gap: an agent may grant broader-than-necessary execution context to a skill that handles secrets and performs network requests, increasing the chance of unintended secret exposure or unsafe tool use.
This code constructs a query string containing the API key and sends it to a remote HTTP endpoint. Although network access is part of the script's purpose, there is no explicit user-facing warning in the code or docstring that the provided key will be transmitted to a third-party service.
The natural-language documentation and several user-facing messages are written only in Chinese, with no indication of language choice or opt-in. Under the policy, forcing a specific language without user choice can be a locale/language policy violation.