Skip to main content

Jupyter MCP Server Host-Header Spoof Bypasses Localhost Fix

Defensive teardown of CVE-2026-137189: Starlette Host-header parsing bypasses localhost middleware in jupyter-mcp-server before 2.1.3, plus patch checks.

AI SECURITY Security Advisory
CVE-2026-137189: Jupyter MCP Server host-header spoof bypasses localhost fix, 9.3 Critical
CVE-2026-137189: Jupyter MCP Server host-header spoof bypasses localhost fix, 9.3 Critical Source: radar.cloudflare.com
Field Note · The Short Version 4 min read

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 Numbers & Verified Specs

6 metrics
Metric / Spec Verified Finding Source
CVE identifier CVE-2026-137189 (GHSA-f8rf-rcrx-h6r9) github.com
CVSS v4.0 score 9.3 Critical radar.cloudflare.com
Affected versions jupyter-mcp-server < 2.1.3 github.com
Patched version 2.1.3 github.com
EPSS exploitation probability 0.442% radar.cloudflare.com
CISA SSVC exploitation status Public exploit code radar.cloudflare.com
Jump to section (5) +

Threat Model & Attack Surface Matrix

Attack surfaceBlast radiusConcrete control
/api/connect management routeUnauthenticated backend configuration hijack; attacker-controlled code_sandbox_url and document_url can redirect kernel execution to attacker infrastructureUpgrade to jupyter-mcp-server 2.1.3; enforce TCP peer validation; disable --insecure-mcp-noauth
/api/stop management routeDenial of service by stopping the MCP server process remotelyRequire bearer token; isolate management network
/api/healthz management routeInformation disclosure and service enumeration from remote networksRestrict to loopback interface; validate Host header against allowlist
Default 0.0.0.0 bindRemote network reachability of all management routes without local network assumptionsBind to 127.0.0.1 or ::1; use host firewall or network segmentation
Starlette URL parsing dependencyHost-header-derived hostname trusted over actual TCP peerValidate 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

Python23 lines
# 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:

Bash2 lines
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:

Bash2 lines
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:

Bash4 lines
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
CVE-2026-137189 advisory card

For additional vulnerability context, see the GitHub Advisory Database entry GHSA-f8rf-rcrx-h6r9 and the Cloudflare Radar CVE record CVE-2026-137189. The OpenCVE vulnerability details page CVE-2026-137189 provides cross-referenced identifiers and patch status.

Reader Q&A

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.

Bibliography & Verification

Primary Sources & References

3 cited sources
  1. [01] github.com advisories / GHSA-f8rf-rcrx-h6r9
  2. [02] radar.cloudflare.com zero-wire / cves / CVE-2026-137189
  3. [03] app.opencve.io cve / CVE-2026-137189

Human × Agent Co-Work

Hamdi Soudani · in collaboration with Pyvren

Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.

Hamdi Soudani × Pyvren

Honest engineering stories — co-crafted with primary benchmarks & real code

Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.