T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
Documentation instructs users to print the API credential file
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This paid HS-code lookup skill is mostly coherent, but it handles API credentials and billing in ways users should review carefully before installing.
Install only if you are comfortable with this skill using a paid Upkuajing API key, storing it in a local plaintext file, and sending queries to the platform. Do not run commands that print the `.env` file, set restrictive permissions on `~/.upkuajing/.env`, and require explicit confirmation before any paid query or recharge-order action.
SKILL.md:37Documentation instructs users to print the API credential file
scripts/auth.py:63API key file is created without explicitly restrictive permissions
requirements.txt:1Third-party dependency is not reproducibly pinned
The skill's stated function is HS code search, but it also performs remote version checks, parses local SKILL.md version data, and maintains cache files in the user's home directory. Undisclosed update-check and local persistence behavior increases attack surface, creates unnecessary outbound requests, and can surprise users who expect a simple query-only skill.
The skill's stated function is HS code search, but it also performs remote version checks, parses local SKILL.md version data, and maintains cache files in the user's home directory. Undisclosed update-check and local persistence behavior increases attack surface, creates unnecessary outbound requests, and can surprise users who expect a simple query-only skill.
The skill's stated function is HS code search, but it also performs remote version checks, parses local SKILL.md version data, and maintains cache files in the user's home directory. Undisclosed update-check and local persistence behavior increases attack surface, creates unnecessary outbound requests, and can surprise users who expect a simple query-only skill.
The skill instructs reading ~/.upkuajing/.env directly and even shows cat ~/.upkuajing/.env, which exposes the entire secrets file rather than only checking for the presence of a needed variable. In an agent setting, direct secret-file access materially raises the risk of credential disclosure to the model, logs, or downstream systems.
本技能需要API密钥。API密钥存储在 ~/.upkuajing/.env 文件中:
cat ~/.upkuajing/.env
文件内容示例:
The workflow directs the agent to inspect and potentially populate ~/.upkuajing/.env with an API key, including automated key issuance and storage. This creates persistent credential-handling behavior inside a search skill, increasing the chance of secret leakage, unauthorized reuse, or insecure file permissions on the local system.
### **API密钥未设置**
首先检查 `~/.upkuajing/.env` 文件中是否有 UPKUAJING_API_KEY;
如果未设置,请让用户选择:
1. 用户已有密钥:用户提供(手动添加到 ~/.upkuajing/.env 文件)
2. 用户没有密钥:通过界面申请(`auth.py --new_key`),新密钥会自动保存到 ~/.upkuajing/.env
等待用户选择;
The skill again directs manipulation of a local .env file for API key handling, reinforcing a pattern of local plaintext credential storage and manual secret insertion. In context, this is more dangerous because the skill is marketed as a simple HS-code lookup tool, so users may not anticipate credential access and persistence side effects.
首先检查 `~/.upkuajing/.env` 文件中是否有 UPKUAJING_API_KEY;
如果未设置,请让用户选择:
1. 用户已有密钥:用户提供(手动添加到 ~/.upkuajing/.env 文件)
2. 用户没有密钥:通过界面申请(`auth.py --new_key`),新密钥会自动保存到 ~/.upkuajing/.env
等待用户选择;
### **账户充值**
The file implements authentication, account lookup, pricing, and recharge/order creation features that are materially broader than the declared HS-code search skill purpose. In an agent-skill context, capability mismatch is dangerous because it can expose billing, credential, and account-management actions to a workflow that users would reasonably expect to be limited to product-code lookup.
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():
This line writes an API key directly into a plaintext .env file, creating a real credential-exposure risk. In a skill whose advertised purpose is only HS-code search, disk persistence of newly minted credentials is especially dangerous because it silently expands trust and can enable subsequent unauthorized API use if the file is read by others.
"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 recharge-order creation function enables a monetary transaction path unrelated to HS-code search. In a skill package advertised for customs-code lookup, hidden or unexpected billing capabilities raise the risk of unauthorized charges, social engineering, or abuse through exposed agent actions.
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 skill for searching and analyzing HS codes by product name or HS-code keywords. This file instead implements exception reporting to a platform endpoint, including collecting request metadata and sending it to '/agent/skill/error/report', which is a separate operational/telemetry capability rather than HS-code search behavior.
The skill declares only high-level metadata and omits an explicit tool/permission scope, yet its documented behavior includes environment access, local file reads/writes, and network/API operations. This weakens containment and informed consent because a caller cannot easily distinguish simple HS-code lookup from broader capabilities like credential handling, reporting, and account operations.
The skill can request a new API key and persist it locally, which is a credential-management capability unrelated to the declared search function. In this context, bundled credential issuance and storage increase the risk of silent environment modification, unauthorized API usage, and privilege expansion beyond the user's expectation.
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 code writes a newly issued API key to a local .env file without an explicit pre-write warning or opt-in at the time of execution. Storing credentials on disk in plaintext can expose them to other local users, backups, logs, or accidental disclosure, especially when users do not realize the command will persist secrets.
Account and balance queries expose financial/account metadata that is not necessary for an HS-code lookup tool. Even if read-only, this expands the skill's access scope and may leak sensitive organizational details or balances to users and downstream systems that did not expect such data exposure.
Pricing-query functionality is outside the core business goal of HS-code search and reveals monetization/account capability that users may not anticipate. While lower severity than credential or payment actions, it still broadens the skill's operational scope and supports abuse chains involving billing discovery and upsell/manipulation.
The module can transmit request parameters to a remote API and, when logging is enabled, persist full request and response bodies locally without any built-in redaction of sensitive fields. If product data, identifiers, or credentials are ever included in params or echoed by the API, they may be exposed in local log files and retained longer than intended.
Detected: suspicious.exposed_secret_literal