T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
API Key Disclosure Through Credential File Display
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill provides the advertised HS-code lookup, but its credential handling and automatic support behavior need review before installation.
Install only if you are comfortable with a paid external API skill that stores an UpKuaJing API key locally. Do not let the agent print ~/.upkuajing/.env into chat or logs, confirm any fee-incurring or payment-related action, and avoid sending raw request or response data in error reports unless it has been sanitized.
SKILL.md:37API Key Disclosure Through Credential File Display
scripts/auth.py:61API Key File Is Created Without Enforced Restrictive Permissions
requirements.txt:1Unpinned and Unverified Third-Party Dependency
Version checking, reading SKILL.md metadata, writing a local version cache, and printing upgrade notices are not necessary for an HS-code description lookup and expand both local file access and network behavior. This increases complexity and can undermine the principle of least privilege for a simple informational skill.
Version checking, reading SKILL.md metadata, writing a local version cache, and printing upgrade notices are not necessary for an HS-code description lookup and expand both local file access and network behavior. This increases complexity and can undermine the principle of least privilege for a simple informational skill.
Version checking, reading SKILL.md metadata, writing a local version cache, and printing upgrade notices are not necessary for an HS-code description lookup and expand both local file access and network behavior. This increases complexity and can undermine the principle of least privilege for a simple informational skill.
Version checking, reading SKILL.md metadata, writing a local version cache, and printing upgrade notices are not necessary for an HS-code description lookup and expand both local file access and network behavior. This increases complexity and can undermine the principle of least privilege for a simple informational skill.
The skill instructs reading the full ~/.upkuajing/.env file, which can expose API keys and potentially other secrets stored in that file. For a lookup skill, direct credential-file access is especially risky because it normalizes secret handling in a user-facing workflow and could leak credentials through logs, prompts, 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 skill directs the agent to check and potentially populate ~/.upkuajing/.env with an API key, including automatic key creation and storage. This combines credential discovery, issuance, and local persistence in a skill that users may expect to be read-only, raising the risk of secret mishandling and unauthorized account 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;
Automatic saving of a newly created API key into ~/.upkuajing/.env creates a persistent local secret-handling path that is broader than necessary for the stated skill purpose. Persistent credential writes can be abused by overprivileged skills, expose secrets to other local processes, or leave sensitive material in insecure file permissions or backups.
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, account management, recharge, and pricing features that are outside the declared purpose of an HS code description lookup skill. In a least-privilege agent ecosystem, unjustified expansion into account and billing operations increases attack surface and creates opportunities for unauthorized account manipulation or unexpected charges.
The code can request a new API key and persist it locally, which is unrelated to a customs lookup function and materially increases credential risk. A skill that can mint and store credentials may be abused to create unauthorized access paths or silently alter the execution environment for later use.
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 code reads the entire .env file content to inspect existing credentials, which means the skill handles plaintext secrets directly. In the context of an unrelated HS code lookup skill, direct credential-file access is unjustified and increases the chance of accidental disclosure, logging, or misuse by adjacent functionality.
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 script writes a newly issued API key to a local .env file in plaintext, creating a persistent secret on disk without visible controls for encryption, rotation, or permission hardening. For a skill whose stated purpose is simple HS code lookup, storing credentials this way is excessive and raises the risk of credential compromise from local file access or later leakage.
"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 CLI exposes account info, recharge-order creation, and pricing operations that are not justified by the stated customs-code lookup purpose. This mismatch is dangerous because users or calling agents may invoke sensitive financial/account actions under the guise of a benign lookup capability.
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 skill manifest says the skill queries HS code details and returns Chinese/English descriptions for a given HS code. In contrast, this code validates error-report parameters and sends them to '/agent/skill/error/report', which is operational telemetry behavior unrelated to customs code detail retrieval.
The skill declares no explicit tool scope or permission boundaries even though its documented behavior includes environment access, local file reads/writes, and networked API operations. This creates an overprivileged execution model where a seemingly simple HS-code lookup skill can access credentials and perform side-effecting actions beyond user expectations.
The documentation explicitly permits sending request parameters, response payloads, and exception context to an error-reporting endpoint. Even though it states sensitive fields will be auto-masked, it does not define masking guarantees or require user/operator minimization, so agents may transmit personal data, credentials, business data, or model inputs/outputs during failure handling. In a customs/HS-code workflow, request and response content can include product, shipment, or customer-related information, making unintended disclosure to the platform a realistic privacy and compliance risk.
The explicit require_auth=False parameter codifies an insecure default for a sensitive operation that creates API credentials. Even if the backend intends to allow self-service signup, embedding that behavior in an unrelated skill makes accidental or unauthorized provisioning easier and weakens separation of duties.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
The explicit require_auth=False parameter codifies an insecure default for a sensitive operation that creates API credentials. Even if the backend intends to allow self-service signup, embedding that behavior in an unrelated skill makes accidental or unauthorized provisioning easier and weakens separation of duties.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
The manifest describes a narrowly scoped skill for retrieving Chinese and English descriptions for a given HS code, but this file defines a task-data directory and later supports saving metadata and result files under that directory. Persistent task management and local result storage are broader behaviors than a straightforward detail lookup utility and are not implied by the manifest text.
The task management section generates task IDs, creates per-task directories, stores metadata, and appends result data. That is a reusable batch/job-processing capability rather than a purpose-specific implementation detail for returning Chinese and English descriptions of one HS code.