T09 · Insecure Skill Coding Practices
- Location
scripts/auth.py:73- Finding
API Key Exposure Through Terminal Output and Insecure Credential File Creation
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill performs the advertised customs-port lookup, but it also handles API keys, billing/account actions, and automatic update checks in ways users should review before installing.
Install only if you are comfortable giving the skill access to an UpKuaJing API account, local ~/.upkuajing files, and billing-related account operations. Do not let an agent print the full .env file; prefer an environment variable or a securely permissioned secret file, confirm every paid query or recharge action explicitly, and review any error report payload before sending it.
scripts/auth.py:73API Key Exposure Through Terminal Output and Insecure Credential File Creation
requirements.txt:1Unbounded Third-Party Dependency Version
Remote version checks, local version cache writes, and upgrade notifications are outside the stated purpose of querying port trade data. While often operationally useful, these hidden side behaviors create extra outbound communication and local file activity that are unnecessary for the user-visible task and could be abused or simply violate least-privilege expectations.
Remote version checks, local version cache writes, and upgrade notifications are outside the stated purpose of querying port trade data. While often operationally useful, these hidden side behaviors create extra outbound communication and local file activity that are unnecessary for the user-visible task and could be abused or simply violate least-privilege expectations.
Remote version checks, local version cache writes, and upgrade notifications are outside the stated purpose of querying port trade data. While often operationally useful, these hidden side behaviors create extra outbound communication and local file activity that are unnecessary for the user-visible task and could be abused or simply violate least-privilege expectations.
Remote version checks, local version cache writes, and upgrade notifications are outside the stated purpose of querying port trade data. While often operationally useful, these hidden side behaviors create extra outbound communication and local file activity that are unnecessary for the user-visible task and could be abused or simply violate least-privilege expectations.
The skill explicitly instructs reading ~/.upkuajing/.env, which is a credential store containing the API key. In an agent environment, direct access to local secret files is sensitive because it exposes reusable credentials that could be leaked, reused for unauthorized API calls, or combined with broader tool access.
This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:
cat ~/.upkuajing/.env
Example file content:
This workflow tells the agent to inspect the user's credential file and potentially initiate API key creation that is automatically written to disk. That combines secret discovery with credential lifecycle management in a skill whose main purpose is data retrieval, increasing the risk of unauthorized key handling and silent persistence of sensitive material.
### **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 again directs access to ~/.upkuajing/.env and supports automatically saving a newly created key there. Repeated emphasis on local credential-file handling makes the skill more dangerous in context because the advertised business-query task does not require exposing or manipulating raw secret storage to the agent.
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 advertised as a paginated customs port trade query tool, but the file implements account provisioning, billing, recharge, and pricing functions. That hidden scope expansion is dangerous because it introduces privileged financial and credential-management capabilities unrelated to the stated purpose, increasing the chance of unauthorized API key issuance, misuse of billing features, and user deception.
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 code writes a newly issued API key directly into a plaintext .env file under the user's home directory. Plaintext secret storage increases the risk of credential compromise through local file disclosure, backups, misconfigured permissions, malware, or accidental inclusion in support bundles and sync tools.
"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'
# 日志开关
The file's behavior does not match the declared skill purpose: instead of querying company port trade data, it reports execution errors to a platform endpoint. This hidden or undocumented capability increases supply-chain risk because operators may deploy a skill expecting analytics while it also transmits runtime metadata off-box.
The skill declares no explicit tool restrictions even though the documented behavior requires access to environment variables, local files, and networked APIs. In an agent setting, missing scope boundaries increases the chance that the skill can read credentials, modify local state, or make outbound requests beyond what a user would reasonably expect from a simple trade-data lookup.
The document explicitly instructs callers to send requestParams, responseData, and free-form context to an error-reporting endpoint. Even though it states sensitive fields are 'automatically desensitized,' there is no explicit requirement to minimize data, redact secrets before submission, or warn users that business data, identifiers, or stack traces may be transmitted to the platform. In a customs/trade analytics skill, these fields can contain commercially sensitive trade data, company identifiers, or internal error details, creating a real privacy and data-exposure risk.
This code file contains user-facing descriptions and messages exclusively in Chinese, including the module docstring and CLI help text. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified.
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:
Account balance lookup and pricing discovery expose account metadata and commercial information that are unrelated to port-trade analytics. In context, this creates unnecessary access to sensitive account details and signals that the skill does more than advertised, which can facilitate reconnaissance or misuse of the associated platform account.
The recharge-order creation capability lets the skill initiate billing-related actions even though the stated functionality is logistics analytics. Unrelated payment flows in a data-query skill expand the attack surface and may enable unexpected financial operations or trick users into approving charges.
This code sends params to a remote API via client.post(...), and when authentication is required it also includes a bearer token in the request headers. Although the function has an internal docstring, there is no user-facing confirmation, print/log disclosure by default, or explicit warning here that user or system data may be transmitted off-host.