Back to skill

Security audit

跨境电商内容本地化|AI-HIVE

Security checks for vulnerabilities and agentic risk

Overview

The skill is not clearly malicious, but it handles API keys, media uploads, paid generation, and remote downloads with unsafe scoping that deserves careful review before installation.

Install only if you intend to use AI-HIVE for media generation and can tolerate API-key and billing exposure. Use a dedicated revocable API key, avoid custom base URLs, run from an isolated working directory, and review upload/download destinations and generated files carefully until endpoint and path validation are fixed.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/imagegen.py:122
Finding

Configurable API endpoint can disclose the bearer API key

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:122-143, 567-568; duplicated in scripts/videogen.py:122-143, 567-568
Vulnerability Type: Unrestricted authenticated endpoint configuration
Risk Level: High

Vulnerable Code

python
class AiHiveClient:
    """Encapsulates AI Hive OpenAPI HTTP calls."""

    def __init__(self, config):
        self.config = config
        self.base = config.base_url
        self.headers = {
            "Authorization": f"Bearer {config.api_key}",
            "Content-Type": "application/json",
        }

    def _url(self, path):
        return f"{self.base}/openapi/v1/{path}"

    def _request(self, method, url, **kwargs):
        self.config.log(f"{method} {url}")
        try:
            resp = requests.request(
                method, url, headers=self.headers, timeout=DEFAULT_TIMEOUT, **kwargs
            )
python
def add_common_args(parser):
    parser.add_argument("--api-key", help="AI Hive API Key (sk-api-*)")
    parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")
    parser.add_argument("--verbose", action="store_true", help="Detailed logging")

The endpoint may also be obtained from an environment variable or configuration file:

python
def _resolve_base_url(self, cli_url):
    if cli_url:
        return cli_url.rstrip("/")
    env_url = os.environ.get("AI_HIVE_BASE_URL")
    if env_url:
        return env_url.rstrip("/")
    file_config = self._read_config_file()
    if file_config.get("base_url"):
        return file_config["base_url"].rstrip("/")
    return DEFAULT_BASE_URL

Technical Analysis

The client automatically adds the AI-HIVE bearer token to every request made through _request. At the same time, the destination base URL can be supplied through --base-url, AI_HIVE_BASE_URL, or ~/.ai-hive/config.json.

No validation restricts ...[truncated 1668 chars]

Remediation
View remediation

Remediation Suggestions

  1. Require the https scheme for every authenticated API endpoint.
  2. Allow authenticated requests only to an explicit hostname allowlist, such as the documented AI-HIVE API hostname.
  3. Reject URLs containing user information, fragments, unsupported ports, ambiguous host encodings, or non-network schemes.
  4. If custom endpoints are required for development, require a separate opt-in flag and a separate credential that is not valid against production.
  5. Display a prominent confirmation before transmitting credentials to a non-default endpoint.
  6. Validate redirect destinations and prevent the authorization header from being forwarded to a different origin.
  7. Apply the same correction to both imagegen.py and videogen.py.
  8. Add tests covering plain HTTP URLs, deceptive subdomains, URL user information, alternate ports, redirects, and attacker-controlled environment variables.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/imagegen.py:395
Finding

Remote task metadata can escape the output directory and overwrite local files

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:395-412; duplicated in scripts/videogen.py:395-412
Vulnerability Type: Path traversal and unrestricted remote download
Risk Level: High

Vulnerable Code

python
out_dir = Path(output_dir)
out_dir.mkdir(parents=True, exist_ok=True)
task_type = task.get("taskType", "task")
for i, item in enumerate(succeeded):
    result_url = item.get("resultUrl")
    if not result_url:
        continue
    ext = ".mp4" if "video" in task_type.lower() else ".png"
    filename = f"{task_type}_{task_id}_{i+1}{ext}"
    out_path = out_dir / filename
    download_file(result_url, out_path)

# Last frame
for item in succeeded:
    last_frame = item.get("lastFrameUrl")
    if last_frame:
        out_path = out_dir / f"{task_type}_{task_id}_lastframe.png"
        download_file(last_frame, out_path)

The destination is then opened directly for writing:

python
def download_file(url, out_path, timeout=300):
    """Stream a file download while displaying progress."""
    print(f"[download] {out_path.name}")
    try:
        resp = requests.get(url, stream=True, timeout=timeout)
        resp.raise_for_status()
        total = int(resp.headers.get("content-length", 0))
        downloaded = 0
        with open(str(out_path), "wb") as f:
            for chunk in resp.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)

Technical Analysis

The output filename incorporates taskType, obtained from the remote task response, without sanitizing path separators or traversal components. The task_id is also originally obtained from a generation response and is subsequently reused in filenames.

Path(output_dir) / filename does not guarantee containment under output_dir. A malicious taskType containing components such as ../../ can cause the resolved destination to escape the ...[truncated 1724 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not derive local filenames from server-provided taskType values. Use fixed local prefixes such as image or video.
  2. Validate identifiers against a strict allowlist, for example ^[A-Za-z0-9_-]+$, before using them in a filename.
  3. Remove directory components with Path(value).name, while still rejecting any input that originally contained separators.
  4. Resolve the final path and verify containment before opening it:
    python
    base = Path(output_dir).expanduser().resolve()
    destination = (base / safe_filename).resolve()
    if destination.parent != base:
        raise SystemExit("Unsafe output path")
    
  5. Open newly generated files in exclusive mode where overwriting is unnecessary, or require explicit confirmation before replacement.
  6. Restrict download URLs to HTTPS and expected object-storage hostnames.
  7. Disable redirects or revalidate the scheme and hostname after each redirect.
  8. Consider download-size limits and content-type validation to prevent resource exhaustion and unexpected file content.
  9. Apply identical hardening to both scripts and test traversal values containing ../, backslashes, encoded separators, absolute paths, and platform-specific path syntax.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:268
Finding

Remote upload instructions can exfiltrate user-selected media

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:268-303; duplicated in scripts/videogen.py:268-303
Vulnerability Type: Unvalidated remote upload destination and method
Risk Level: Medium

Vulnerable Code

python
def upload_media(client, file_path):
    """Three-step upload: upload-token, PUT, complete. Returns mediaId."""
    path = Path(file_path)
    if not path.is_file():
        raise SystemExit(f"File does not exist: {file_path}")

    filename = path.name
    content_type = guess_mime(str(path))
    size = path.stat().st_size

    print(f"[1/3] Creating upload credential: {filename} ({content_type}, {size} bytes)")
    token = client.create_upload_token(filename, content_type, size)

    media_id = token["mediaId"]
    upload_url = token["upload"]["url"]
    upload_method = token["upload"].get("method", "PUT")
    upload_headers = token["upload"].get("headers", {})

    # Upload to object storage without the API key, using returned headers
    print(f"[2/3] Uploading file to object storage...")
    with open(str(path), "rb") as f:
        try:
            oss_resp = requests.request(
                upload_method, upload_url, headers=upload_headers,
                data=f, timeout=300,
            )
        except requests.exceptions.RequestException as e:
            raise SystemExit(
                f"Object-storage upload network error: {e}\n"
                "Check the network connection or file size"
            )
    if not oss_resp.ok:
        try:
            detail = oss_resp.text
        except Exception:
            detail = "<unable to read response>"
        raise SystemExit(f"Object-storage upload failed ({oss_resp.status_code}): {detail}")

    print(f"[3/3] Confirming upload completion...")
    result = client.complete_upload(media_id)
    print(f"[ok] mediaId = {media_id}")
    return media_id

Technical

...[truncated 1845 chars]

Remediation
View remediation

Remediation Suggestions

  1. Require HTTPS for all upload destinations.
  2. Validate the upload hostname against an explicit allowlist of trusted object-storage domains.
  3. Restrict the HTTP method to the minimum supported set, normally PUT or POST.
  4. Validate returned headers and reject sensitive, unexpected, or hop-by-hop headers.
  5. Disable redirects for upload operations, or validate every redirect target before transmitting any file bytes.
  6. Show the normalized destination hostname and file size before uploading sensitive content, especially when it differs from the default service.
  7. Consider requiring interactive approval for uploads to newly encountered storage origins.
  8. Enforce local file-size and permitted-type limits before opening the file.
  9. Apply the same validation logic to imagegen.py and videogen.py through a shared, centrally tested network utility.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (20)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Again, the issue is a documentation-to-capability mismatch: the skill claims structured localization outputs but appears to support broader account/API setup, model enumeration, chat, and media orchestration. Such mismatches undermine least surprise and security review, because operators may approve a narrowly described business skill that can actually perform more expansive external interactions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

Again, the issue is a documentation-to-capability mismatch: the skill claims structured localization outputs but appears to support broader account/API setup, model enumeration, chat, and media orchestration. Such mismatches undermine least surprise and security review, because operators may approve a narrowly described business skill that can actually perform more expansive external interactions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

Again, the issue is a documentation-to-capability mismatch: the skill claims structured localization outputs but appears to support broader account/API setup, model enumeration, chat, and media orchestration. Such mismatches undermine least surprise and security review, because operators may approve a narrowly described business skill that can actually perform more expansive external interactions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The file presents itself as a cross-border ecommerce localization skill, but its implementation is a broad AI-Hive client that exposes generic chat, media generation, model discovery, upload, and account-related operations. This capability mismatch is dangerous because users and orchestrators may grant or invoke the skill under a narrow business purpose while actually enabling a much wider set of actions than advertised.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The generated skill interface is a generic video-generation front end, not a localization workflow. In the context of a supposedly localization-focused skill, this hidden expansion of scope increases the risk of policy bypass, misuse of platform credits, and execution of unintended content-generation tasks under misleading metadata.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill advertises executable scripts that use environment variables, local files, network access, and shell commands, but it declares no explicit tool scope or permission boundaries. That creates an authorization gap where an agent or reviewer cannot tell what operations are intended, increasing the risk of over-privileged execution, secret exposure, unintended file access, or external API calls.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The entire skill description, invocation guidance, workflow, and output instructions are written only in Chinese, with no indication that the user may choose another language or that the skill is intentionally limited to a Chinese-speaking audience for compliance reasons. This creates a locale/language constraint without explicit opt-in or documented justification.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger conditions are very broad, matching generic terms like Amazon, TikTok Shop, overseas marketing, and requests for scripts or task lists. Overbroad invocation can cause the skill to activate in contexts where the user did not intend external generation, file operations, or specialized workflow behavior, increasing the chance of accidental data disclosure, wrong-tool use, or unnecessary paid API activity.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The default prompt hard-codes output in Chinese regardless of the user's preferred language, which can override user intent and create misleading or unusable responses for non-Chinese-speaking users. In an agent setting, this is a prompt-level behavior constraint that reduces transparency and can cause downstream workflow errors if users assume language preference will be respected.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file is presented as a narrowly scoped cross-border ecommerce localization/image skill, but the implementation embeds a broader generic AI/OpenAPI client with unrelated operations. This capability mismatch increases attack surface and makes it easier for callers or downstream agents to invoke functions outside the user's expected consent boundary.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The module docstring and surrounding user-facing text present the skill as operating in Chinese only, and the rest of the CLI prompts/help messages are also Chinese-only. This imposes a specific language/locale on users without offering a choice or documenting a justified regional constraint, which matches the language/locale policy violation category.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill can query user account information and wallet balance even though that functionality is unrelated to localization or image generation. In an agent setting, this creates unnecessary access to sensitive account metadata and billing information that a user would not reasonably expect this skill to access.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code exposes generic text-chat functionality that falls outside the declared ecommerce-localization image skill scope. Broad chat access can be repurposed for unintended prompt handling, data exfiltration, or policy bypass workflows because it provides a general-purpose model invocation path not aligned to the skill contract.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The presence of full video-generation support is inconsistent with the skill's advertised image/localization role and materially expands what the skill can do. Extra media-generation pathways increase the chance of misuse, larger data handling, and invocation of higher-risk capabilities without clear user awareness or approval.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring explicitly describes a generic AI capability invocation tool, which conflicts with the manifest identity of a dedicated localization skill. This kind of contradictory self-description is a strong indicator of scope deception or poor packaging hygiene, both of which undermine reviewability and can conceal unexpected capabilities.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Retrieving user account and wallet information is not necessary for cross-border ecommerce localization output generation. Exposing this function in a mismatched skill broadens access to potentially sensitive billing and identity data, creating unnecessary privacy and information-disclosure risk if the skill is invoked or repurposed.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Model enumeration and generic model lookup expose broader platform capabilities than required for a localization-specific tool. This can help an operator or downstream agent discover and access unintended models, increasing the blast radius of the skill and making abuse easier when the skill is trusted for a narrower purpose.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

A top-level arbitrary media upload feature is broader than needed for a localization skill and can be abused to stage or transfer unrelated content through the integrated platform. In this context, the mismatch is especially concerning because callers may not expect the skill to function as a generic media-ingestion utility.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code embeds the skill name and argument parser description entirely in Chinese, which signals a fixed language/locale presentation. The file does not indicate that Chinese is optional, user-selectable, or required for a documented region-specific purpose, so it falls under the language/locale policy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The top-level docstring says this is a '通用 AI 能力调用工具' and the main parser description repeats that it is a generic AI Hive OpenAPI skill. Later, the file hard-codes SKILL_CONFIG for the specific 'cross-border-ecommerce-localization-ai-hive' skill, so the inline documentation presents a materially different intent from the specialized skill wrapper actually shipped in this file.

Content

No source excerpt is available for this finding.