T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_gold-price.py:76- Finding
API Credential Exposed in URL Query Parameters
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill matches its stated purpose of querying TianAPI precious-metal prices, but users should handle the TianAPI API key carefully.
Install only if you are comfortable giving the skill a TianAPI API key and making HTTPS requests to TianAPI. Prefer setting TIANAPI_GOLD_KEY in your environment, avoid passing keys on the command line, do not commit scripts/.env, and rotate the key if it may have appeared in shell history, logs, or shared screenshots.
scripts/fetch_gold-price.py:76API Credential Exposed in URL Query Parameters
SKILL.md:43Documentation Encourages Passing API Credentials on the Command Line
The documentation recommends writing the API key into scripts/.env, which creates a plaintext credential file inside the project tree. This increases the risk of accidental exposure through source control commits, backups, logs, or broader file read access by other tools in the environment.
# 方式一:环境变量(推荐,一次配置永久生效)
export TIANAPI_GOLD_KEY=你的APIKey
# 方式二:.env 文件(在脚本目录创建)
echo "TIANAPI_GOLD_KEY=你的APIKey" > scripts/.env
# 方式三:每次命令行传入
Passing the API key directly on the command line can expose the secret via shell history, process listings, terminal recording, or job control logs. In multi-user or monitored environments, this is a common and avoidable credential leakage path.
export TIANAPI_GOLD_KEY=你的APIKey
# 方式二:.env 文件(在脚本目录创建)
echo "TIANAPI_GOLD_KEY=你的APIKey" > scripts/.env
# 方式三:每次命令行传入
python3 scripts/fetch_gold-price.py --key 你的APIKey --kinds au9999
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Env Config:
export TIANAPI_GOLD_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_GOLD_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_GOLD_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_GOLD_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_GOLD_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_GOLD_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_GOLD_KEY=your_api_key
# 或在脚本同级目录创建 .env 文件: TIANAPI_GOLD_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 advertises executable behavior that uses environment variables, local files, and outbound network access, but it does not declare an explicit tool scope such as permissions or allowed-tools. That gap can cause the agent runtime or reviewer to underestimate what the skill can access, increasing the chance of unintended secret exposure or network use when the skill is invoked.
The script sends the API key as a URL query parameter in a GET request. Even though the endpoint uses HTTPS, query-string credentials are more likely to be exposed through logs, proxies, browser/history equivalents, monitoring systems, or upstream infrastructure than credentials sent in headers or POST bodies.
L043 将脚本用法写为 python3 scripts/fetch_gold-price.py <API_KEY> <KINDS>,而前文 L031 又写成 --key 选项形式,后文 L079 也仅笼统描述“传入API Key和种类代码”。这属于文档层面的主动矛盾,会误导调用者对脚本真实接口的理解。
The skill instructs users to send their API key and requested symbols to a third-party API but does not clearly warn that these values leave the local environment. Even though the data involved is limited, lack of disclosure can lead to unintentional sharing of credentials and query metadata with an external service.
The skill’s descriptive and user-facing text is written in Chinese, including usage guidance and configuration hints, with no indication that users may opt into another language. Under the stated policy, forcing a specific language without opt-in is a natural-language policy concern.