T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
API Key Disclosure Through Documented Credential Inspection
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly performs the advertised trade-data queries, but it needs review because it handles paid-account API keys, top-up/order flows, plaintext local credentials, and automatic version-check traffic.
Install only if you trust UpKuaJing with paid API access. Do not print the `.env` file or paste the API key into chat; prefer a secret manager or tightly permissioned environment variable, confirm every paid query or top-up action, and review any error report payload before sending it.
SKILL.md:37API Key Disclosure Through Documented Credential Inspection
scripts/auth.py:61API Key File Is Written Without Explicit Restrictive Permissions
requirements.txt:1Unbounded Dependency Version Allows Unreviewed Future Releases
The skill appears to perform version checks, read local metadata, and maintain a cache file unrelated to the advertised trade-query task. These side behaviors expand the attack surface and can create unexpected network and filesystem activity under the guise of a simple data lookup tool.
The skill appears to perform version checks, read local metadata, and maintain a cache file unrelated to the advertised trade-query task. These side behaviors expand the attack surface and can create unexpected network and filesystem activity under the guise of a simple data lookup tool.
The skill appears to perform version checks, read local metadata, and maintain a cache file unrelated to the advertised trade-query task. These side behaviors expand the attack surface and can create unexpected network and filesystem activity under the guise of a simple data lookup tool.
The skill appears to perform version checks, read local metadata, and maintain a cache file unrelated to the advertised trade-query task. These side behaviors expand the attack surface and can create unexpected network and filesystem activity under the guise of a simple data lookup tool.
The skill instructs reading the full ~/.upkuajing/.env file with cat, which exposes secrets beyond the single API key and normalizes direct credential inspection. In an agent setting, this is especially risky because it encourages plaintext secret handling and could leak credentials into logs, transcripts, or downstream tools.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
The skill directs the agent to inspect a local secret file and, if absent, initiate API key creation and automatic saving into that file. This combines credential discovery, generation, and persistence in one workflow, creating opportunities for unauthorized secret handling and long-lived plaintext storage.
### **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;
The workflow tells the agent to check whether UPKUAJING_API_KEY exists in ~/.upkuajing/.env and potentially write user-provided or newly created credentials there. In this context, the danger is elevated because the skill is ostensibly a data-query tool, yet it manipulates local credential storage and could expose or overwrite secrets without strong isolation.
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 adds broad account-management capabilities—API key provisioning, account balance lookup, recharge order creation, and pricing queries—that are unrelated to the declared purpose of a read-only trade-list querying skill. In an agent-skill context, unnecessary financial and credential-management functionality expands the attack surface and could let the skill trigger account or billing side effects beyond what users expect.
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 a newly issued API key directly into a plaintext .env file under the user's home directory creates a secret-at-rest exposure. Other local processes, backups, logs, or misconfigured file permissions could disclose the credential, enabling unauthorized API use and potential account abuse.
"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 skill can create recharge/payment orders despite being described as a data-query tool. Billing-related actions are high risk because they introduce financial side effects that could be invoked unexpectedly by an agent or a user who only intended to fetch trade data.
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'
# 日志开关
This file implements telemetry for reporting runtime errors to a remote platform rather than functionality for querying paginated country trade-list data promised by the skill manifest. That mismatch is security-relevant because hidden or undisclosed auxiliary network behavior expands the skill’s privileges and can enable covert data collection or unexpected outbound communication during agent execution.
The primary behavior in this code path is skill version management, including remote POST requests and user-environment file writes, rather than the declared trade-data functionality. In a skill ecosystem, undeclared non-functional behavior is dangerous because it can bypass user expectations, complicate review, and enable covert telemetry or control channels through an attacker-controlled api_base_url.
The skill declares executable capabilities involving environment access, file reads/writes, and network use, but does not constrain them with an explicit tool scope. That creates unnecessary ambient authority: an agent invoking this skill may access credentials, local files, or remote endpoints beyond what a simple trade-list query should require.
The description lists triggers such as "country trade list" and "national trade breakdown" without specifying invocation constraints or exclusion conditions. These phrases are generic enough to match ordinary analytical requests, increasing the chance of unintended activation.
The document explicitly instructs agents to send request parameters, response payloads, and exception context to an external error-reporting API. Even though it says sensitive fields are automatically masked, it does not require minimization, user notice, or strict exclusion of secrets/PII, so operational data, prompts, identifiers, or business-sensitive trade queries could still be transmitted unnecessarily.
This code provisions a new API credential and persists it locally, which is broader than the stated purpose of querying trade data. Automatic credential issuance and storage can create unmanaged secrets, confuse trust boundaries, and enable later misuse of the account or API from the local environment.
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: