fix(mcp): refuse panel requests to routes reached through a dot suffix

The server routes a mounted path when a dot follows it, so /mcp.json reached
the MCP endpoint while panel_request refused only /mcp and /mcp/...; the same
held for the provider-settings, credential and model routes. The refusals now
match a dot after the route as well. A regression test drives panel_request
against a real Vite server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Sameh KhamisandClaude Opus 5.5 committed 2026-10-02 20:10:47 -07:00
1 parent 6cdd6c8af9
commit 81513f9aae
5 files changed
+109 -8

No files matched your search

+7 -6
View File
@@ -25,13 +25,14 @@ const HELD_LIMIT_BYTES = 256 * 1024 * 1024;
export const PANEL_RESPONSE_LIMIT_BYTES = 64 * 1024 * 1024;
const REQUEST_TIMEOUT_MS = 60 * 1000;
const METHODS = new Set(['GET', 'HEAD', 'POST']);
// Routes the panel never loads, matched without regard to case as the
// server routes them: Provider Settings, which only the app's own page may
// use; credential and model endpoints; the MCP server itself; and the
// development server's internal routes.
// Routes the panel never loads, matched as the server routes them: without
// regard to case, and with a mounted route also matching when a dot follows
// it (`/mcp.json` reaches `/mcp`). Provider Settings, which only the app's own
// page may use; credential and model endpoints; the MCP server itself; and
// the development server's internal routes.
const REFUSED_PATHS = [
/^\/api\/(?:setup|realtime|openai)(?:\/|$)/i,
/^\/mcp(?:\/|$)/i,
/^\/api\/(?:setup|realtime|openai)(?:[/.]|$)/i,
/^\/mcp(?:[/.]|$)/i,
/^\/(?:@|__)/,
];
const FORWARDED_REQUEST_HEADERS = ['accept', 'content-type'];
+6
View File
@@ -234,6 +234,12 @@ test('routes the panel never loads are refused in any case or encoding', async (
'/api/%4fpenai/hud-summary',
'/mcp',
'/MCP',
// A dot after a mounted route still reaches it.
'/mcp.json',
'/MCP.json',
'/api/setup.json',
'/api/realtime.token',
'/api/OpenAI.x/hud-summary',
'/@fs/etc/passwd',
'/@vite/client',
'/%40fs/x',