fix(gateway): reject malformed MCP sandbox policy (#110264)

Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com>
This commit is contained in:
Peter Steinberger
2026-07-18 02:00:46 +01:00
committed by GitHub
parent 6f0f6af62e
commit 1ca26c508d

View File

@@ -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");