Back to skill

Security audit

AI大模型专家|电商主图

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real AI-HIVE image workflow, but it needs review because it can use stored API keys, upload and download files, auto-invoke broadly, and accepts unsafe endpoint and download data.

Install only if you intend to use AI-HIVE for this workflow and are comfortable sending prompts and selected media to that service. Keep the API key private, avoid custom base URLs unless you fully trust the endpoint, disable or constrain implicit invocation if possible, and use a dedicated output directory while treating downloaded files as untrusted.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:91
Finding

API Credential Disclosure Through an Unrestricted Custom Base URL

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:91-99, 130-133, 587
Vulnerability Type: Bearer-token disclosure through an attacker-controlled API origin
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 __init__(self, config):
    self.config = config
    self.base = config.base_url
    self.headers = {
        "Authorization": f"Bearer {config.api_key}",
        "Content-Type": "application/json",
    }
python
parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")

Technical Analysis

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

The HTTP client independently constructs an Authorization: Bearer header containing the user's AI-HIVE API key and attaches that header to every API request. Consequently, changing the base URL also changes the recipient of the credential.

This violates the expected trust boundary for an API credential: a token intended for ai-hive.iclip.cn can be transmitted to any HTTP or HTTPS server. Plain HTTP endpoints are also accepted, allowing interception by a network attacker.

Attack Path

  1. The victim has a valid AI-HIVE key in AI_HIVE_API_KEY, a CLI argument, or ~/.ai-hive/config.json.
  2. An attacker causes the victim to use a malicious endpoint through one of the supported configuration mechanisms, for example:
    bash
    python3 scripts/imagegen.py generate
    

...[truncated 1124 chars]

Remediation
View remediation

Remediation Suggestions

  1. Restrict the normal client to the expected origin:
    python
    from urllib.parse import urlparse
    
    ALLOWED_API_HOSTS = {"ai-hive.iclip.cn"}
    
    def validate_base_url(value):
        parsed = urlparse(value)
        if parsed.scheme != "https":
            raise SystemExit("The API base URL must use HTTPS")
        if parsed.hostname not in ALLOWED_API_HOSTS:
            raise SystemExit("The API hostname is not trusted")
        if parsed.username or parsed.password:
            raise SystemExit("Credentials in the API URL are not allowed")
        return value.rstrip("/")
    
  2. Do not send an AI-HIVE credential to a custom origin automatically.
  3. If self-hosted or development endpoints are genuinely required, require an explicit unsafe-development option and a separate credential.
  4. Reject plaintext HTTP and URLs containing embedded user information.
  5. Display the normalized credential destination and require confirmation before first use of any non-default endpoint.
  6. Document that environment and configuration-file changes can alter the credential destination.
  7. Rotate any API key that may already have been transmitted to an untrusted endpoint.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:312
Finding

Unvalidated Server-Controlled Download URLs and Output Paths

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:312-316, 399-414
Vulnerability Type: Server-side request forgery from the client environment and path traversal during result download
Risk Level: Medium

Vulnerable Code

python
def download_file(url, out_path, timeout=300):
    """Stream a file download and display progress."""
    print(f"[download] {out_path.name}")
    try:
        resp = requests.get(url, stream=True, timeout=timeout)
        resp.raise_for_status()
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)

Technical Analysis

The task response controls resultUrl, lastFrameUrl, and taskType. The task identifier used in the output filename can also originate from an API response when a generation task is created.

The downloader passes response-provided URLs directly to requests.get(). It does not enforce HTTPS, restrict destination hosts, reject loopback or private-network addresses, or validate redirect destinations. A malicious or compromised API endpoint can therefore cause the machine running the Skill to make HTTP requests to network resources available from that machine.

The output filename is assembled from taskType and task_id without sanitizing path separators or traversal components. Joining this value to out_dir does not guarantee containm ...[truncated 1919 chars]

Remediation
View remediation

Remediation Suggestions

  1. Allow downloads only from HTTPS hosts explicitly authorized by AI-HIVE.
  2. Validate every redirect target rather than relying on the initial URL check. One option is to disable automatic redirects and inspect each Location header.
  3. Resolve download hostnames and reject loopback, link-local, multicast, private, reserved, and unspecified IP addresses unless a narrowly defined deployment requirement permits them.
  4. Apply response-size limits before and during streaming to prevent disk exhaustion.
  5. Generate filenames locally instead of incorporating server-provided metadata:
    python
    filename = f"generation_{i + 1}{ext}"
    
  6. If metadata must appear in filenames, restrict it to a small safe character set:
    python
    import re
    safe_task_type = re.sub(r"[^A-Za-z0-9_-]", "_", task_type)
    safe_task_id = re.sub(r"[^A-Za-z0-9_-]", "_", str(task_id))
    
  7. Enforce output-directory containment before opening the file:
    python
    root = out_dir.resolve()
    target = (root / filename).resolve()
    if root not in target.parents:
        raise SystemExit("Unsafe output path")
    
  8. Open new files with exclusive creation where overwriting is unnecessary, and define an explicit overwrite policy.
  9. Treat all task response fields as untrusted, even when they normally come from the official API.
Vulnerability Patterns
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill describes capabilities that imply access to environment data, local files, networking, shell execution, and file writes, but it does not declare any explicit tool scope or permission boundaries. In a skill that handles API keys, opens web pages, writes config files, uploads media, and downloads results, missing scope declarations can let an invoking agent grant overly broad powers by default and make privilege review difficult.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The invocation description is so broad that it overlaps with many ordinary image-generation, marketing, and ecommerce requests, increasing the chance the skill is auto-selected in contexts where the user did not intend to invoke a networked, file-writing workflow. Because this skill can upload local images, persist task data, and download outputs, overbroad triggering expands the attack surface for unintended data exfiltration or unreviewed external API use.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The metadata sets language: zh-CN, which indicates a fixed locale preference. Under the policy, forcing a specific language or locale without user opt-in is a natural-language policy concern unless the constraint is clearly justified or the user is offered a choice.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The search coverage block contains very broad trigger terms spanning general AI, ecommerce platforms, social media, model brands, and content workflows, with few constraints. This can cause the skill to match a large number of unrelated requests and unexpectedly activate a workflow that uploads assets and interacts with external services, which is risky when user data or proprietary media may be involved.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill enables implicit invocation without any trigger constraints, so the agent may call this skill automatically in contexts the user did not clearly intend. Because this skill can submit jobs, upload reference images, poll task status, and download generated outputs through an external service, unintended invocation could cause data disclosure, unwanted external requests, and unexpected cost-incurring actions.

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 specialized e-commerce main-image skill, but its implementation is a generic AI Hive client supporting chat, image, video, model discovery, uploads, and task polling. This capability mismatch violates least privilege and increases the attack surface, because a caller expecting a narrowly scoped image tool can instead access broader API functions and potentially use the skill as a general-purpose gateway.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring and CLI descriptions explicitly market the script as a generic AI capability tool, contradicting the skill's claimed identity as an e-commerce main-image skill. This is dangerous because it can mislead reviewers, policy engines, or orchestrators into granting trust or permissions under a narrow label while the code retains broad operational capability.

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 later prompts/messages throughout the script also assume Chinese-language interaction. There is no indication that the skill is region-specific or that users may opt into another language, which creates a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The generic text-chat capability is outside the declared purpose and can be repurposed as an unrestricted LLM access path under the guise of an image tool. In a skill ecosystem, this matters because policy, billing, prompt controls, and trust assumptions for an image-generation skill may be weaker or different than for arbitrary chat/model interaction.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The video-generation path substantially exceeds the advertised image-only scope and introduces additional upload, processing, and output capabilities. This increases abuse potential, cost exposure, and policy bypass risk because users or agents can access richer media-generation functionality than the skill contract suggests.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The example API key placeholder uses Chinese text ('请替换为你的APIKey'), which imposes a specific language in user-facing configuration content. There is no indication that the skill is region-specific or that alternative locales are supported.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

Exposing user/account information retrieval is unrelated to image generation and unnecessarily broadens data access. Even if the endpoint is legitimate, it may disclose account metadata or balances to workflows that only require image creation, creating avoidable privacy and reconnaissance risk.

Content

No source excerpt is available for this finding.