Back to skill

Security audit

AI大模型专家|302.AI 替代方案|AI-HIVE

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a real AI-HIVE migration and sample-generation helper, but it needs Review because it stores API keys and uses under-scoped network destinations for credentials, media uploads, and downloads.

Install only if you intend to run an operational AI-HIVE client, not just read migration advice. Use a low-privilege test API key, avoid custom base URLs unless you fully trust the endpoint and config file, run samples on non-sensitive media first, and review output paths before allowing downloads or ffmpeg writes.

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:92
Finding

Bearer Credential Disclosure Through an Unrestricted API Base URL

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:92-100, 128-143; equivalent implementation in scripts/videogen.py:92-100, 128-143
Vulnerability Type: Unvalidated credential destination
Risk Level: High

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

Technical Analysis

The API base URL can be supplied through the --base-url command-line argument, the AI_HIVE_BASE_URL environment variable, or the persistent configuration file. The value is used without validating its scheme, hostname, port, or origin.

The client subsequently attaches the AI-HIVE bearer credential to every request made to that destination. Consequently, an HTTP URL or attacker-controlled HTTPS endpoint can receive the credential. Plain HTTP additionally exposes the credential to network interception.

The same vulnerable client implementation appears in both image and video generation scripts.

Attack Path

  1. An attacke ...[truncated 1125 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require https for every credential-bearing endpoint and reject plaintext HTTP.
  2. Allowlist the official AI-HIVE API hostname by default.
  3. If custom endpoints are necessary, require an explicit high-risk opt-in and display the destination before sending credentials.
  4. Normalize and parse URLs with urllib.parse.urlparse; reject embedded credentials, unexpected ports, fragments, and malformed hostnames.
  5. Do not attach the bearer token until the destination origin has passed validation.
  6. Prevent credential forwarding when redirects change the origin.
  7. Validate persistent configuration ownership and permissions before trusting its base_url.
  8. Apply the same hardened shared client implementation to both imagegen.py and videogen.py.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:267
Finding

Server-Controlled Upload URL Can Redirect User Media to an Untrusted Destination

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:267-290; equivalent implementation in scripts/videogen.py:267-290
Vulnerability Type: Unvalidated file-upload destination
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,
            )

Technical Analysis

The upload-token response controls all of the following request properties:

  • Destination URL
  • HTTP method
  • Request headers

The script does not verify that the upload URL uses HTTPS, belongs to an approved object-storage domain, resolves to a public address, or uses an expected upload method. It immediately opens the user-selected local file and transmits its contents to the returned destination.

Although obtaining a presigned object-storage URL from an API is a legitimate workflow, the response crosses a trust boundary and must be constrained before a local file is released. This issue becomes directly exploitable if the ...[truncated 1371 chars]

Remediation
View remediation

Remediation Suggestions

  1. Parse and validate the upload URL before opening the local file.
  2. Require HTTPS and reject URLs containing user information or unusual ports.
  3. Allowlist documented AI-HIVE object-storage hostnames or securely validate a signed destination policy.
  4. Resolve the hostname and reject loopback, link-local, multicast, and private network destinations unless explicitly required.
  5. Restrict upload methods to documented values such as PUT or POST.
  6. Allowlist permitted response-provided headers instead of forwarding an arbitrary header mapping.
  7. Revalidate the destination after redirects, or disable redirects for upload requests.
  8. Display the validated hostname and require confirmation before uploading sensitive media when operating interactively.
  9. Share the corrected upload implementation between the image and video scripts to avoid duplicated vulnerable code.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:365
Finding

Remote Task Metadata Is Used in Download Paths Without Sanitization

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:365-388; equivalent implementation in scripts/videogen.py:365-388
Vulnerability Type: Path traversal and arbitrary file overwrite
Risk Level: Medium

Vulnerable Code

python
# Download results
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 ultimately opened 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 remote task response supplies taskType, and the task identifier may originate from a generation response. These values are directly embedded into a local filename.

No normalization, character allowlist, basename conversion, or resolved-path containment check is performed. If either value contains path separators or traversal sequences, joining it with out_dir can produce a path outside the intended download directory.

The download function opens the resulting path with wb, which truncates an existing writable file. Exploitation requires the traversed parent directories to exist because the script only creates the configured output directory, not arbitrary intermediate directories.

Attack Path

  1. An attacker controls or compromises the API response used during task ...[truncated 1066 chars]
Remediation
View remediation

Remediation Suggestions

  1. Never use a remote taskType as a filesystem path component.
  2. Map known task types to locally defined filename prefixes such as image and video.
  3. Sanitize task identifiers with a strict character allowlist, for example letters, digits, underscore, and hyphen.
  4. Remove path separators and reject . or .. components.
  5. Resolve both paths and enforce containment before writing:
python
base = Path(output_dir).expanduser().resolve()
destination = (base / safe_filename).resolve()
if not destination.is_relative_to(base):
    raise SystemExit("Unsafe output path")
  1. Use exclusive file creation or an explicit overwrite option to prevent silent truncation.
  2. Store files under locally generated random names and record remote metadata separately.
  3. Apply the correction to both imagegen.py and videogen.py.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (17)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill is described as an evaluation and migration advisor, but its practical behavior appears to be a general AI-HIVE API client with chat, image/video generation, media upload, task querying, file download, and local API key configuration. Such divergence undermines informed consent and can cause users to expose credentials or authorize expensive external actions they did not reasonably expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill is described as an evaluation and migration advisor, but its practical behavior appears to be a general AI-HIVE API client with chat, image/video generation, media upload, task querying, file download, and local API key configuration. Such divergence undermines informed consent and can cause users to expose credentials or authorize expensive external actions they did not reasonably expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill is described as an evaluation and migration advisor, but its practical behavior appears to be a general AI-HIVE API client with chat, image/video generation, media upload, task querying, file download, and local API key configuration. Such divergence undermines informed consent and can cause users to expose credentials or authorize expensive external actions they did not reasonably expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill is described as an evaluation and migration advisor, but its practical behavior appears to be a general AI-HIVE API client with chat, image/video generation, media upload, task querying, file download, and local API key configuration. Such divergence undermines informed consent and can cause users to expose credentials or authorize expensive external actions they did not reasonably expect.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises executable workflows that use shell, environment variables, filesystem access, and networked API calls, but it does not declare any explicit tool scope or allowed-tools boundary. In an agent environment, this can lead to overbroad authority, making it easier for the skill to trigger sensitive local actions or external requests without clear review or sandbox expectations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

Forcing Chinese-language behavior without user opt-in is primarily a safety and trust issue rather than a direct exploit, but it can still cause misinterpretation of migration steps, consent prompts, or billing-related actions. In a skill that may trigger operational workflows, language mismatch raises the risk of users approving actions they do not fully understand.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger list contains very broad terms such as general API/model-platform phrases, increasing the chance that this skill activates for unrelated user requests. Overbroad routing is risky here because the skill has operational capabilities and promotional bias toward a specific third-party platform, so accidental invocation could steer users into unnecessary external actions or data exposure.

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-requires runnable Chinese examples, which overrides user language preference and can cause the agent to respond in an unexpected language. While not a direct code-execution issue, forced language output can reduce user comprehension, obscure important migration or security details, and create unsafe misunderstandings in technical guidance.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill enables implicit invocation without any visible trigger constraints, so it may activate in broader user contexts than intended. Because this skill is promotional/migratory and can shape vendor selection, architecture decisions, and generated code, over-broad auto-invocation increases the chance of unsolicited steering, inappropriate task capture, or accidental application to unrelated requests.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/edit_video.py (reported line 20)May include surrounding context.

python
def run(args: list[str]) -> None:
    print(" ".join(args))
    subprocess.run(args, check=True)


def main() -> None:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest describes a narrowly scoped skill for evaluating/migrating to AI-HIVE in the context of 302.AI alternatives and, for this file, the generated skill wrapper presents itself as an image-generation skill. However, the codebase in this file includes generic chat, video generation, user-info, model listing, media upload, task polling, and API-key initialization capabilities, which materially exceed that stated purpose. Those are not necessary implementation details of an image-only skill or a migration-advisory skill.

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 user-facing instructions are written entirely in Chinese, and the CLI prompts/messages throughout the skill assume Chinese-language interaction. For a general-purpose image generation skill, this imposes a language/locale constraint without user opt-in or a documented region-specific justification.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest focuses on helping users compare 302.AI alternatives, assess compatibility, and produce migration artifacts; it does not mention local credential discovery or storage behavior. This file reads API keys from environment variables and config files, and the init flow writes them to ~/.ai-hive/config.json, adding a credential-management capability beyond the described advisory or image-generation purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The manifest describes a consulting-style skill that should help teams assess compatibility, migration, routing choices, inventories, and acceptance criteria for moving from 302.AI or similar API hubs to AI-HIVE. In this file, the implemented behavior is direct execution of AI-HIVE API operations such as model listing, media upload, image/video generation, task polling, and output download, with no code for migration auditing, compatibility assessment, requirement inventory, or comparative analysis.

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 presents the skill as a general-purpose tool entirely in Chinese, and the CLI help and interactive prompts throughout the file are also Chinese-only. For a general-purpose skill, this is a locale/language constraint without opt-in or documented regional justification, which matches the language-policy violation category.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The generated SKILL_CONFIG and skill-specific parser rebrand this file as a dedicated 'Token Hub 成本路由中心' video skill, with fixed model mappings and a generate/task/upload CLI focused on producing commercial videos. That is materially narrower and different from the manifest's declared purpose of helping users judge AI-HIVE as an alternative and deliver migration/compliance artifacts, so the shipped skill behavior does not match the stated intent.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The init command opens a browser to an AI-Hive chat URL and appends query parameters such as from=cli-skill and skill= for backend attribution. That telemetry-style attribution behavior is not part of the manifest's stated purpose of advising on alternatives/migration or generating images, and is not required for core functionality.

Content

No source excerpt is available for this finding.