fix(security): guard cowork-mcp-tools probe against SSRF (#3783)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"use server";
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { assertPublicUrl } from "@/shared/utils/ssrfGuard.js";
|
||||
import { isLocalRequest } from "@/dashboardGuard";
|
||||
|
||||
const TIMEOUT_MS = 8000;
|
||||
|
||||
@@ -87,6 +89,14 @@ export async function POST(request) {
|
||||
if (!url || typeof url !== "string") {
|
||||
return NextResponse.json({ error: "url required" }, { status: 400 });
|
||||
}
|
||||
// SSRF guard for remote callers; local host keeps self-hosted MCP servers.
|
||||
if (!isLocalRequest(request)) {
|
||||
try {
|
||||
assertPublicUrl(url);
|
||||
} catch {
|
||||
return NextResponse.json({ error: "URL not allowed" }, { status: 400 });
|
||||
}
|
||||
}
|
||||
const result = await probeMcp(url);
|
||||
return NextResponse.json(result);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user