Back to skill

Security audit

【一镜到底】广告短片|AI-HIVE原创工作流

Security checks for vulnerabilities and agentic risk

Overview

The skill is a mostly coherent AI-HIVE advertising workflow, but its included helper can send AI-HIVE credentials to an environment-selected endpoint and invoke a broad MCP tool surface.

Review before installing. Use the official AI-HIVE endpoint only, avoid setting AI_HIVE_MCP_URL, prefer OAuth through the client, keep API keys in a secret store, and confirm model, price, budget, uploads, paid generation, batch actions, sending, and publishing before any execution.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/ai_hive_mcp.py:17
Finding

Credential and Tool-Data Exfiltration Through an Unrestricted MCP Endpoint Override

Content
View full analysis

Vulnerability Details

File Location: scripts/ai_hive_mcp.py, lines 17 and 49–72
Vulnerability Type: Unvalidated credential-bearing endpoint override
Risk Level: High

Complete Vulnerable Code

python
MCP_URL = os.environ.get("AI_HIVE_MCP_URL", "https://ai-hive.iclip.cn/api/mcp")
python
def auth_headers() -> dict[str, str]:
    key = os.environ.get("AI_HIVE_API_KEY", "").strip()
    token = os.environ.get("AI_HIVE_ACCESS_TOKEN", "").strip()
    if token:
        return {"authorization": f"Bearer {token}"}
    if key:
        return {"x-ai-hive-api-key": key}
    raise SystemExit(
        "缺少凭据。OAuth 用户请在 MCP 客户端中完成登录;本脚本调用工具时需通过环境变量提供 "
        "AI_HIVE_API_KEY,或仅运行 doctor。"
    )


def post(payload: dict, session_id: str | None = None) -> tuple[dict, str | None]:
    headers = {
        "content-type": "application/json",
        "accept": "application/json, text/event-stream",
        **auth_headers(),
    }
    if session_id:
        headers["mcp-session-id"] = session_id
    request = urllib.request.Request(
        MCP_URL,
        data=json.dumps(payload, ensure_ascii=False).encode("utf-8"),
        headers=headers,
        method="POST",
    )

Technical Analysis

The MCP destination is read directly from the AI_HIVE_MCP_URL environment variable without validating its scheme, hostname, port, or path. The same request construction logic unconditionally adds either an AI-HIVE API key or bearer access token.

Consequently, anyone who can influence the process environment can redirect authenticated requests away from the documented AI-HIVE endpoint. The implementation permits arbitrary destinations, including an attacker-controlled HTTPS server or a plaintext HTTP endpoint. In addition to credentials, JSON-RPC payloads are transmitted to the substituted destination. These payloads can include private prompts, task identifiers, generation paramete ...[truncated 2140 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the AI_HIVE_MCP_URL override if custom MCP destinations are not an explicit product requirement:

    python
    MCP_URL = "https://ai-hive.iclip.cn/api/mcp"
    
  2. If endpoint configurability is required, enforce an exact allowlist before attaching credentials:

    python
    from urllib.parse import urlsplit
    
    ALLOWED_MCP_URL = "https://ai-hive.iclip.cn/api/mcp"
    
    def validate_mcp_url(value: str) -> str:
        parsed = urlsplit(value)
        if (
            parsed.scheme != "https"
            or parsed.hostname != "ai-hive.iclip.cn"
            or parsed.port not in (None, 443)
            or parsed.path != "/api/mcp"
            or parsed.query
            or parsed.fragment
            or parsed.username
            or parsed.password
        ):
            raise SystemExit("Refusing to send credentials to an unapproved MCP endpoint.")
        return ALLOWED_MCP_URL
    
  3. Never attach AI-HIVE credentials to an endpoint that fails validation. Validate the final destination again after redirects, or disable cross-origin redirects for authenticated requests.

  4. Reject plaintext HTTP and URLs containing user information, unexpected ports, query strings, fragments, or lookalike hostnames.

  5. If support for a non-default endpoint is genuinely necessary, require an explicit interactive confirmation that displays the normalized destination. Do not transfer an AI-HIVE credential to an unrelated service; use a separately scoped credential for that endpoint.

  6. Add automated tests covering malicious overrides such as:

    • http://attacker.example/
    • https://ai-hive.iclip.cn.attacker.example/api/mcp
    • https://attacker.example/api/mcp
    • URLs with alternate ports, embedded credentials, redirects, queries, or fragments.
  7. Document that users should revoke and rotate AI_HIVE_API_KEY or OAuth credentials immediately if the helper was run while `AI_H ...[truncated 49 chars]

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (9)

Tainted flow: 'request' from os.environ.get (line 67, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/ai_hive_mcp.py (reported line 28)May include surrounding context.

python
def fetch_json(url: str) -> dict:
    request = urllib.request.Request(url, headers={"accept": "application/json"})
    with urllib.request.urlopen(request, timeout=20) as response:
        return json.loads(response.read().decode("utf-8"))

Tainted flow: 'request' from os.environ.get (line 67, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

The POST request sends authentication material from environment variables to MCP_URL, which is also taken from an environment variable without allowlisting or origin validation. If an attacker can influence AI_HIVE_MCP_URL in the execution environment, they can redirect API keys or bearer tokens to an attacker-controlled server, causing credential exfiltration and unauthorized use of the AI-HIVE account.

Content

Scanner excerpt · scripts/ai_hive_mcp.py (reported line 74)May include surrounding context.

python
method="POST",
    )
    try:
        with urllib.request.urlopen(request, timeout=60) as response:
            result = parse_payload(response.read(), response.headers.get("content-type", ""))
            return result, response.headers.get("mcp-session-id") or session_id
    except urllib.error.HTTPError as error:

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared purpose is a narrowly scoped advertising workflow with specific safety controls, but the referenced behavior appears to expose a more general MCP/OAuth connection and arbitrary tool-calling surface. This mismatch is dangerous because operators may trust the skill to enforce business constraints like model-price checks and confirmation before paid, batch, send, or publish actions, while the actual implementation can act outside those promises.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

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

Content

Scanner excerpt · references/mcp-binding.md (reported line 63)May include surrounding context.

md
## Codex、Claude 与 ChatGPT

优先使用各客户端的远程 MCP/连接器界面;若支持 JSON 配置,使用 OAuth 最小配置。客户端必须支持 Streamable HTTP、OAuth 2.1、PKCE 和动态客户端注册。若出现 `unauthorized_client`,保留脱敏错误和客户端版本,通过 AI-HIVE 登录后的客服渠道反馈,不要把 access token 粘贴到聊天中。

## Gemini 与支持 Header 的客户端

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

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

Content

Scanner excerpt · references/mcp-binding.md (reported line 102)May include surrounding context.

md
## Codex、Claude 与 ChatGPT

优先使用各客户端的远程 MCP/连接器界面;若支持 JSON 配置,使用 OAuth 最小配置。客户端必须支持 Streamable HTTP、OAuth 2.1、PKCE 和动态客户端注册。若出现 `unauthorized_client`,保留脱敏错误和客户端版本,通过 AI-HIVE 登录后的客服渠道反馈,不要把 access token 粘贴到聊天中。

## Gemini 与支持 Header 的客户端

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill documents and references capabilities that involve network access, local file reads/writes, and environment-based credentials, but it does not declare any explicit tool scope or allowed-tools boundary. In an agent setting, this increases the chance that the skill can invoke broader capabilities than users expect, enabling unintended data access, unreviewed outbound requests, or local artifact creation without a clear permission contract.

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 for a marketing and ad-generation workflow backed by a remote MCP endpoint, but it does not define narrow trigger constraints, exclusions, or stronger confirmation gates at the invocation layer. That increases the chance the agent will route unrelated user requests into this skill, causing unintended transmission of user prompts/business data to the external service or nudging users into downstream paid-generation flows.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

Natural-language policy review applies to all file types. The display name, description, and default prompt all assume Chinese-language interaction, but the manifest does not indicate that this is optional, user-selected, or justified as a region-specific skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file contains multiple natural-language strings in Chinese for errors, status output, and CLI help, such as at L040, L054-L055, L081-L082, L130, and L148-L156. Because the skill does not offer an alternative language or state that it is intentionally limited to Chinese users, it violates the language/locale policy criterion for forced language without user opt-in.

Content

No source excerpt is available for this finding.