T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
Documentation Instructs Users to Expose the Complete API Key
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a real UpKuaJing date API helper, but it handles API keys, billing/account operations, and hidden update-check persistence in ways users should review before installing.
Review this skill before installing. Do not let an agent print or paste the contents of `~/.upkuajing/.env`; use a secret manager or environment variable if possible, and if the file is used, keep `~/.upkuajing` owner-only and the `.env` file mode `0600`. Only approve billable queries, top-up/payment-order creation, and error reports when you understand what will be sent to UpKuaJing. Be aware that normal API calls also trigger an undocumented version check and local cache write.
SKILL.md:37Documentation Instructs Users to Expose the Complete API Key
scripts/auth.py:71API Key File Is Created Without Explicitly Restrictive Permissions
requirements.txt:1Unbounded and Unlocked Third-Party Dependency
The documented functionality includes version checking, reading local metadata, writing a cache under ~/.upkuajing, and emitting upgrade notices, none of which are implied by a simple date-reference skill. This hidden auxiliary behavior expands the attack surface with unnecessary network and filesystem access and makes the skill less predictable in restricted environments.
The documented functionality includes version checking, reading local metadata, writing a cache under ~/.upkuajing, and emitting upgrade notices, none of which are implied by a simple date-reference skill. This hidden auxiliary behavior expands the attack surface with unnecessary network and filesystem access and makes the skill less predictable in restricted environments.
The documented functionality includes version checking, reading local metadata, writing a cache under ~/.upkuajing, and emitting upgrade notices, none of which are implied by a simple date-reference skill. This hidden auxiliary behavior expands the attack surface with unnecessary network and filesystem access and makes the skill less predictable in restricted environments.
The documented functionality includes version checking, reading local metadata, writing a cache under ~/.upkuajing, and emitting upgrade notices, none of which are implied by a simple date-reference skill. This hidden auxiliary behavior expands the attack surface with unnecessary network and filesystem access and makes the skill less predictable in restricted environments.
The skill instructs reading ~/.upkuajing/.env directly and even shows a command to print it, which can expose API keys and other secrets in cleartext. In an agent setting, normalizing direct secret-file access increases the chance of credential disclosure to logs, transcripts, or unauthorized components.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
The workflow explicitly checks for API keys in a local .env file and supports automatically saving newly created keys there. This couples the skill to local credential-store inspection and modification, creating both read and write risk for secrets and increasing the blast radius if the skill is misused or compromised.
### **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 documented flow encourages checking and populating a plaintext local .env credential file as part of normal skill operation. Making credential-file access part of the expected workflow materially raises the risk of secret leakage, unauthorized overwrites, and persistence of sensitive data in insecure local storage.
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, billing, and pricing operations, which are unrelated to the declared purpose of a date-reference helper. This capability mismatch is dangerous because it expands the skill’s privileges and attack surface beyond user expectations, enabling credential provisioning and financial/account actions under misleading packaging.
This code explicitly targets a .env file for API key handling, indicating credential material is read from local plaintext configuration. Accessing and managing secrets in this manner increases the risk of leakage through filesystem access, backups, logs, or accidental check-in.
"""
申请新的 API 密钥。
"""
# 检查是否已存在 .env 文件和 API key
env_file = UPKUAJING_ENV_FILE
if env_file.exists():
The script opens and reads the .env file contents to discover an existing API key. Reading secrets from plaintext local storage broadens the credential exposure surface and is particularly concerning in a skill whose advertised purpose does not justify secret management.
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 code exposes account-management and payment-related capabilities that are unjustified for a date utility. In a misleading skill context, these functions can be abused to create credentials, enumerate account data, or initiate recharge/payment flows that users and reviewers would not expect.
The code writes the API key directly into a .env file in plaintext. Plaintext persistence of live credentials can lead to credential theft by local users, malware, backups, or accidental upload, enabling unauthorized API access and possible account or billing abuse.
"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'
# 日志开关
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
def load_env_file() -> Dict[str, str]:
"""
从 ~/.upkuajing/.env 文件加载环境变量。
Returns:
环境变量字典
This file implements remote exception reporting that is unrelated to the declared purpose of a date-reference skill. It sends operational metadata and free-form context to an external endpoint, which expands the skill's data flows and creates a risk of unintended data exfiltration if request identifiers, paths, or context contain sensitive user or system information.
This module performs outbound network requests and persists cache state even though the advertised skill purpose is only to provide date reference values. That hidden side-effect expands the trust boundary, can leak environment usage metadata to a remote service, and introduces unnecessary external dependency and persistence behavior that users would not reasonably expect from this skill.
The skill advertises executable behaviors that include environment access, local file read/write, and network use, but it declares no explicit tool scope or permission boundaries. This creates an over-privileged and poorly constrained skill surface, making unintended credential access, file modification, or remote calls more likely if the skill is invoked in an automated agent environment.
The manifest description lists trigger terms such as "last year" and "last month" alongside a generic "date reference" phrase. In a markdown/manifest context, these are broad enough to match ordinary conversation outside the intended customs-trade domain, and the file does not provide exclusion conditions or tighter activation scope in the trigger field.
The document instructs agents to send request parameters, response data, and error context to a platform error-reporting API, which can include sensitive operational or user data. Although it notes that sensitive fields are automatically redacted, it does not provide an explicit warning, consent model, or minimization guidance, so users or integrators may transmit confidential information unintentionally.
This Python file contains natural-language descriptions, CLI help text, and user-visible messages exclusively in Chinese. Under the policy, forcing a specific language without offering a user choice or documenting a justified locale constraint is a natural-language policy violation.
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: