T09 · Insecure Skill Coding Practices
Error
- Location
- index.js:34
- Finding
- Configurable API Endpoint Can Expose Bearer Credentials and Monitoring Data<![CDATA[ ## Vulnerability Details **File Location**: `index.js:34-39, 143-166` **Vulnerability Type**: Unrestricted credential-bearing outbound requests **Risk Level**: High ### Vulnerable Code ```js const CONFIG = { apiUrl: process.env.WATCHDOG_API_URL || "https://api.watch.dog/api/mcp_server.php", apiKey: process.env.WATCHDOG_API_KEY || "", }; ``` ```js async function callRemoteTool(toolName, args = {}) { // Remove undefined args Object.keys(args).forEach((k) => args[k] === undefined && delete args[k]); if (!CONFIG.apiKey) { throw new Error( "WATCHDOG_API_KEY is not configured. " + "Please configure it in the .env file of the skill or as an environment variable.", ); } const response = await fetch(CONFIG.apiUrl, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json", Authorization: `Bearer ${CONFIG.apiKey}`, }, body: JSON.stringify({ jsonrpc: "2.0", id: `req_${Date.now()}`, method: "tools/call", params: { name: toolName, arguments: args }, }), }); ``` ### Technical Analysis `WATCHDOG_API_URL` controls the destination of every remote tool request. The value is accepted without HTTPS enforcement, hostname allowlisting, private-network address rejection, or explicit confirmation before credentials are transmitted. Each request sends `WATCHDOG_API_KEY` as a bearer token. Tool arguments can also contain sensitive infrastructure information, including monitored URLs, hostnames, monitor names, identifiers, and tracker-page configuration. Because the Skill documentation and embedded prompt allow the user-supplied API URL to be persisted and immediately tested with `list_monitors`, a malicious, compromised, or mistyped endpoint can receive the credential as soon as configuration is completed. An HTTP endpoint could additionally expose the credential to network interception. A local or private-network endpoint could cause ...[truncated 1258 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin production requests to the official `https://api.watch.dog` origin wherever possible. 2. If custom endpoints are a required feature: - Enforce HTTPS. - Parse the URL with the standard `URL` class. - Allow only explicitly approved hostnames and ports. - Reject embedded credentials, redirects to unapproved hosts, and non-HTTP protocols. - Resolve and reject loopback, private, link-local, multicast, and cloud metadata addresses. 3. Require explicit informed confirmation before sending an API key to a newly configured origin. 4. Do not automatically test credentials against an unverified custom URL. 5. Disable automatic redirect following or revalidate every redirect destination. 6. Use separate, narrowly scoped API keys where the remote platform supports them. 7. Avoid including unnecessary infrastructure details in requests and document exactly what data leaves the host. ]]>
