mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(gateway): reject malformed MCP sandbox policy
This commit is contained in:
@@ -30,9 +30,14 @@ 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);
|
||||
// The decoder also returns undefined for malformed input; only an absent query may use defaults.
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user