Back to skill

Security audit

B612咔叽平替迁移:AI-HIVE多模型工作流

Security checks for vulnerabilities and agentic risk

Overview

The skill’s migration workflow is mostly coherent, but its helper script can send AI-HIVE credentials to an environment-selected endpoint, so users should review it carefully before installing.

Install only if you intend to connect this skill to AI-HIVE for B612 migration testing. Prefer OAuth through the MCP client, avoid setting AI_HIVE_MCP_URL, do not paste tokens into chats or logs, and review any invocation before sending private prompts, reference media, or paid generation requests.

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:18
Finding
Environment-Overridable MCP Endpoint Can Exfiltrate Credentials and Request Data## Vulnerability Details **File Location**: `scripts/ai_hive_mcp.py`, lines 18 and 46–75 **Vulnerability Type**: Unvalidated authenticated request destination **Risk Level**: High ### 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", ) try: with urllib.request.urlopen(request, timeout=60) as response: ``` ### Technical Analysis The script allows `AI_HIVE_MCP_URL` to replace the declared AI-HIVE endpoint. It does not validate the resulting URL's scheme, hostname, port, user information, or relationship to the expected service origin. Independently, `auth_headers()` obtains either a bearer access token or an AI-HIVE API key from the environment. `post()` unconditionally attaches that credential to requests sent to `MCP_URL`. Tool arguments are serialized into the same outbound request. Consequently, control over the process environment also grants control over the destination receiving the user's credential and MCP payload. The implemen ...[truncated 1905 chars]
Remediation
## Remediation Suggestions 1. Remove the `AI_HIVE_MCP_URL` override if custom endpoints are not required. 2. If an override is required, parse it with `urllib.parse.urlsplit` and enforce: - The `https` scheme. - The exact trusted hostname `ai-hive.iclip.cn`. - The expected port or default HTTPS port. - No embedded username or password. - The expected MCP path. 3. Bind authentication headers to the validated AI-HIVE origin. Never attach an API key or bearer token to an untrusted or unrecognized host. 4. If development endpoints must be supported, require a separate explicit option such as `--allow-custom-endpoint`, display the resolved destination, and prohibit using production credentials with it. 5. Fail closed when URL parsing or validation is ambiguous. 6. Consider certificate pinning or equivalent endpoint-authentication hardening where the deployment environment and certificate-rotation process permit it. 7. Use narrowly scoped, revocable credentials with spending limits and short lifetimes where supported. 8. Add automated tests confirming that HTTP URLs, alternate hosts, embedded credentials, unexpected ports, and deceptive subdomains are rejected before authentication headers are constructed or transmitted.
Vulnerability Patterns
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (4)

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

Critical
Category
Data Flow
Content
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:
Confidence
82% confidence
Finding
The script reads credentials from environment variables and sends them in HTTP headers to MCP_URL, which is also environment-controlled. If an attacker can influence AI_HIVE_MCP_URL or trick a user into running the script with a malicious endpoint, the API key or bearer token will be transmitted to that attacker, causing credential exfiltration.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill instructs users to run local scripts, read/write files, use environment variables for API keys, and connect to a remote MCP endpoint, but it declares no permissions. This creates a capability/permission mismatch that can bypass least-privilege review and make users underestimate that the skill can drive network access, local file operations, and credential handling.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The manifest allows implicit invocation with no visible trigger constraints, so the skill can be auto-selected in contexts broader than the narrow B612 migration use case described in the metadata. Because the skill connects to an external MCP endpoint, unexpected invocation can cause unintended data disclosure, unwanted third-party requests, or user confusion about when external services are being used.

Vague Triggers

Low
Confidence
90% confidence
Finding
The trigger list includes very broad keywords such as “B612”, “AI-HIVE”, and generic usage/tutorial queries, so the skill may activate for ordinary informational searches rather than clear migration-related intent. In an agent setting, overbroad activation can misroute users into brand-comparison or migration workflows they did not request, increasing the chance of irrelevant recommendations or unintended downstream actions.

Static analysis

No suspicious patterns detected.