T09 · Insecure Skill Coding Practices
- Location
scripts/auth.py:59- Finding
API Credential File Is Created Without Restrictive Permissions
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mostly a disclosed paid UpKuaJing customs-data integration, but it handles API keys and account/payment flows in ways users should review carefully before installing.
Review this skill before installing if you are not comfortable with a paid external API integration storing a reusable API key in ~/.upkuajing/.env. Prefer setting UPKUAJING_API_KEY through a secure secret mechanism, avoid displaying the .env file contents, restrict file permissions on ~/.upkuajing and its .env file, and confirm any billed query or top-up action explicitly.
scripts/auth.py:59API Credential File Is Created Without Restrictive Permissions
requirements.txt:1Unbounded Third-Party Dependency Reduces Supply-Chain Integrity
If the associated code performs software update checks, local cache writes, and outbound version requests unrelated to trade-statistics functionality, that is a meaningful behavior mismatch from the declared purpose. Such hidden maintenance/network behavior expands the attack surface and can surprise users with extra outbound communication and local persistence beyond the advertised analytics task.
If the associated code performs software update checks, local cache writes, and outbound version requests unrelated to trade-statistics functionality, that is a meaningful behavior mismatch from the declared purpose. Such hidden maintenance/network behavior expands the attack surface and can surprise users with extra outbound communication and local persistence beyond the advertised analytics task.
If the associated code performs software update checks, local cache writes, and outbound version requests unrelated to trade-statistics functionality, that is a meaningful behavior mismatch from the declared purpose. Such hidden maintenance/network behavior expands the attack surface and can surprise users with extra outbound communication and local persistence beyond the advertised analytics task.
The skill explicitly instructs reading ~/.upkuajing/.env to obtain an API key, which is direct access to local credentials. Exposing or retrieving secrets from a plaintext file in the user's home directory is dangerous because it can leak reusable authentication material and normalize unsafe secret-handling practices.
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 around checking for a local API key and, if missing, obtaining a new one that will be automatically saved to a local .env file. Automatically creating and persisting credentials in a user-home plaintext file increases exposure of sensitive tokens and couples a data-query skill with credential lifecycle operations that should be more tightly controlled.
### **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 normalizes checking and populating ~/.upkuajing/.env for secret management, again creating a direct credential-access path in the skill instructions. In context, this is especially risky because the same skill can make network requests and paid API calls, so credential exposure could enable unauthorized data access and charges.
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 API key issuance, account lookup, pricing, and recharge-order creation, which are materially broader than the declared purpose of a read-oriented customs regional analytics skill. In an agent-skill ecosystem, hidden billing/auth-management logic increases the attack surface and can enable unexpected credential provisioning or monetization flows that users would not reasonably expect from this skill.
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 code writes a newly issued API key to a local .env file in plaintext, which can expose credentials to other local users, backup systems, logs, or accidental inclusion in tooling. In an analytics skill, this secret-persistence behavior is especially risky because users may not expect credential storage side effects.
"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")
Creating recharge/payment orders is not justified by the stated analytics-only functionality and introduces an unnecessary financial action into the skill. If exposed through an agent workflow, this could trigger or facilitate unintended payment flows, phishing-style redirection, or abuse of a user's billing relationship.
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 querying and analyzing company customs trade statistics by region, monthly trends, and country distribution. This file instead implements exception reporting to a platform endpoint, including collecting request metadata and sending it to '/agent/skill/error/report', which is operational telemetry rather than trade-statistics functionality.
The skill declares capabilities that involve environment access, local file reads/writes, and network activity, but it does not explicitly scope or constrain those powers via permissions or allowed-tools metadata. In a skill that handles credentials and can contact remote services, missing tool-scope declarations increases the chance of overbroad execution and makes it harder for a host to enforce least privilege.
The trigger phrases are broad and overlap with general trade-analysis requests, which can cause unintended invocation of a skill that performs paid queries and credential/account operations. While not an exploit by itself, ambiguous triggering raises the likelihood of accidental execution and unexpected cost or data access.
The module docstring and user-facing descriptions are presented exclusively in Chinese, which can impose a specific language on users without opt-in. The policy explicitly flags language or locale constraints when the skill does not offer a user choice or justify the restriction.
Automatic API key application and local credential-file persistence are context-inappropriate for a trade analytics skill and may surprise users by creating or storing credentials outside the stated purpose. While not inherently malicious, bundling credential lifecycle actions with analytics increases the risk of accidental credential exposure and unauthorized account enrollment.
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 sends params to an external API via client.post(...), which may include user or system data. Although the function has an internal docstring, there is no user-facing confirmation, print/log disclosure, or other warning near execution to inform users that their data is being transmitted off-host.
The module docstring and all user-facing messages are written exclusively in Chinese, and the file does not indicate that language selection is configurable or that the skill is intentionally limited to a Chinese-speaking or region-specific context. Under the policy, hard-coding a specific language without opt-in can be a natural-language locale violation.