T09 · Insecure Skill Coding Practices
- Location
scripts/call_api.py:45- Finding
Environment-Controlled API Endpoint Can Exfiltrate Credentials and User Data
- Content
View full analysis
HttpResult: """Call a XiaoBenYang MCP tool.""" url = f"{settings.base_url}/api" mcp_id = mcp_id or settings.mcp_id api_key = get_api_key() if not api_key: raise UpstreamError("API key is not configured; call set_api_key() first") headers = { "XBY-APIKEY": api_key, "func": tool_name, "mcpid": mcp_id, "Content-Type": "application/json", } t0 = time.time() try: resp = self._session.post( url=url, headers=headers, data=json.dumps(params), timeout=settings.timeout_seconds, ) ``` ### Technical Analysis The Pydantic settings model uses the `XBY_GAOKAO_` environment-variable prefix. Consequently, `XBY_GAOKAO_BASE_URL` can override the intended `https://mcp.xiaobenyang.com` endpoint. The request code constructs a URL directly from this configurable value and sends the `XBY-APIKEY` header without validating the URL scheme, hostname, port, or origin. An attacker who can influence the process environment or `.env` configuration can therefore redirect requests to an attacker-controlled endpoint. The same request body includes tool parameters. Depending on the invoked operation, those parameters may contain mathematical expressions, natural-language queries, session identifiers, session variables, or other user-provided data. Redirect beh ...[truncated 1177 chars]- Remediation
View remediation
