NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Other MCP servers and tools

CVE-2026-33946: MCP Ruby SDK: Insufficient Session Binding Allows SSE Stream Hijacking via Session ID Replay

highCVSS 4.0 8.2GHSA-qvqr-5cv7-wh35

The MCP Ruby SDK (the mcp gem) up to 0.9.1 keeps one SSE stream per session ID and lets a second GET with the same Mcp-Session-Id replace it. An attacker who learns a session ID takes over the victim's stream and receives every later tool response. Upgrade the mcp gem to 0.9.2.

Published Mar 27, 2026 · Updated Mar 30, 2026 · Analysis Oct 31, 2026

What an attacker can do

In lib/mcp/server/transports/streamable_http_transport.rb, store_stream_for_session wrote the new stream over the old one: @sessions[session_id][:stream] = stream. Nothing tied a session to a user, and nothing rejected a second connection. When the attacker sends GET / with the victim's Mcp-Session-Id, the victim's stream is silently dropped and the server writes all later notifications and tool responses to the attacker's stream.

The attacker needs a valid session ID, which the report calls out of scope for how it is obtained, and network access to the MCP server. The CVSS 4.0 vector marks attack requirements as present and rates confidentiality impact high (8.2). Tool responses can carry confidential data, so the loss is whatever your MCP tools return. The victim sees no data and no error.

The Python SDK already answers a duplicate SSE connection with 409 Conflict, and only the C# and Go SDKs bind sessions to user identity. Local, single-user servers carry less risk. Multi-user or network-exposed servers carry the most.

Who is affected

The mcp gem (rubygems) 0.9.1 and earlier, for servers built on the StreamableHTTPTransport class. Stdio-only servers are not affected. Check the version:

gem list mcp

In a bundler project, run bundle list mcp.

mcp

Ecosystem
RubyGems
Affected
<= 0.9.1
Fixed in
0.9.2
Check
bundle info mcp

How to fix it

Upgrade to mcp 0.9.2:

gem update mcp

Or set the version in your Gemfile and run bundle update mcp. Commit db40143402d6 makes handle_get reject a GET for a session that already has an SSE stream, with HTTP 409 and the error "Conflict: Only one SSE stream is allowed per session." It also checks for an existing stream under the mutex in store_stream_for_session to close the race. The commit calls this defense-in-depth. Binding sessions to authenticated users is still your server's job.

How to tell if you were hit

Look in server logs for several GET requests carrying one Mcp-Session-Id from different client addresses. Watch for clients whose SSE stream drops without a client-side reason and stops receiving notifications. After the upgrade, a second connection attempt gets 409 and appears in logs as a conflict.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

The Ruby SDK's streamable_http_transport.rb implementation contains a session hijacking vulnerability. An attacker who obtains a valid session ID can completely hijack the victim's Server-Sent Events (SSE) stream and intercept all real-time data.

Details

Root Cause The StreamableHTTPTransport implementation stores only one SSE stream object per session ID and lacks:

  • Session-to-user identity binding
  • Ownership validation when establishing SSE connections
  • Protection against multiple simultaneous connections to the same session

PoC

Vulnerable Code

File: streamable_http_transport.rb - L336-L339:

def store_stream_for_session(session_id, stream)
  @mutex.synchronize do
    if @sessions[session_id]
      @sessions[session_id][:stream] = stream  # OVERWRITES existing stream
    else
      stream.close
    end
  end
end

Attack Scenario

Step 1: Legitimate Session Establishment

POST / (initialize) → receives session_id: "abc123"
GET / with Mcp-Session-Id: abc123 → SSE stream connected

Step 2: Session ID Compromise

  • An attacker obtains the session ID through various means (out of scope for this analysis)

Step 3: Stream Hijacking

GET / with Mcp-Session-Id: abc123 
@sessions["abc123"][:stream] = attacker_stream `# Victim's stream is REPLACED (silently disconnected)

Step 4: Data Interception

  • ALL subsequent tool responses/notifications go to the attacker
  • The legitimate user receives no data and has no indication of the hijacking

Technical Details

The vulnerability happens:

Client 1 connects (GET request)

proc do |stream1|  # ← Rack server provides stream1 for client 1
 @sessions[session_id][:stream] = stream1  # Stored
end

Client 2 connects with SAME session ID (Attack!)

proc do |stream2|  # ← Rack provides stream2 for client 2
 @sessions[session_id][:stream] = stream2  # REPLACES stream1!
end

Now when the server sends notifications:

@sessions[session_id][:stream].write(data)  # Goes to stream2 (attacker!)
# stream1 (victim) receives nothing

Comparison: Python SDK Protection

The Python SDK prevents this vulnerability by rejecting duplicate SSE connections:

Refer: https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/server/streamable_http.py#L680-L685

if GET_STREAM_KEY in self._request_streams:  # pragma: no cover
            response = self._create_error_response(
                "Conflict: Only one SSE stream is allowed per session",
                HTTPStatus.CONFLICT,
            )

When a duplicate connection attempt is detected, the Python SDK returns an HTTP 409 Conflict error, protecting the existing connection.

Recommended Mitigations For SDK Maintainers

  • Implement User Binding: All SDKs should bind session IDs to authenticated user identities where possible. Currently only, go-sdk and csharp-sdk do user binding.
  • Ruby SDK: Prevent Duplicate Connections: Implement checks to reject or handle multiple simultaneous connections to the same session
  • Improve Documentation: Provide clear guidance on secure session management implementation for SDK consumers

Steps To Reproduce:

Please find attached two python client files demonstrating the attack

Terminal 1: ruby streamable_http_server.rb

Makes use of https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/streamable_http_server.rb This server has a tool call notification_tool which the clients call

Terminal 2:

python3 legitimate_client_ruby_server.py

What happens:

  • The client connects and prints the session ID
  • Press Enter to start the SSE stream
  • Notifications start appearing every 3 seconds as the client makes a tool call

Terminal 3 (while the legitimate client is running):

python3 attacker_client_ruby_server.py <SESSION_ID>

Replace <SESSION_ID> with the ID from Terminal 2.

What happens immediately:

  • Terminal 2 (Legitimate): Stops receiving notifications, shows disconnect message
  • Terminal 3 (Attacker): Starts receiving ALL the tool call responses

Impact

While the absence of user binding may not pose immediate risks if session IDs are not used to store sensitive data or state, the fundamental purpose of session IDs is to maintain stateful connections. If the SDK or its consumers utilize session IDs for sensitive operations without proper user binding controls, this creates a potential security vulnerability. For example: In the case of the Ruby SDK, the attacker was able to hijack the stream and receive all the tool responses belonging to the victim. The tool responses can be sensitive confidential data.

Additional Details

Session Hijacking Protection in MCP Implementations

The MCP specification recommends - "MCP servers SHOULD bind session IDs to user-specific information".

Current Implementation Status Across SDKs

Of the 10 official MCP SDKs, only the following implementations bind session IDs to user-specific information:

  1. csharp-sdk - https://github.com/modelcontextprotocol/csharp-sdk/blob/main/src/ModelContextProtocol.AspNetCore/SseHandler.cs#L93-L97
  2. Go-sdk - https://github.com/modelcontextprotocol/go-sdk/blob/main/mcp/streamable.go#L281C1-L288C2

attacker_client_ruby_server.py legitimate_client_ruby_server.py The remaining SDKs do not implement session-to-user binding. Most implementations only verify that a session ID exists, without validating ownership. Additionally, SDK documentation does not provide clear guidance on implementing secure session management, leaving security responsibilities unclear for SDK consumers.

Credited to srikanthramu.

Questions

How does the attacker get a session ID?

The advisory does not say; it treats that as out of scope. Leaks through logs, URLs or a shared network are possible routes. Without the ID the attack does not work.

Do other MCP SDKs have this problem?

The report says only the C# and Go SDKs bind sessions to user identity, and the Python SDK rejects duplicate SSE streams with a 409. This advisory covers only the Ruby SDK.

Does upgrading to 0.9.2 bind sessions to users?

No. It blocks a second stream per session. If you need user binding, add authentication in your own server.

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 entries