Back to skill

Security audit

电商批量内容工厂|AI-HIVE

Security checks for vulnerabilities and agentic risk

Overview

This AI-HIVE ecommerce media skill is broadly coherent, but it overstates batch-production safeguards and handles API keys, custom endpoints, and downloaded files in ways users should review before installing.

Install only if you trust AI-HIVE and need this Chinese ecommerce image/video workflow. Use a limited API key, avoid custom base URLs unless they are trusted HTTPS AI-HIVE endpoints, keep generated output in a non-sensitive directory, and expect batch deduplication/audit controls to be handled manually rather than enforced by the scripts.

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
scripts/imagegen.py:89
Finding

API Key Disclosure Through an Unrestricted API Base URL

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:89-99, 132-145, 585-587; mirrored in scripts/videogen.py:89-99, 132-145, 585-587
Vulnerability Type: Credential disclosure through an unvalidated endpoint override
Risk Level: Medium

Vulnerable Code

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
python
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="Verbose logging")

Technical Analysis

The client accepts an arbitrary base URL from a command-line argument, the AI_HIVE_BASE_URL environment variable, or the persistent configuration file. No validation requires HTTPS or restricts the destination to an approved AI-HIVE host.

Every API request includes the following authorization header:

python
self.headers = {
    "Authorization": f"Bearer {config.api_key}",
    "Content-Type": "application/json",
}

Consequently, an attacker who can influence the base URL can direct authenticated requests to an attacker-controlled service and capture the bearer API key. An HTTP URL can also expose the credential to network interception.

This is not covert exfiltration under the default configuration: the defaul ...[truncated 1071 chars]

Remediation
View remediation

Remediation Suggestions

  • Restrict normal operation to an explicit allowlist of approved API hosts.
  • Require the URL scheme to be https.
  • Reject URLs containing user information, fragments, unexpected ports, or non-approved hostnames.
  • Treat custom endpoints as an advanced opt-in feature that does not automatically reuse the production API key.
  • Require a separate credential for custom endpoints or display an explicit confirmation naming the destination receiving the key.
  • Ignore AI_HIVE_BASE_URL in privileged or automated execution contexts unless custom endpoints are explicitly enabled.
  • Validate the final URL immediately before each authenticated request to prevent malformed URL and redirect-related edge cases.
  • Disable redirects for authenticated API requests or ensure authorization headers are never forwarded to a different origin.
  • Apply the same correction to both imagegen.py and videogen.py.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:394
Finding

Arbitrary File Write Through Unsanitized API-Derived Output Names

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:394-416; mirrored in scripts/videogen.py:394-416
Vulnerability Type: Path traversal and arbitrary file overwrite
Risk Level: Medium

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 opened directly for writing:

python
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 and task_id without validating that they are safe filename components. taskType comes from the remote API response, while task_id comes from a generation response and is later used in polling.

Path separators, absolute path syntax, and traversal components are not removed. With a malicious or compromised API endpoint, a crafted taskType can make out_path resolve outside the selected output directory. The downloaded content is then opened with wb, which creates or truncates the destination.

For example, a malicious absolute taskType can cause Python's Path joining behavior to discard out_dir. Traversal sequences containing directory separators can similarly introduce unintended subdirectories where those directories already exist. Exploitability therefore depends ...[truncated 1397 chars]

Remediation
View remediation

Remediation Suggestions

  • Never use API-provided strings directly as filesystem path components.
  • Generate local filenames from trusted constants and locally generated identifiers, such as UUIDs.
  • If task metadata must appear in a filename, replace every character outside a narrow allowlist such as [A-Za-z0-9._-].
  • Remove path separators, drive prefixes, traversal components, control characters, and leading dots.
  • Resolve both the output directory and candidate destination, then verify that the destination remains beneath the output directory using Path.resolve() and Path.relative_to().
  • Refuse to overwrite an existing file, or use exclusive creation after obtaining explicit user confirmation.
  • Write to a temporary file in the approved output directory and atomically rename it after successful validation.
  • Enforce maximum download sizes and reject responses exceeding the configured limit.
  • Validate the response content type and, where practical, verify the file signature.
  • Apply the same correction to result files and last-frame files in both scripts.

T08 · Insecure Dependencies

Note
Location
scripts/imagegen.py:7
Finding

Third-Party Dependency Is Installed Without Version or Integrity Pinning

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:7, 18-22; mirrored in scripts/videogen.py:7, 18-22
Vulnerability Type: Unpinned third-party dependency
Risk Level: Low

Vulnerable Code

python
"""AI Hive OpenAPI Skill — generic AI capability client.

Dependency: requests (pip3 install requests)
"""
python
try:
    import requests
except ImportError:
    print("Missing dependency: requests. Run pip3 install requests", file=sys.stderr)
    sys.exit(1)

Technical Analysis

The project directs users to install requests without declaring a version range, lockfile, package hash, or reproducible environment. The package name is legitimate and is not evidence of a malicious dependency. However, installation behavior can vary over time and across package indexes.

If a future upstream release is compromised, incompatible, or maliciously replaced in a configured package mirror, users following the instruction may install code that was not reviewed with this project. Python packages can execute installation-time logic and are imported into the process with the user's privileges.

Attack Path

  1. A user runs the documented pip3 install requests command.
  2. Package resolution uses the user's configured index and selects the latest acceptable release because no version or hash is specified.
  3. The selected artifact is compromised, replaced by a malicious mirror, or otherwise differs from the tested dependency.
  4. Installation or subsequent import executes dependency code under the user's account.
  5. The malicious dependency can access the same files, environment variables, and API credentials available to the scripts.

Impact Assessment

A compromised dependency could execute arbitrary Python code with the privileges of the user running the installation or scripts. It could access AI_HIVE_API_KEY, the local AI-HIVE configuration, uploaded media, and generated ...[truncated 191 chars]

Remediation
View remediation

Remediation Suggestions

  • Add a dependency manifest with a tested version range.
  • Generate a lockfile containing exact versions and cryptographic hashes.
  • Install with hash verification, such as pip install --require-hashes -r requirements.txt.
  • Document the supported Python version and periodically update dependencies through a controlled review process.
  • Use trusted package indexes and prevent unreviewed index overrides in automated deployment.
  • Run dependency vulnerability and provenance checks in continuous integration.
  • Keep the dependency declaration shared between the two scripts to prevent version drift.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared purpose centers on controlled multi-SKU batch processing with deduplication, trial production, and auditable task-state handling, but the observed behavior is closer to single-task media generation plus undeclared generic functions. In this context, the mismatch is dangerous because users may assume the presence of safeguards against duplicate billing, unauthorized asset processing, and poor traceability when those protections may not actually exist.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared purpose centers on controlled multi-SKU batch processing with deduplication, trial production, and auditable task-state handling, but the observed behavior is closer to single-task media generation plus undeclared generic functions. In this context, the mismatch is dangerous because users may assume the presence of safeguards against duplicate billing, unauthorized asset processing, and poor traceability when those protections may not actually exist.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

The declared purpose centers on controlled multi-SKU batch processing with deduplication, trial production, and auditable task-state handling, but the observed behavior is closer to single-task media generation plus undeclared generic functions. In this context, the mismatch is dangerous because users may assume the presence of safeguards against duplicate billing, unauthorized asset processing, and poor traceability when those protections may not actually exist.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest promises receiving SKU tables, asset catalogs, brand rules, platform lists, production targets, and budgets, then delivering batch orchestration artifacts like SKU content matrices, template variables, task status, and sampling rules, with pre-processing steps like deduplication and grouping. The skill-facing code only offers per-request video generation plus task lookup and upload, with none of the claimed batch-planning or orchestration logic present.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises and demonstrates capabilities that involve environment variables, filesystem access, network access, and shell execution, but it does not declare any explicit tool scope or permission boundaries. That increases the risk of over-broad execution in hosts that infer or grant capabilities implicitly, making review, containment, and least-privilege enforcement harder.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The default prompt hard-codes output in Chinese regardless of the user's language preference, which can override user intent and reduce transparency or usability for non-Chinese-speaking users. In an agent setting, prompt-level coercion is a policy and safety concern because it changes system behavior without explicit user opt-in, though it does not directly enable code execution or data exfiltration.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file implements a broad, general-purpose AI API client with text chat, image/video generation, model enumeration, upload, task polling, and user-info access, while the declared skill is scoped to an ecommerce image-centric content factory. This capability mismatch expands the attack surface and can let callers use the skill as an unintended proxy for unrelated actions, including account inspection and broader content generation workflows not covered by the manifest.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains user-facing natural-language instructions and descriptions exclusively in Chinese, including the module docstring and later CLI help/output strings. Because the skill does not offer user opt-in for language/locale or document that it is intentionally region-specific, it can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The generic text chat command accepts arbitrary prompts and optional system instructions, allowing the skill to act as a general-purpose LLM interface unrelated to the stated ecommerce batch image factory purpose. In an agent setting, this can bypass intended policy boundaries by exposing undeclared capabilities and enabling prompt-driven misuse outside the approved workflow.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file is presented as a narrowly scoped ecommerce batch-content skill, but it embeds a reusable general-purpose AI API client with capabilities beyond the declared purpose, including chat, model enumeration, and generic media handling. This capability mismatch increases attack surface and violates least privilege, making it easier to repurpose the skill for unintended actions that operators may not expect or approve.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and subsequent user-facing CLI help and prompts are written in Chinese, establishing a fixed locale for interaction. The file does not provide an opt-in or alternative language path, which is a natural-language locale policy concern under the rule.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The client exposes a user-info endpoint that can reveal account metadata and wallet/balance information unrelated to the stated ecommerce video-generation purpose. Unnecessary access to account details broadens the blast radius if the skill is invoked in untrusted contexts and can disclose sensitive operational information to users or downstream logs.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The text-chat endpoint enables arbitrary general AI interactions that are unrelated to a specialized ecommerce batch image/video factory. In context, this hidden general-purpose capability can be abused to bypass intended skill scope, exfiltrate prompts or attached media to broader workflows, and use the skill as an unauthorized proxy to the provider API.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code hard-codes Chinese-language skill names and aliases in user-facing strings, including the module docstring, CLI description, and search aliases. Because no opt-in, alternative locale, or justification for a China-specific deployment is provided, this creates a natural-language locale policy concern under the stated rule.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The user-info endpoint exposes account metadata and wallet balance, which are not necessary for batch ecommerce content generation. Even if not highly sensitive on its own, it enables unnecessary data access and account reconnaissance, violating least-privilege expectations for a narrowly scoped skill.

Content

No source excerpt is available for this finding.