T09 · Insecure Skill Coding Practices
- Location
SKILL.md:39- Finding
Documentation Instructs the Agent to Print the API Credential File
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill’s trade-query purpose is mostly coherent, but it handles API keys, billing flows, telemetry, and hidden version-check persistence in ways users should review carefully before installing.
Install only if you are comfortable with a Chinese-language skill that calls Upkuajing APIs, may incur per-query fees after confirmation, stores its API key in a local plaintext file, can create recharge payment URLs, and can report errors to the platform after confirmation. Do not run the documented cat command on the .env file or paste API keys into chat/logs; prefer setting UPKUAJING_API_KEY through a secure environment/secret mechanism and restrict local file permissions if you use the .env flow.
SKILL.md:39Documentation Instructs the Agent to Print the API Credential File
scripts/auth.py:68API Key File Is Created Without Explicit Owner-Only Permissions
requirements.txt:1Third-Party HTTP Dependency Is Not Reproducibly Pinned
The skill includes version-check behavior, local parsing of SKILL metadata, cache writes in the home directory, and upgrade prompting despite being advertised as a trade-query skill. Hidden maintenance/network behavior broadens the trust boundary and can leak metadata or create persistent artifacts unrelated to the user-requested task.
The skill includes version-check behavior, local parsing of SKILL metadata, cache writes in the home directory, and upgrade prompting despite being advertised as a trade-query skill. Hidden maintenance/network behavior broadens the trust boundary and can leak metadata or create persistent artifacts unrelated to the user-requested task.
The skill includes version-check behavior, local parsing of SKILL metadata, cache writes in the home directory, and upgrade prompting despite being advertised as a trade-query skill. Hidden maintenance/network behavior broadens the trust boundary and can leak metadata or create persistent artifacts unrelated to the user-requested task.
The skill includes version-check behavior, local parsing of SKILL metadata, cache writes in the home directory, and upgrade prompting despite being advertised as a trade-query skill. Hidden maintenance/network behavior broadens the trust boundary and can leak metadata or create persistent artifacts unrelated to the user-requested task.
The skill instructs reading the full ~/.upkuajing/.env file, which may expose the API key and potentially other secrets stored in that file. In an agent environment, encouraging raw secret-file access increases the chance of credential disclosure to logs, transcripts, or unintended downstream processing.
本技能需要API密钥。API密钥存储在 ~/.upkuajing/.env 文件中:
cat ~/.upkuajing/.env
文件内容示例:
The workflow instructs users or the agent to add credentials into a local plaintext .env file and notes that auth.py --new_key will auto-save the new secret there. Storing and managing API credentials in a writable plaintext file under the home directory creates credential theft risk from other processes, logs, backups, or overly broad file access.
### **API密钥未设置**
首先检查 `~/.upkuajing/.env` 文件中是否有 UPKUAJING_API_KEY;
如果未设置,请让用户选择:
1. 用户已有密钥:用户提供(手动添加到 ~/.upkuajing/.env 文件)
2. 用户没有密钥:通过界面申请(`auth.py --new_key`),新密钥会自动保存到 ~/.upkuajing/.env
等待用户选择;
This section repeats the practice of checking and populating ~/.upkuajing/.env with API secrets, reinforcing a pattern of direct credential-file handling inside a trade-analysis skill. The skill context makes this more dangerous because credential management is unnecessary for the advertised narrow task and enlarges the blast radius if the agent is induced to inspect or modify local secret files.
首先检查 `~/.upkuajing/.env` 文件中是否有 UPKUAJING_API_KEY;
如果未设置,请让用户选择:
1. 用户已有密钥:用户提供(手动添加到 ~/.upkuajing/.env 文件)
2. 用户没有密钥:通过界面申请(`auth.py --new_key`),新密钥会自动保存到 ~/.upkuajing/.env
等待用户选择;
### **账户充值**
This file implements API key issuance, account lookup, recharge-order creation, and pricing queries, which are materially unrelated to a skill described as read-only trade trend analysis. In an agent-skill context, this expands capabilities into credential provisioning and billing flows, increasing attack surface and enabling unexpected side effects a user would not reasonably expect from the declared purpose.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Writing an API key into a .env file stores a credential in plaintext on disk, which increases the chance of local disclosure through weak permissions, backups, accidental commits, or other tools reading environment files. In a skill that users expect to analyze trade data, hidden credential storage is more dangerous because it is outside normal expectations.
"envFilePath": str(env_file)
}
# 保存到 .env 文件
try:
with open(env_file, 'w', encoding='utf-8') as f:
f.write(f"{API_KEY_ENV}={api_key}\n")
Creating recharge orders and exposing payment-related endpoints is unjustified for a trade-analysis/query skill and introduces financial side effects. If an agent can invoke this unexpectedly, users may be pushed into unintended billing workflows or payment links outside the skill's stated purpose.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
API_BASE_URL = "https://openapi.upkuajing.com"
API_KEY_ENV = "UPKUAJING_API_KEY"
UPKUAJING_DIR = Path.home() / '.upkuajing'
UPKUAJING_ENV_FILE = UPKUAJING_DIR / '.env'
UPKUAJING_LOGS_DIR = UPKUAJING_DIR / 'logs'
# 日志开关
The module docstring explicitly describes cross-platform agent exception reporting, which contradicts the stated purpose of a trade analytics skill. This kind of hidden secondary purpose increases risk because it signals undeclared telemetry or data transfer functionality that operators may not review under the expected trust boundary of the skill.
This file implements exception reporting to a platform endpoint instead of HS-code trade trend querying described by the manifest, creating a clear capability mismatch. In an agent skill, undocumented out-of-scope network functionality is dangerous because it can exfiltrate operational context and makes the skill behave differently from what integrators and users expect.
The skill declares no explicit tool or permission boundaries even though the documented behavior includes reading environment files, writing local configuration, and making external network requests. In an agent setting, this expands the effective attack surface and makes it harder to constrain what the skill may access or modify at runtime.
This markdown skill file presents its operational instructions, warnings, and usage examples only in Chinese. Under the policy, forcing a specific language without user opt-in or a clearly justified locale constraint is a natural-language policy violation.
The API documentation instructs agents to upload request parameters, response payloads, and exception context to a central error-reporting endpoint. Even though it says sensitive fields are 'automatically desensitized,' it provides no explicit data classification rules, user notice, consent flow, or prohibition on including secrets, personal data, or commercially sensitive trade data in free-form fields such as context, requestParams, and responseData. In this skill context, debugging data may contain user queries, HS codes, business analysis inputs, and backend error details, increasing the chance of unintended data leakage to logging or telemetry systems.
The file’s user-facing description, error messages, and CLI help are presented only in Chinese, with no mechanism to select another language or indication that the tool is intentionally region-specific. Under the policy, forcing a language/locale without user opt-in is a natural-language policy violation.
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
Detected: suspicious.exposed_secret_literal