GHSA-JW52-P54C-W7HJ
McpStreamableServer reflects localhost CORS Origin regardless of bind interface (incomplete fix of GHSA-4pvg-m42h-c3x2)
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-JW52-P54C-W7HJ divulgada | |
| Remediación | Parche 5.17.2 | network-ai · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`McpStreamableServer._handleRequest` (`lib/mcp-transport-http.ts`) reflects any `Origin` matching `^https?://(localhost|127\.0\.0\.1)(:\d+)?$` into `Access-Control-Allow-Origin` regardless of the interface the server is bound to:
const origin = req.headers['origin'] ?? '';
const isLocalOrigin = /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(origin);
if (isLocalOrigin) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Vary', 'Origin');
}This is the very defect fixed for the sibling transport `McpSseServer` in v5.15.2 (GHSA-4pvg-m42h-c3x2). That advisory's Fix section states the invariant generally: *"Only reflect the localhost Origin when the server itself is bound to a loopback interface. In every other bind mode, do not set `Access-Control-Allow-Origin`."* The v5.15.2 commit `95e349a` touches `lib/mcp-transport-sse.ts` only, and `lib/mcp-transport-http.ts` has not been modified since the Streamable transport was introduced in v5.11.0 (`git log v5.11.0..HEAD -- lib/mcp-transport-http.ts` is empty).
Impact
`McpStreamableServerOptions.host` documents `'0.0.0.0'` as a supported deployment with a non-empty secret, and `listen()` only prints a warning for a non-loopback bind. In that supported deployment, a browser page whose Origin is `http://localhost:<port>` - any other local web app / Electron window / dev server on the victim machine, or a DNS-rebinding name that yields a localhost-looking Origin - is granted readable cross-origin access to the unauthenticated `GET /health` and `GET /tools` routes:
- `GET /tools` returns the complete tool catalog: names, descriptions and input schemas (`_handleTools`), including application-specific tool metadata registered on the bridge.
- `GET /health` returns bridge name, client count and protocol version.
Bearer auth still gates `/mcp` and `/` (POST and GET), so tool invocation still requires the token. The exposure is the unauthenticated read routes plus a broken invariant: downstream code that assumes "if `Access-Control-Allow-Origin` was set, the Origin is trusted local" is now wrong on any external bind. Same impact class, preconditions and severity as GHSA-4pvg-m42h-c3x2 (Low).
Proof of Concept
Run against the published `network-ai@5.17.1` tarball with a non-empty secret and a dummy tool provider (so `/tools` has content). All responses HTTP 200:
server / bind request Origin Access-Control-Allow-Origin
McpStreamableServer 0.0.0.0 GET /tools http://localhost:9999 http://localhost:9999
McpStreamableServer 0.0.0.0 GET /tools http://127.0.0.1:9999 http://127.0.0.1:9999
McpStreamableServer 0.0.0.0 GET /health http://localhost:9999 http://localhost:9999
McpStreamableServer 0.0.0.0 GET /tools http://evil.example (none)
McpStreamableServer 0.0.0.0 GET /tools (no Origin) (none)
McpSseServer 0.0.0.0 GET /tools http://localhost:9999 (none) <- fixed sibling
McpSseServer 0.0.0.0 GET /health http://localhost:9999 (none) <- fixed sibling
McpStreamableServer 127.0.0.1 GET /tools http://localhost:9999 http://localhost:9999Body returned cross-origin with the reflected header:
{"tools":[{"name":"internal_admin_export","description":"INTERNAL ONLY - exports tenant data from https://internal-api.corp.local/v1/export","inputSchema":{...}}]}Minimal harness:
const { McpStreamableServer } = require('network-ai/dist/lib/mcp-transport-http');
const { McpCombinedBridge } = require('network-ai/dist/lib/mcp-transport-sse');
const bridge = new McpCombinedBridge('poc');
bridge.register({ getDefinitions: () => [{ name: 'internal_admin_export',
description: 'INTERNAL ONLY', inputSchema: { type: 'object' } }],
callTool: async () => ({ content: [] }) });
const s = new McpStreamableServer(bridge, { port: 34102, host: '0.0.0.0',
secret: 'S'.repeat(48), heartbeatMs: 0 });
await s.listen();
// GET /tools with header Origin: http://localhost:9999
// -> Access-Control-Allow-Origin: http://localhost:9999Affected versions
`>= 5.11.0, <= 5.17.1` (npm latest at report time is 5.17.1). The Streamable transport was added in v5.11.0 and the file is unchanged through tag `v5.17.1` / HEAD `b9f1e55`.
Fix
Reuse the existing helper (added in v5.15.2) or mirror the SSE guard:
import { isLoopbackHost } from './http-guards';
...
if (isLocalOrigin && isLoopbackHost(this._opts.host)) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Vary', 'Origin');
}Why this is not a duplicate
- The repository's 20 published advisories do not name the Streamable HTTP transport or `lib/mcp-transport-http.ts`.
- GHSA-4pvg-m42h-c3x2 names `McpSseServer` / `lib/mcp-transport-sse.ts`, and its fix commit `95e349a` does not touch the Streamable handler.
- Issue search `repo:Jovancoding/Network-AI streamable cors` returns 0 results.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmnetwork-ai |
Corregida | 5.17.2 | 0 d | 6.0.1 no afectada |
5.17.2Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Jovancoding/Network-AI/security/advisories/GHSA-jw52-p54c-w7hjLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
