From 1ca26c508db14b141935c8f1c7c71660c8a14273 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 18 Jul 2026 02:00:46 +0100 Subject: [PATCH] fix(gateway): reject malformed MCP sandbox policy (#110264) Co-authored-by: Patrick Erichsen --- src/gateway/mcp-app-sandbox-http.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gateway/mcp-app-sandbox-http.ts b/src/gateway/mcp-app-sandbox-http.ts index 015c34be0464..95ea9249dc50 100644 --- a/src/gateway/mcp-app-sandbox-http.ts +++ b/src/gateway/mcp-app-sandbox-http.ts @@ -30,9 +30,13 @@ function handleMcpAppSandboxHttpRequest(req: IncomingMessage, res: ServerRespons return; } + const encodedCsp = url.searchParams.get("csp"); let csp; try { - csp = decodeMcpAppSandboxCsp(url.searchParams.get("csp")); + csp = decodeMcpAppSandboxCsp(encodedCsp); + if (encodedCsp !== null && !csp) { + throw new Error("invalid MCP App sandbox policy"); + } } catch { res.statusCode = 400; res.setHeader("Content-Type", "text/plain; charset=utf-8");