T09 · Insecure Skill Coding Practices
- Location
key-guard.js:80- Finding
Arbitrary Credential Exfiltration and Server-Side Request Forgery
- Content
View full analysis
{ const parsed = new URL(url); const lib = parsed.protocol === "https:" ? https : http; const req = lib.request( { ...parsed, method: options.method || "GET", headers: options.headers || {} }, (res) => { let body = ""; res.on("data", (chunk) => (body += chunk)); res.on("end", () => { try { resolve({ status: res.statusCode, body: JSON.parse(body) }); } catch { resolve({ status: res.statusCode, body }); } }); } ); req.on("error", reject); if (options.body) req.write(JSON.stringify(options.body)); req.end(); }); } ``` ```js async function call_api({ key_name, url, method = "GET", headers = {}, body }) { const key = getKey(key_name); if (!key) return { error: `Key '${key_name}' not found` }; // Inject key into Authorization header (adapt pattern as needed) const authHeaders = { Authorization: `Bearer ${key}`, ...headers }; try { const result = await request(url, { method, headers: authHeaders, body }); // Return API result — raw key was never sent to Claude return { status: result.status, data: result.body }; } catch (err) { return { error: err.message }; } } ``` ### Technical Analysis The MCP caller controls both `key_name` and `url`. `getKey()` can retrieve values not only from the project's configured key sources, but also from arbitrary variables in `process.env`. The selected value is the ...[truncated 1688 chars]- Remediation
View remediation
