Back to skill

Security audit

Search HS codes for analysis reports — find matching HS (Harmonized System) codes by product name and HS code keywords from customs trade data. Returns a list of relevant HS codes that can be used in other analysis report skills for deeper trade data queries. Designed for trade analysts, exporters and import-export professionals who need to locate the correct customs classification codes for specific products before conducting trade data analysis, market research or competitor monitoring across global customs data.

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a disclosed paid HS-code lookup integration, but its credential handling can expose a billable API key and deserves review before installation.

Install only if you are comfortable with a paid UpKuaJing API workflow. Do not let the agent print ~/.upkuajing/.env; configure the API key through a safer secret mechanism where possible, restrict permissions on any local key file, and require explicit confirmation for fee-incurring queries, top-up orders, and error reports.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:37
Finding

API Key Disclosure Through Terminal Output

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 37–46
Vulnerability Type: Credential exposure through unsafe operational instructions
Risk Level: Medium

Vulnerable Code

markdown
This skill requires an API key. The API key is stored in the `~/.upkuajing/.env` file:
```bash
cat ~/.upkuajing/.env

Example file content:

text
UPKUAJING_API_KEY=your_api_key_here

API Key Not Set

First check if the ~/.upkuajing/.env file has UPKUAJING_API_KEY;

text

### Technical Analysis

The Skill explicitly instructs the Agent to display the entire credential file with `cat`. Although accessing the API key is required for authenticated requests, exposing its plaintext value through standard output is not necessary.

Executing this instruction can place the API key in terminal transcripts, Agent conversation context, command-capture logs, screen recordings, debugging output, or other downstream systems that process command results. The file may also contain additional variables in the future, all of which would be disclosed by the same command.

The Python implementation already retrieves the required key internally, so there is no functional need to print the credential file.

### Attack Path

1. A user invokes the Skill without an API key available in the process environment.
2. The Agent follows the instructions in `SKILL.md`.
3. The Agent executes `cat ~/.upkuajing/.env`.
4. The complete API key appears in captured terminal or tool output.
5. A party with access to the transcript, logs, shared display, or Agent context obtains the key.
6. The exposed key is used to issue authenticated and potentially billable API requests.

### Impact Assessment

Exploitation does not grant operating-system privileges, but it can disclose the user's UpKuaJing API credential. An attacker could impersonate the credential owner within the API's authorized scope, consume account balance, retriev
...[truncated 261 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the instruction to execute cat ~/.upkuajing/.env.
  2. Check only whether the required variable exists, without printing its value.
  3. Keep credential retrieval entirely inside the Python client.
  4. If diagnostic output is necessary, report only whether the key is configured, such as UPKUAJING_API_KEY is set, without displaying any portion of the value.
  5. Ensure tool and Agent output never contains secrets.
  6. Update the documentation to prefer process environment variables or a system credential store over plaintext inspection.
  7. Advise users to rotate any key that has already appeared in terminal, Agent, or application logs.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/auth.py:63
Finding

API Key File Is Created Without Explicit Restrictive Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/auth.py, lines 63–74
Vulnerability Type: Insecure local storage of a plaintext API credential
Risk Level: Medium

Vulnerable Code

python
# 确保 ~/.upkuajing 目录存在
try:
    UPKUAJING_DIR.mkdir(parents=True, exist_ok=True)
except OSError as e:
    return {
        "success": False,
        "message": f"API密钥申请成功,但创建目录失败:{str(e)}。\n请手动创建目录 {UPKUAJING_DIR} 并设置环境变量 {API_KEY_ENV}。",
        "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")

Technical Analysis

The script stores the newly issued API key in plaintext under ~/.upkuajing/.env, but it does not explicitly set restrictive permissions on either the directory or the file. Their effective permissions depend on the process umask and existing filesystem state.

Under a permissive umask, the resulting credential file may be readable by other local users. If the directory or target file already exists with unsafe permissions, opening the file with w does not correct those permissions.

The write also follows filesystem links. The implementation does not verify that the destination is a regular file owned by the current user, creating an additional local risk where an attacker able to manipulate the path could redirect or expose the credential.

Writing a persistent credential is part of the declared key-creation flow, but relying on ambient permissions exceeds the minimum safe access model for secret storage.

Attack Path

  1. An attacker has access to another local account or can influence the existing ~/.upkuajing path.
  2. The victim runs python scripts/auth.py --new_key.
  3. The API returns a newly generated key.
  4. The script creates or overwrites .env using permissions inherited from the environment or existing file.
  5. The attacker reads the file if it is accessi ...[truncated 650 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create ~/.upkuajing with mode 0700.
  2. Create the credential file with mode 0600, independent of the process umask.
  3. Apply restrictive permissions to an existing credential file before writing.
  4. Reject symbolic links and verify that the destination is a regular file owned by the current user.
  5. Write the key to a securely created temporary file in the same directory, set mode 0600, flush it, and atomically replace the destination.
  6. Avoid returning or logging the key value, including partial values.
  7. Prefer an operating-system credential manager where available.
  8. Add automated tests that verify directory and file permissions after key creation.

A hardened implementation should use secure creation flags such as os.O_CREAT | os.O_EXCL | os.O_WRONLY with mode 0o600, or an equivalent safe atomic-replacement design.

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Unpinned Third-Party HTTP Dependency

Content
View full analysis

Vulnerability Details

File Location: requirements.txt, line 1
Vulnerability Type: Non-reproducible and unrestricted dependency resolution
Risk Level: Low

Vulnerable Code

text
httpx>=0.23.0

Technical Analysis

The dependency specification provides only a lower version boundary. Installation can therefore resolve to any future httpx release accepted by the package resolver. This prevents reproducible builds and means code not reviewed as part of this audit may be installed later.

No evidence of typosquatting, dependency confusion, a malicious package, or an unsafe package source was found. The risk arises from permitting future, unaudited releases and from the absence of package hashes or a lock file.

A future compromised or incompatible dependency release could affect all network operations, including requests carrying the bearer API credential.

Attack Path

  1. A user follows the documented setup process and runs pip install -r requirements.txt.
  2. The package resolver selects a newer release than the version reviewed and tested by the project.
  3. That release, or one of its transitive dependencies, contains malicious or incompatible behavior.
  4. Installation hooks or imported runtime code execute in the user's environment.
  5. Malicious runtime behavior could inspect process data, intercept authenticated requests, or access files available to the Python process.

This is a supply-chain exposure rather than evidence that the current named dependency is malicious.

Impact Assessment

If a resolved package release were compromised, code could execute with the privileges of the user installing or running the Skill. That scope may include access to UPKUAJING_API_KEY, ~/.upkuajing/.env, project files, network connectivity, and other resources available to the process.

The present likelihood is assessed as low because the audit found no indication that httpx itself or the ...[truncated 128 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin httpx to a specific version that has been reviewed and tested.
  2. Pin all transitive dependencies through a generated lock file.
  3. Use cryptographic hashes with pip --require-hashes for reproducible installation.
  4. Configure dependency-update automation to submit reviewed version changes rather than accepting arbitrary future releases.
  5. Run dependency vulnerability scanning in continuous integration.
  6. Install dependencies in an isolated virtual environment under a non-privileged account.
  7. Periodically update the locked versions after security review and compatibility testing.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (38)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Version checking, reading local metadata, writing cache files in the user's home directory, and printing upgrade notices are unrelated to the declared lookup purpose and expand both file-system and network behavior. Undisclosed self-update or telemetry-style mechanisms create unnecessary trust and integrity risks in a skill expected to perform a narrow data query.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Version checking, reading local metadata, writing cache files in the user's home directory, and printing upgrade notices are unrelated to the declared lookup purpose and expand both file-system and network behavior. Undisclosed self-update or telemetry-style mechanisms create unnecessary trust and integrity risks in a skill expected to perform a narrow data query.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Version checking, reading local metadata, writing cache files in the user's home directory, and printing upgrade notices are unrelated to the declared lookup purpose and expand both file-system and network behavior. Undisclosed self-update or telemetry-style mechanisms create unnecessary trust and integrity risks in a skill expected to perform a narrow data query.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

The skill instructs reading the entire ~/.upkuajing/.env file with cat in order to obtain an API key. Directly accessing a local secrets file is dangerous because it may expose not only the intended credential but any other secrets stored there to the agent, logs, or downstream tools.

Content

Scanner excerpt · SKILL.md (reported line 39)May include surrounding context.

This skill requires an API key. The API key is stored in the ~/.upkuajing/.env file:

bash
cat ~/.upkuajing/.env

Example file content:

text

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

The workflow explicitly checks for and potentially persists credentials in ~/.upkuajing/.env, coupling a simple search skill with local credential discovery and storage. This increases the risk of unauthorized secret access, accidental disclosure, and persistence of sensitive tokens on disk beyond what is necessary for the task.

Content

Scanner excerpt · SKILL.md (reported line 48)May include surrounding context.

md
### **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;

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

Automatically saving a newly created API key into ~/.upkuajing/.env encourages plaintext credential persistence in the user's home directory. In the context of a lookup skill, this is especially risky because it broadens the skill from query execution into secret provisioning and local secret management without strong isolation.

Content

Scanner excerpt · SKILL.md (reported line 49)May include surrounding context.

md
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**

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The file implements authentication, account provisioning, balance lookup, and recharge functions that are unrelated to the advertised HS code search capability. This scope mismatch is dangerous because users or platforms may grant the skill permissions and trust appropriate for tariff lookup, while the code introduces financially sensitive account-management behavior that can be abused or surprise operators.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth.py (reported line 18)May include surrounding context.

python
"""
    申请新的 API 密钥。
    """
    # 检查是否已存在 .env 文件和 API key
    env_file = UPKUAJING_ENV_FILE

    if env_file.exists():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth.py (reported line 22)May include surrounding context.

python
"""
    申请新的 API 密钥。
    """
    # 检查是否已存在 .env 文件和 API key
    env_file = UPKUAJING_ENV_FILE

    if env_file.exists():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/common.py (reported line 63)May include surrounding context.

python
"""
    申请新的 API 密钥。
    """
    # 检查是否已存在 .env 文件和 API key
    env_file = UPKUAJING_ENV_FILE

    if env_file.exists():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/common.py (reported line 85)May include surrounding context.

python
"""
    申请新的 API 密钥。
    """
    # 检查是否已存在 .env 文件和 API key
    env_file = UPKUAJING_ENV_FILE

    if env_file.exists():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/common.py (reported line 90)May include surrounding context.

python
"""
    申请新的 API 密钥。
    """
    # 检查是否已存在 .env 文件和 API key
    env_file = UPKUAJING_ENV_FILE

    if env_file.exists():

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

The code writes a newly provisioned API key into a local .env file, which can be insecure if permissions are too broad, the file is accidentally committed, or other local users/processes can read it. In the context of an unrelated HS code skill, silently creating and persisting credentials increases the risk of secret leakage and unauthorized API use.

Content

Scanner excerpt · scripts/auth.py (reported line 71)May include surrounding context.

python
"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")

Credential Access

High
Category
Privilege Escalation
Confidence
82% confidence
Finding

The script instructs the user to manually set the API key as an environment variable after a file-write failure, reflecting continued insecure secret-handling patterns around credential material. While not exfiltration by itself, this contributes to unsafe credential lifecycle management and is more concerning because the skill's declared purpose does not justify credential provisioning at all.

Content

Scanner excerpt · scripts/auth.py (reported line 78)May include surrounding context.

python
except IOError as e:
        return {
            "success": False,
            "message": f"API密钥申请成功,但保存到 .env 文件失败:{str(e)}。\n请手动设置环境变量 {API_KEY_ENV}。",
            "envFilePath": str(env_file)
        }

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script can create recharge orders and return payment URLs even though the skill is presented only as an HS code lookup tool. In this context, hidden payment initiation functionality is risky because it enables unexpected financial workflows and could be used to trick users or consume funds outside the skill's stated purpose.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/common.py (reported line 19)May include surrounding context.

python
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'

# 日志开关

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The file implements remote error reporting functionality that is not part of the stated HS code search purpose, which expands the skill's capability surface beyond user expectations. Even if intended for observability, hidden telemetry in a narrowly scoped customs lookup skill can exfiltrate request metadata and error context to an external service and complicates trust and review.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares executable capabilities involving environment access, local file access, and network use, but does not constrain them with an explicit tool scope. That increases the blast radius if the skill is invoked in an agent environment, because the runtime may permit broader operations than users would reasonably expect from an HS code lookup skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file’s natural-language instructions and API reference are entirely in Chinese, and there is no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation explicitly instructs sending request parameters, response payloads, and exception context to an error-reporting endpoint, which can easily include sensitive business data, tokens, personal data, or internal system details. Although it mentions automatic masking of sensitive fields, it does not define what is masked, require data minimization, or warn users to avoid transmitting secrets, so this creates a real privacy and information disclosure risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring and all user-facing CLI descriptions/messages are written only in Chinese, indicating a fixed language choice for the skill. Under the policy, language constraints should either offer user opt-in/choice or be clearly documented as region-specific and justified, which is not present here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script provisions new API keys despite the skill being described as an HS code search tool. Generating and storing credentials introduces secret-management and unauthorized-access risk, especially when users and reviewers would not expect the skill to perform account bootstrap operations.

Content

No source excerpt is available for this finding.

Unsafe Defaults

Medium
Category
Tool Misuse
Confidence
93% confidence
Finding

Using require_auth=False on the credential-creation endpoint weakens the security posture by making the client assume no authentication is needed for a sensitive operation. In a skill that should only search HS codes, this unexpected unauthenticated provisioning path materially increases risk and indicates poor security boundaries.

Content

Scanner excerpt · scripts/auth.py (reported line 41)May include surrounding context.

python
pass  # 如果读取失败,继续执行

    # 不需要认证申请新密钥
    response = make_request('/agent/auth/create', {}, require_auth=False)

    # 检查是否申请成功
    if response.get('code') != 0:

Unsafe Defaults

Medium
Category
Tool Misuse
Confidence
93% confidence
Finding

Using require_auth=False on the credential-creation endpoint weakens the security posture by making the client assume no authentication is needed for a sensitive operation. In a skill that should only search HS codes, this unexpected unauthenticated provisioning path materially increases risk and indicates poor security boundaries.

Content

Scanner excerpt · scripts/auth.py (reported line 41)May include surrounding context.

python
pass  # 如果读取失败,继续执行

    # 不需要认证申请新密钥
    response = make_request('/agent/auth/create', {}, require_auth=False)

    # 检查是否申请成功
    if response.get('code') != 0:

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code retrieves account profile and balance information that is unrelated to HS code search. This expands the data-access scope to sensitive account and financial information, increasing privacy and abuse risk if the skill is installed or invoked under the assumption that it only performs customs-code queries.

Content

No source excerpt is available for this finding.