---
title: "Jupyter MCP Server Host-Header Spoof Bypasses Localhost Fix"
slug: "jupyter-mcp-server-host-header-spoof-cve-2026-137189"
description: "Defensive teardown of CVE-2026-137189: Starlette Host-header parsing bypasses localhost middleware in jupyter-mcp-server before 2.1.3, plus patch checks."
author: "Hamdi Soudani"
category: "ai-security-jailbreaks"
archetype: "advisory-teardown"
published_at: "2026-12-04T21:05:48.163+00:00"
updated_at: "2026-12-04T21:05:48.271621+00:00"
canonical_url: "https://pyvren.com/blog/jupyter-mcp-server-host-header-spoof-cve-2026-137189"
reading_time_minutes: 4
word_count: 782
quality_score: 94
tags: ["ai-security-jailbreaks","mcp-server","cve-2026-137189"]
keywords: ["jupyter mcp server host header spoof","cve-2026-137189 patch verification","management route security middleware localhost bypass","starlette host header tcp peer validation","jupyter-mcp-server 2.1.3 upgrade"]
sources: ["https://github.com/advisories/GHSA-f8rf-rcrx-h6r9","https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189","https://app.opencve.io/cve/CVE-2026-137189"]
---

# Jupyter MCP Server Host-Header Spoof Bypasses Localhost Fix

> **TL;DR:** Upgrade jupyter-mcp-server to 2.1.3 or validate the actual TCP peer address instead of the client-supplied Host header to prevent unauthenticated management-route hijacking.

## Key Facts

- **CVE identifier:** CVE-2026-137189 (GHSA-f8rf-rcrx-h6r9) ([source](https://github.com/advisories/GHSA-f8rf-rcrx-h6r9))
- **CVSS v4.0 score:** 9.3 Critical ([source](https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189))
- **Affected versions:** jupyter-mcp-server < 2.1.3 ([source](https://github.com/advisories/GHSA-f8rf-rcrx-h6r9))
- **Patched version:** 2.1.3 ([source](https://github.com/advisories/GHSA-f8rf-rcrx-h6r9))
- **EPSS exploitation probability:** 0.442% ([source](https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189))
- **CISA SSVC exploitation status:** Public exploit code ([source](https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189))

## Threat Model & Attack Surface Matrix

| Attack surface | Blast radius | Concrete control |
| --- | --- | --- |
| /api/connect management route | Unauthenticated backend configuration hijack; attacker-controlled code_sandbox_url and document_url can redirect kernel execution to attacker infrastructure | Upgrade to jupyter-mcp-server 2.1.3; enforce TCP peer validation; disable --insecure-mcp-noauth |
| /api/stop management route | Denial of service by stopping the MCP server process remotely | Require bearer token; isolate management network |
| /api/healthz management route | Information disclosure and service enumeration from remote networks | Restrict to loopback interface; validate Host header against allowlist |
| Default 0.0.0.0 bind | Remote network reachability of all management routes without local network assumptions | Bind to 127.0.0.1 or ::1; use host firewall or network segmentation |
| Starlette URL parsing dependency | Host-header-derived hostname trusted over actual TCP peer | Validate scope["client"] or request.client in middleware before route access |

The root cause is a trust-boundary violation in `ManagementRouteSecurityMiddleware.dispatch` and `_is_local_hostname` at `jupyter_mcp_server/server.py:105-169`. The middleware performs a pure string comparison against `request.url.hostname`, which Starlette derives from the client-supplied `Host` header whenever one is present. It never references `request.client` or `scope["client"]`. A remote caller can supply `Host: localhost` to pass the check regardless of the actual TCP peer address. Because the server binds to `0.0.0.0` by default, this is reachable from the network, not just localhost. In `--insecure-mcp-noauth` mode, the caller can replace the active Jupyter backend configuration. In `--mcp-token` mode, state-changing routes still require a bearer token, but `/api/healthz` remains reachable via the spoof.

This failure pattern mirrors indirect prompt injection via tool outputs: the system trusts attacker-controlled input that arrives through a legitimate channel. Here the channel is the HTTP `Host` header, and the trusted component is the localhost middleware. Naive string filters on the parsed hostname fail because they operate on data the client controls. Any defense that inspects `request.url.hostname` without cross-referencing the transport-layer peer address is bypassable with a single forged header. DNS rebinding is not required, which distinguishes this bypass from the original GHSA-9x8x-crjq-g64h fix for CVE-2026-77359/CVE-2026-77318.

## Why Naive Prompt Filters Fail

Naive hostname string filters fail because they operate on data the client controls. Any defense that inspects `request.url.hostname` without cross-referencing the transport-layer peer address is bypassable with a single forged header. DNS rebinding is not required, which distinguishes this bypass from the original GHSA-9x8x-crjq-g64h fix for CVE-2026-77359/CVE-2026-77318.

OWASP LLM01 (prompt injection) and LLM02 (insecure output handling) describe the same trust inversion: an LLM or middleware component treats attacker-controlled data as trustworthy because it arrives through a seemingly legitimate channel. Multi-turn guardrail drift compounds the risk when an agent fetches tool output across multiple requests and progressively relaxes validation assumptions. A hostname check that ignores `scope["client"]` is the infrastructure equivalent of an LLM accepting a web-fetched instruction as system policy.

## Defense-in-Depth & Sandbox Isolation Architecture

Deploy the MCP server behind an authenticated reverse proxy that terminates untrusted `Host` headers and forwards only validated values. Bind the application socket to `127.0.0.1` rather than `0.0.0.0` so remote hosts cannot reach management routes at the TCP layer. Run the server in a restricted container or sandbox with no outbound network access to attacker-controlled `code_sandbox_url` endpoints, and enforce egress allowlists. Never run `--insecure-mcp-noauth` in production; the CLI itself labels this mode as not recommended for production, yet its entire security guarantee rested on the broken localhost check.

A defense-in-depth stack should layer transport validation, application-layer patching, network segmentation, and runtime sandboxing. If one layer fails—for example, if a reverse proxy misconfiguration forwards a forged `Host` header—the TCP peer validation in the patched middleware still blocks remote callers.

## Runnable Guardrail Policy / Verification Code

```python
# Defensive middleware patch: validate actual TCP peer, not client-supplied Host header
from starlette.datastructures import URL
from starlette.responses import PlainTextResponse
from starlette.types import ASGIApp, Receive, Scope, Send

LOCAL_HOSTNAMES = {"localhost", "127.0.0.1", "::1"}
MANAGEMENT_ROUTES = {"/api/connect", "/api/stop", "/api/healthz"}

class ManagementRouteSecurityMiddleware:
    def __init__(self, app: ASGIApp) -> None:
        self.app = app

    async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
        if scope["type"] == "http":
            path = scope.get("path", "")
            if path in MANAGEMENT_ROUTES:
                client = scope.get("client")
                peer_host = client[0] if client and len(client) > 0 else None
                if peer_host not in LOCAL_HOSTNAMES:
                    response = PlainTextResponse("Forbidden", status_code=403)
                    await response(scope, receive, send)
                    return
        await self.app(scope, receive, send)
```

Verify the installed version:

```bash
pip show jupyter-mcp-server | grep -E '^(Name|Version)'
# Expected: Version: 2.1.3 or later
```

Confirm the server is not binding to all interfaces:

```bash
ss -ltnp | grep jupyter-mcp
# Expected: local address 127.0.0.1 or ::1, not 0.0.0.0
```

Test that a forged Host header from a non-local peer is rejected:

```bash
curl -s -o /dev/null -w "%{http_code}\n" -X PUT http://127.0.0.1:PORT/api/connect \
  -H "Host: localhost" -H "Content-Type: application/json" \
  -d '{"code_sandbox_url":"http://attacker.example/sandbox"}'
# Expected on patched server: 403 when request.client is non-loopback
```

## Operational Tradeoffs & False-Positive Budget

Validating `scope["client"]` breaks legitimate deployments where the MCP server sits behind a trusted reverse proxy and the real client IP is carried in `X-Forwarded-For`. In those architectures, validate the proxy’s own IP as a trusted ingress point and extract the original client from a validated header only after confirming the direct connection originates from the proxy. Binding to `127.0.0.1` prevents remote access but also prevents container sidecars or adjacent pods from reaching the MCP server unless they share the network namespace or use an explicit ingress controller. The false-positive rate for TCP peer validation is effectively zero for loopback-only policies, but operational overhead increases when managing hybrid local-and-remote topologies.

Patch immediately. Versions earlier than 2.1.3 are affected, and CISA SSVC assesses public exploit code with full control impact. The EPSS probability is 0.442%, but low exploit probability does not reduce blast radius in exposed environments.

![CVE-2026-137189 advisory card](https://radar.cloudflare.com/api/og/zero-wire/cves/CVE-2026-137189)

For additional vulnerability context, see the GitHub Advisory Database entry [GHSA-f8rf-rcrx-h6r9](https://github.com/advisories/GHSA-f8rf-rcrx-h6r9) and the Cloudflare Radar CVE record [CVE-2026-137189](https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189). The OpenCVE vulnerability details page [CVE-2026-137189](https://app.opencve.io/cve/CVE-2026-137189) provides cross-referenced identifiers and patch status.

## Frequently Asked Questions

### Does --mcp-token mode fully protect against this bypass?

No. In --mcp-token mode, /api/connect and /api/stop still require a valid bearer token after the Host check passes, but /api/healthz remains reachable via the spoof, creating an information-disclosure and status-enumeration gap. The full unauthenticated backend hijack applies to --insecure-mcp-noauth mode.

### Why does checking request.url.hostname fail as a localhost control?

Starlette builds URL.netloc from the client-supplied Host header whenever that header is present and syntactically valid, falling back to scope["server"] (the real bind address) only when the header is absent or malformed. The middleware never inspects request.client or scope["client"], so a forged Host: localhost header from any remote IP passes the check.

### Can DNS rebinding be used instead of a forged Host header?

DNS rebinding is not required for this bypass. The vulnerability is a pure Host-header trust issue, distinct from the original GHSA-9x8x-crjq-g64h fix for CVE-2026-77359/CVE-2026-77318.

## Primary Sources

- https://github.com/advisories/GHSA-f8rf-rcrx-h6r9
- https://radar.cloudflare.com/zero-wire/cves/CVE-2026-137189
- https://app.opencve.io/cve/CVE-2026-137189
