# Jupyter MCP Server: Host-header spoof bypasses the CVE-2026-77359/GHSA-9x8x-crjq-g64h fix

Jupyter MCP Server's localhost middleware trusts the client-supplied Host header, so a forged `Host: localhost` bypasses the CVE-2026-77359 fix and hijacks the code sandbox config.

- Payout: Research
- Severity: critical
- Program: Jupyter MCP Server
- Found by: SyedAnas01
- Disclosed: 2026-11-30
- CVE: CVE-2026-137189
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-f8rf-rcrx-h6r9
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-f8rf-rcrx-h6r9
- Tags: area:ai domain:ai domain:web impact:integrity kind:research platform:ghsa sev:critical tech:python technique:incomplete-fix vuln:access-control vuln:auth-bypass vuln:host-header vuln:misconfiguration

**Target:** Starlette ASGI management routes (/api/connect, /api/stop, /api/healthz)
**Root cause:** ManagementRouteSecurityMiddleware._is_local_hostname compares request.url.hostname, which Starlette builds from the client-supplied Host header, against localhost/127.0.0.1/::1 instead of the real peer address in scope["client"].
**Steps:**
1. Start server with `--insecure-mcp-noauth --transport streamable-http` (binds 0.0.0.0 by default).
2. Send `curl -X PUT /api/connect -H "Host: evil.com"` -> 421 Misdirected Request.
3. Send same request with `-H "Host: localhost"` and attacker payload (`code_sandbox_url`, `document_url`, tokens) -> accepted.
4. Server logs show connect() ran, DocumentCodeSandbox(**data) validated, set_config() overwrote code_sandbox_url, and server attempted kernel connection to attacker infrastructure.
**How found:** Reviewed the fix for CVE-2026-77359/GHSA-9x8x-crjq-g64h, noticed _is_local_hostname does a pure string comparison on the parsed Host header and never references request.client or scope["client"] (confirmed via grep); then verified against pinned starlette==1.6.0 datastructures.py that URL.netloc is built from scope["headers"] host entry when present, falling back to scope["server"] only if absent/malformed.
**Exploitation:** Attacker sends one PUT /api/connect request with a forged `Host: localhost` header from any network location; the middleware passes, the handler accepts attacker-controlled code_sandbox_url/document_url/tokens, overwrites live config, and the server connects a kernel to attacker-controlled infrastructure. Full impact only in --insecure-mcp-noauth mode; in --mcp-token mode only /api/healthz is reachable (info disclosure).
**Escalation:** In secure token mode the spoof only reaches /api/healthz (status/info disclosure); full unauthenticated backend hijack requires --insecure-mcp-noauth mode.
**Insight:** When auditing a localhost-only middleware, check whether the hostname comes from the Host header (client-controlled) versus scope["client"]/peer address; grep the middleware for `request.client` — its absence is the tell. Also check the pinned framework version's URL parsing to confirm header precedence over scope["server"].

## Proof of concept (copied exactly from the original report)

**Forged Host: localhost request to /api/connect**

```
`curl -X PUT /api/connect -H "Host: evil.com"` correctly returns 421 Misdirected Request.

The same request with `-H "Host: localhost"` and a full attacker-controlled payload (`code_sandbox_url`, `document_url`, tokens) is accepted - server logs confirm the `connect()` handler ran, `DocumentCodeSandbox(**data)` validated, and `set_config()` overwrote the live server's `code_sandbox_url` with the attacker's URL, followed by the server actually attempting to connect a kernel to attacker infrastructure.
```

