T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
API Key Exposure and Insecure Plaintext Credential Storage
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mainly a disclosed paid trade-ranking API helper, but it handles credentials in ways that could expose an API key and includes extra account, payment, telemetry, and update-check behavior.
Install only if you are comfortable with this skill using an UpKuaJing API key, creating a plaintext key file under `~/.upkuajing`, making paid API calls after confirmation, and using account/top-up support flows. Do not run commands that print `.env` contents; check for key presence without exposing the key, restrict file permissions, and review any error report before sending it.
SKILL.md:37API Key Exposure and Insecure Plaintext Credential Storage
requirements.txt:1Unbounded Third-Party Dependency Installation
Remote version checks, local metadata parsing, and creation of cache files in the user's home directory are unrelated to the stated top-N trade query purpose. Undisclosed update-check behavior introduces additional outbound network traffic and filesystem writes, which can leak usage patterns and expand the skill's capabilities beyond what users and reviewers expect.
Remote version checks, local metadata parsing, and creation of cache files in the user's home directory are unrelated to the stated top-N trade query purpose. Undisclosed update-check behavior introduces additional outbound network traffic and filesystem writes, which can leak usage patterns and expand the skill's capabilities beyond what users and reviewers expect.
Remote version checks, local metadata parsing, and creation of cache files in the user's home directory are unrelated to the stated top-N trade query purpose. Undisclosed update-check behavior introduces additional outbound network traffic and filesystem writes, which can leak usage patterns and expand the skill's capabilities beyond what users and reviewers expect.
Remote version checks, local metadata parsing, and creation of cache files in the user's home directory are unrelated to the stated top-N trade query purpose. Undisclosed update-check behavior introduces additional outbound network traffic and filesystem writes, which can leak usage patterns and expand the skill's capabilities beyond what users and reviewers expect.
The skill explicitly instructs reading ~/.upkuajing/.env and even shows cat ~/.upkuajing/.env, which normalizes direct access to a credential file. In an agent context, prompting or automating reads of secret-bearing files increases the risk of accidental secret exposure to the model, logs, or downstream tooling.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
The workflow directs the system to inspect a local secret file and, if needed, obtain or store an API key there. This is dangerous because it operationalizes credential handling inside a general-purpose skill, increasing the chance of exposing, overwriting, or mishandling secrets through model-driven actions.
### **API Key Not Set**
First check if the `~/.upkuajing/.env` file has UPKUAJING_API_KEY;
If UPKUAJING_API_KEY is not set, prompt the user to choose:
1. User has one: User provides it (manually add to ~/.upkuajing/.env file)
2. User doesn't have one: You can apply using the interface (`auth.py --new_key`), the new key will be automatically saved to ~/.upkuajing/.env
Wait for user selection;
Automatically saving newly created API keys to a local .env file combines secret generation and local persistence in a way that exceeds the expectations of a ranking-query skill. If exploited or misused, this can create durable credential artifacts on disk that may later be read by other tools, leaked in backups, or exposed through logs and support actions.
First check if the `~/.upkuajing/.env` file has UPKUAJING_API_KEY;
If UPKUAJING_API_KEY is not set, prompt the user to choose:
1. User has one: User provides it (manually add to ~/.upkuajing/.env file)
2. User doesn't have one: You can apply using the interface (`auth.py --new_key`), the new key will be automatically saved to ~/.upkuajing/.env
Wait for user selection;
### **Account Top-up**
This file implements authentication, API key provisioning, account information retrieval, pricing lookup, and recharge order creation, which materially exceed the skill’s stated purpose of returning top-N supplier/buyer rankings. In an agent-skill context, hidden or unnecessary account-management capabilities expand the attack surface and can enable unexpected billing or credential lifecycle actions unrelated to the user’s trade-ranking task.
The code explicitly inspects a local .env file for an existing API key, which places credential material into a flat-file workflow. In this context the main risk is secret handling weakness: .env files are easily overexposed through backups, permissive file permissions, accidental inclusion in archives, or debugging output.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
Reading the entire .env file to locate credentials reinforces insecure secret storage practices and increases the chance that credentials are handled more broadly than necessary. In a skill that should only perform ranking queries, this credential-centric behavior is unnecessary and raises exposure risk if the environment file is accessible to other local users or processes.
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
# 读取现有的 .env 文件
try:
with open(env_file, 'r', encoding='utf-8') as f:
content = f.read()
The code writes the newly issued API key directly into a .env file, creating persistent local secret storage without any visible permission hardening or encryption. This is dangerous because API keys can be stolen from disk, copied via backups, or leaked through developer workflows, enabling unauthorized use of the associated account or API quota.
"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")
The code can create recharge/payment orders through '/agent/auth/pay/url', which is unrelated to supplier/buyer ranking queries and introduces a financial operation into a read-oriented skill. In a skill ecosystem, undisclosed billing functionality is dangerous because it can trigger payment workflows or socially engineer users into funding accounts they did not intend to manage.
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'
# 日志开关
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
The manifest describes a read-oriented trade ranking skill for querying ranked suppliers or buyers by country pair and year. In contrast, this code collects error-report parameters and sends them to an '/agent/skill/error/report' API, which is operational telemetry/reporting behavior unrelated to trade-volume ranking functionality.
The skill advertises and instructs use of sensitive capabilities including environment-variable access, local file reads/writes, and network/API operations, but it does not declare a limiting tool scope. That creates an over-privileged execution model where a seemingly simple analytics skill can access credentials, persist data locally, and make remote requests beyond the narrow user-visible purpose.
The documentation explicitly allows sending raw request parameters, response data, and error context to an error-reporting endpoint. Even if the platform claims sensitive fields are auto-redacted, this still creates a data-sharing channel that can expose business data, personal data, tokens, or stack traces unless callers are clearly warned and instructed to minimize submitted content. In an agent/skill setting, error paths often contain highly contextual user inputs and backend responses, which increases the chance of over-collection during failures.
This file contains the module description and CLI help/messages in Chinese only, indicating a fixed language choice. Under the policy, forcing a specific language without offering user choice or documenting a justified locale constraint is a natural-language policy violation.
The skill provisions a new API key and persists it locally, even though credential issuance is outside the declared top-N ranking use case. Unnecessary credential-management logic increases the chance of secret sprawl, accidental exposure, and misuse of newly issued credentials by components or users who only expected query functionality.
Using 'require_auth=False' for '/agent/auth/create' makes the default behavior permissive around a sensitive operation: issuing credentials. In context, the mismatch between the skill’s trade-ranking purpose and its unauthenticated auth-management path makes this more dangerous, because users and reviewers may not expect secret provisioning logic in such a skill.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
Using 'require_auth=False' for '/agent/auth/create' makes the default behavior permissive around a sensitive operation: issuing credentials. In context, the mismatch between the skill’s trade-ranking purpose and its unauthenticated auth-management path makes this more dangerous, because users and reviewers may not expect secret provisioning logic in such a skill.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
The argparse description and argument help text are all presented in Chinese, which constrains interaction to a single language. The file does not indicate any opt-in, fallback, or justified regional limitation.