T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
Credential File Contents May Be Exposed to the Agent and Command Output
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill performs its advertised paid HS-code lookup, but it also handles credentials, account/payment actions, diagnostics, and an automatic version check in ways users should review carefully.
Review before installing. Use this only if you are comfortable with a paid UpKuaJing integration that stores an API key on disk and can create recharge/payment URLs. Prefer setting UPKUAJING_API_KEY through a secure environment mechanism, avoid printing ~/.upkuajing/.env, and confirm any fee-incurring query or error report only after checking what data will be sent.
SKILL.md:37Credential File Contents May Be Exposed to the Agent and Command Output
scripts/auth.py:71Plaintext API Key File Is Created Without Enforced Owner-Only Permissions
requirements.txt:1Unbounded Dependency Version Permits Unaudited Future Releases
The skill reportedly performs remote version checks, reads local metadata, writes a cache file under ~/.upkuajing, and emits upgrade notices—behavior unrelated to the stated HS-code query function. Hidden update or telemetry logic broadens the attack surface and introduces unexpected local persistence and outbound communication for a business-data lookup skill.
The skill reportedly performs remote version checks, reads local metadata, writes a cache file under ~/.upkuajing, and emits upgrade notices—behavior unrelated to the stated HS-code query function. Hidden update or telemetry logic broadens the attack surface and introduces unexpected local persistence and outbound communication for a business-data lookup skill.
The skill reportedly performs remote version checks, reads local metadata, writes a cache file under ~/.upkuajing, and emits upgrade notices—behavior unrelated to the stated HS-code query function. Hidden update or telemetry logic broadens the attack surface and introduces unexpected local persistence and outbound communication for a business-data lookup skill.
The instruction to run cat ~/.upkuajing/.env is a direct request to access a sensitive credential store. Because .env files commonly contain live API secrets, this behavior creates an obvious path for credential exposure, misuse of the user's paid account, and possible compromise of related services if the key is reused or insufficiently scoped.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
The skill instructs checking and manually modifying ~/.upkuajing/.env for API-key handling, and states that a newly created key will be automatically saved there. This encourages interaction with a local secret file and normalized persistence of credentials without clear safeguards, which increases the chance of accidental exposure or insecure storage practices.
### **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;
Directing the agent to inspect whether ~/.upkuajing/.env contains UPKUAJING_API_KEY still constitutes access to a secret-bearing file, even if the goal is only presence checking. In practice, such instructions often result in reading or echoing the file content, which is especially risky in an LLM-mediated environment where outputs may be logged or surfaced unintentionally.
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 skill is described as an HS-code trade-data query tool, but the file adds separate authentication lifecycle and billing capabilities such as API key provisioning, account lookup, recharge creation, and pricing retrieval. That scope expansion is dangerous because it gives the skill access to credential and payment-adjacent operations unrelated to the stated user task, increasing the attack surface and enabling abuse if invoked unexpectedly.
The code can request a new platform API key and persist it locally, which is an unjustified sensitive capability for a company HS-code listing skill. Provisioning credentials inside a data-retrieval skill creates a path for unauthorized credential creation, persistence, and later misuse, especially because the skill context does not require users to manage platform identity or secrets.
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 the API key into a local .env file in plaintext, creating durable credential exposure on disk. In the context of a skill that should only query HS-code data, credential persistence is especially risky because it enables later unauthorized use of platform access outside the user’s immediate action.
"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")
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 adds outbound exception reporting to a platform endpoint, which is outside the skill's declared purpose of HS code list retrieval. That hidden or undocumented behavior increases supply-chain risk because runtime context may be exfiltrated during failures, and users or integrators would not reasonably expect network transmission of diagnostic data from this skill.
The skill advertises executable behavior that can access environment variables, read and write local files, and make network requests, but it declares no explicit tool scope or permission boundary. That makes the skill harder to sandbox and review, and increases the risk that a caller or agent may invoke capabilities beyond what users expect from a simple HS-code query tool.
The skill explicitly instructs reading a local .env file containing the API key via a shell command, without any warning against exposing the secret in chat output or logs. In an agent setting, this can lead to direct credential disclosure to the model, the user, or telemetry systems, turning a normal setup step into a secret-exfiltration risk.
The API documentation explicitly encourages sending raw request parameters, response payloads, and exception context to a centralized error-reporting endpoint. Although it notes that sensitive fields will be automatically redacted, it does not define the redaction scope or require callers to minimize data before submission, creating a realistic risk of over-collection and leakage of confidential business data, personal data, tokens, or stack traces.
Using require_auth=False for /agent/auth/create establishes an unsafe default in this skill because a user invoking a data-query tool can reach credential-provisioning behavior without prior authentication. Given the mismatch between declared skill purpose and implemented capability, this increases risk and is more dangerous than it would be in a dedicated account-registration component.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
Using require_auth=False for /agent/auth/create establishes an unsafe default in this skill because a user invoking a data-query tool can reach credential-provisioning behavior without prior authentication. Given the mismatch between declared skill purpose and implemented capability, this increases risk and is more dangerous than it would be in a dedicated account-registration component.
pass # 如果读取失败,继续执行
# 不需要认证申请新密钥
response = make_request('/agent/auth/create', {}, require_auth=False)
# 检查是否申请成功
if response.get('code') != 0:
The code writes a newly issued API key directly to a local .env file on disk without a prior warning, opt-in, permission hardening, or use of a secure secret store. Storing credentials in plaintext files increases exposure to local compromise, accidental inclusion in backups or source control, and unauthorized reuse by other processes or users on the host.
The script exposes account balance, recharge-order creation, and pricing-management discovery that are unrelated to retrieving HS-code trade data. These functions reveal financial/account metadata and can trigger payment workflow actions, broadening the skill beyond its declared purpose and creating unnecessary risk if the capability is abused or called unintentionally.
The file’s human-facing natural language is exclusively Chinese, starting with the module description, and the code later emits only Chinese user-facing messages. Under the stated policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly documented and justified.