T09 · Insecure Skill Coding Practices
- Location
scripts/auth.py:63- Finding
API key file is created without restrictive filesystem permissions
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly performs the advertised paid customs-data lookup, but it handles API credentials and account/billing support in ways users should review carefully before installing.
Review this before installing if you use paid UpKuaJing API access. Do not print or paste ~/.upkuajing/.env into chat or logs, prefer setting UPKUAJING_API_KEY through a safer secret mechanism, and restrict the credential file to owner-only permissions if you use it. Be aware that the skill can create payment-order URLs, query account details, send confirmed error reports to the platform, and performs an under-disclosed version check/cache write during API calls.
scripts/auth.py:63API key file is created without restrictive filesystem permissions
SKILL.md:38Setup instructions expose the complete API credential file through terminal output
requirements.txt:1Third-party dependency is unpinned and installed without integrity verification
Remote version checking, reading local skill metadata, writing cache files in the home directory, and emitting upgrade notices are unrelated to the skill's claimed trade-analysis purpose. These extra behaviors enlarge the attack surface through additional network calls and local file interactions that users would not reasonably expect from a simple data-query skill.
Remote version checking, reading local skill metadata, writing cache files in the home directory, and emitting upgrade notices are unrelated to the skill's claimed trade-analysis purpose. These extra behaviors enlarge the attack surface through additional network calls and local file interactions that users would not reasonably expect from a simple data-query skill.
Remote version checking, reading local skill metadata, writing cache files in the home directory, and emitting upgrade notices are unrelated to the skill's claimed trade-analysis purpose. These extra behaviors enlarge the attack surface through additional network calls and local file interactions that users would not reasonably expect from a simple data-query skill.
Remote version checking, reading local skill metadata, writing cache files in the home directory, and emitting upgrade notices are unrelated to the skill's claimed trade-analysis purpose. These extra behaviors enlarge the attack surface through additional network calls and local file interactions that users would not reasonably expect from a simple data-query skill.
The skill explicitly instructs reading the user's credential file from the home directory using commands like viewing ~/.upkuajing/.env. Direct credential-file access is sensitive because it can expose API secrets to the agent context, logs, or downstream tooling, and this is especially risky in a skill whose primary purpose is data retrieval rather than secret management.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
This section directs the workflow to check for the API key in ~/.upkuajing/.env and, if absent, to obtain and save a new key automatically. That combines secret discovery, secret provisioning, and local persistence in one flow, creating unnecessary exposure and increasing the chance credentials are mishandled or written to insecure locations.
### **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 continued instructions around checking and populating ~/.upkuajing/.env reinforce that the skill expects direct access to and modification of a local secret file. Repeated credential-file handling increases the likelihood of accidental disclosure, persistence in transcripts, or abuse by an over-privileged agent environment.
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**
The file implements authentication, API key provisioning, account info lookup, recharge order creation, and pricing retrieval, which materially exceeds the stated skill purpose of HS-code trade percentage analysis. This capability mismatch is dangerous because it introduces sensitive account-management operations that a user or platform reviewer would not reasonably expect from the advertised skill, increasing the risk of privilege misuse, billing abuse, and stealthy credential handling.
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():
The script writes a newly issued API key in plain text to a .env file under the user's home area without any visible permission hardening or secure storage mechanism. Plain-text secret storage increases the chance that other local users, backup systems, accidental commits, or unrelated tooling can read and leak the credential.
"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")
Exposing recharge-order creation and pricing functionality inside a data-analysis skill creates an unnecessary financial operations surface. If invoked unexpectedly or through misuse of the agent interface, these features could trigger billing-related actions or enable account enumeration and monetization workflows unrelated to the declared business function.
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 manifest describes a read-oriented customs trade analysis capability, but this code implements exception reporting by collecting request metadata and sending it to '/agent/skill/error/report'. Error telemetry is a different operational function than querying trade percentage analysis and is not reflected in the stated skill description.
The skill advertises executable behaviors that include environment access, local file read/write, and network use, but it does not declare any explicit tool scope or permissions boundary. That makes the effective trust surface much larger than the manifest suggests and increases the chance an agent invokes sensitive capabilities without clear user awareness or policy enforcement.
The manifest description advertises trigger phrases such as "trade percentage" and especially "market share," which are broad enough to match many general business-analysis requests outside this specific customs/HS-code skill. The file does not provide exclusion conditions or tighter scoping to customs data contexts, increasing the risk of unintended invocation.
The document explicitly instructs agents to report exception context, request parameters, and response data to a remote error-reporting API. Even though it claims sensitive fields are automatically masked, it provides no guarantee of comprehensive redaction and no requirement for user notice, consent, or data minimization, creating a real risk of leaking proprietary, personal, or credential-bearing data through telemetry.
The module docstring and all user-facing CLI descriptions/messages are written exclusively in Chinese, indicating the skill is designed around a single language locale. Under the policy, language constraints should either be optional for the user or clearly documented as a justified region-specific limitation, which is not stated here.
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:
The module title and all user-facing strings/comments in this file are in Chinese, and there is no indication that users can choose another language or that the skill is intentionally limited to a Chinese-only audience. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.