T09 · Insecure Skill Coding Practices
Error
- Location
- mcp/main.go:12
- Finding
- API Key Can Be Transmitted to an Arbitrary Configured Server<![CDATA[ ## Vulnerability Details **File Location**: `mcp/main.go:12-17` and `mcp/client.go:30-45` **Vulnerability Type**: Unrestricted destination configuration and credential disclosure **Risk Level**: High ### Vulnerable Code ```go // mcp/main.go:12-17 apiKey := os.Getenv("TRANSITION_API_KEY") baseURL := os.Getenv("TRANSITION_API_URL") if baseURL == "" { baseURL = "https://api.transition.fun" } client := NewTransitionClient(baseURL, apiKey) ``` ```go // mcp/client.go:30-45 func (tc *TransitionClient) doRequest(method, path string, body io.Reader) (*http.Response, error) { url := tc.baseURL + path req, err := http.NewRequest(method, url, body) if err != nil { return nil, err } if tc.apiKey != "" { req.Header.Set("X-API-Key", tc.apiKey) } req.Header.Set("Content-Type", "application/json") req.Header.Set("Accept", "application/json") return tc.httpClient.Do(req) } ``` ### Technical Analysis The server obtains its destination from `TRANSITION_API_URL` without validating the URL scheme or hostname. The HTTP client then attaches `TRANSITION_API_KEY` as an `X-API-Key` header to every request, regardless of the configured destination. Consequently, setting `TRANSITION_API_URL` to an untrusted origin causes the application to disclose the Transition API key to that origin. A plain HTTP destination would additionally expose the credential and request contents to network interception. This destination override is not described in the reviewed README or skill documentation. The same requests may contain sensitive athlete information, including coaching questions, injury descriptions, training schedules, adaptation reasons, profile information, and performance metrics. ### Attack Path 1. An attacker, malicious launcher, or unsafe MCP configuration sets `TRANSITION_API_URL` to an attacker-controlled HTTP or HTTPS server. 2. The user starts the MCP server with a valid `TRANSITION_API_KEY`. 3. The user or ...[truncated 1070 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `TRANSITION_API_URL` if custom API origins are not an explicit requirement. 2. If custom endpoints are required, parse the value with `net/url` and require: - An `https` scheme. - No embedded user information. - No unexpected port. - A hostname from an explicit allowlist. 3. Attach `X-API-Key` only after verifying that the final request destination exactly matches the trusted Transition API origin. 4. Use separate constructors for production and development clients so development endpoints cannot accidentally receive production credentials. 5. Reject plain HTTP destinations whenever an API key is present. 6. Document all supported configuration variables and their security implications. 7. Consider scoping and rotating API keys, and advise users to revoke keys that may have been exposed. ]]>
