T09 · Insecure Skill Coding Practices
- Location
scripts/ai_hive_mcp.py:19- Finding
API Credential Exfiltration Through an Unvalidated MCP Endpoint Override
- Content
View full analysis
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 reads an API key or OAuth access token from the process environment and attaches it to every MCP request. The destination of that request is independently configurable through `AI_HIVE_MCP_URL`. No validation ensures that the configured URL: - Uses HTTPS. - Belongs to `ai-hive.iclip.cn`. - Uses the expected MCP path. - Resolves to an approved service. - Does not redirect requests to another origin. Consequently, anyone ab ...[truncated 1796 chars]- Remediation
View remediation
