T09 · Insecure Skill Coding Practices
- Location
tools/src/config.py:54- Finding
API Key Persisted in Plaintext Within an MCP URL
- Content
View full analysis
Dict[str, str]: api_key = get_api_key() if not api_key: api_key = "YOUR_API_KEY_HERE" return { "baseUrl": f"https://stargate.yingmi.com/mcp/sse?apiKey={api_key}", "description": "Fund investment toolkit" } ``` ```python config["mcpServers"][self.REQUIRED_MCP_SERVER] = get_qieman_mcp_config() try: with open(self.MCPORTER_CONFIG_PATH, "w", encoding="utf-8") as f: json.dump(config, f, indent=2, ensure_ascii=False) self.results["setup_success"] = True return True except Exception as e: self.results["setup_error"] = str(e) return False ``` ### Technical Analysis The application reads `QIEMAN_API_KEY` from the process environment, interpolates it into the query component of an MCP endpoint URL, and writes the resulting URL to `~/.mcporter/mcporter.json`. The configuration file is created with the default permissions derived from the process umask. The application does not explicitly require owner-only permissions. On systems with a permissive umask or shared home-directory access, other local users or processes may be able to retrieve the credential. Placing credentials in query strings is also unsafe because URLs are commonly included in diagnostic output, proxy logs, exception messages, telemetry, and connection histories. The key may consequently be exposed beyond the configuration file itself. ### Attack Path 1. A user exports a valid `QIEMAN_API_KEY`. 2. The user runs the documented initialization command. 3. `get_qieman_mcp_config()` embeds the key in the `baseUrl` query string. 4. `setup_qieman_mcp_config()` writes that URL to `~/.mcporter/mcporter.json` without enforcing owner-only per ...[truncated 686 chars]- Remediation
View remediation
