T09 · Insecure Skill Coding Practices
- Location
index.js:123- Finding
Bearer API Key Can Be Transmitted to an Arbitrary Configured Endpoint
- Content
View full analysis
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 }, }), }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (data.error) { throw new Error(`[${data.error.code}] ${data.error.message}`); } return data?.result?.content?.[0]?.text ?? "{}"; } ``` The documentation explicitly permits a configurable endpoint: ```env WATCHDOG_API_KEY="sk_live_your_key_here" WATCHDOG_API_URL="api_url_here" | "https://api.watch.dog/api/mcp_server.php" ``` ### Technical Analysis `WATCHDOG_API_URL` is accepted without validating its scheme, hostname, port, or network destination. Every tool request then transmits `WATCHDOG_API_KEY` in an `Authorization: Bearer` header to that endpoint. Consequently, a configuration mistake or attacker-influenced onboarding interacti ...[truncated 1809 chars]- Remediation
View remediation
