T05 · Unauthorized Access and Privilege Escalation
- Location
index.ts:397- Finding
Agent-Callable Server-Side Request Forgery Through Arbitrary MCP URLs
- Content
View full analysis
= {}): Promise { const urlObj = new URL(url); const isHttps = urlObj.protocol === "https:"; const httpModule = isHttps ? (await import("https")) : http; return new Promise((resolve, reject) => { const body = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }); const options = { hostname: urlObj.hostname, port: urlObj.port || (isHttps ? 443 : 80), path: urlObj.pathname, method: "POST", headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) } }; const req = httpModule.request(options, (res) => { let data = ""; res.on("data", chunk => { data += chunk; }); res.on("end", () => { try { const response = JSON.parse(data); resolve(response.result || response); } catch (e) { reject(e); } }); }); req.on("error", reject); req.write(body); req.end(); }); } ``` ```ts const url = params.url || "http://localhost:3000"; try { const result = await mcpRequest(url, "initialize", { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "openclaw-mcp", version: "1.0.0" } }) as { serverInfo: { name: string; version: string } }; ``` ### Technical Analysis The `mcp_echo` tool accepts a caller-controlled URL and passes it directly to a server-side HTTP client. The implementation performs no destination allowlisting, hostname validation, DNS resolution validation, private-address filtering, or protocol restriction beyond treating `https:` specially. Any other parsed protocol is effectively sent through the HTTP module. Because the request originates from the OpenClaw host rather than the exte ...[truncated 1636 chars]- Remediation
View remediation
