ruby-sdk/test/mcp
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO db40143402 Reject duplicate SSE connections with 409 to prevent stream hijacking
An attacker who obtains a valid session ID could issue a GET request to
establish a new SSE stream, silently replacing the victim's stream. All
subsequent server-to-client messages (tool responses, notifications)
would then be delivered to the attacker instead of the legitimate client,
with no indication to the victim.

The fix mirrors the Python SDK's approach: when a GET request arrives for
a session that already has an active SSE stream, respond with HTTP 409
Conflict ("Only one SSE stream is allowed per session") and leave the
existing connection intact. Additionally, `store_stream_for_session`
checks for an existing stream under the mutex before storing a new one,
closing the TOCTOU window between the HTTP-level check and the deferred
stream assignment.

Note: exploiting this requires prior knowledge of the session ID
(a `SecureRandom.uuid`), so the practical severity is low in typical local
MCP deployments. The change is still worthwhile as defense-in-depth,
especially for multi-user or network-exposed server deployments.
2026-03-24 19:24:45 +09:00
..
client Add Accept header validation 2026-01-07 14:55:19 +09:00
resource Fix Resource::Contents#to_h to use correct property names per MCP spec 2026-02-19 13:50:10 +09:00
server/transports Reject duplicate SSE connections with 409 to prevent stream hijacking 2026-03-24 19:24:45 +09:00
tool Merge pull request #237 from koic/replace_assert_empty_with_assert_equal_using_explicit_literals 2026-03-03 01:05:16 +09:00
annotations_test.rb Replace assert_empty with assert_equal using explicit literals 2026-02-24 16:09:34 +09:00
client_test.rb Replace assert_empty with assert_equal using explicit literals 2026-02-24 16:09:34 +09:00
configuration_test.rb Merge pull request #192 from koic/add_missing_assertion 2025-12-25 00:33:12 +09:00
content_test.rb Add Content::EmbeddedResource class for embedded resource content type 2026-03-02 01:33:05 +09:00
icon_test.rb Replace assert_empty with assert_equal using explicit literals 2026-02-24 16:09:34 +09:00
instrumentation_test.rb Rename test directory from model_context_protocol to mcp 2025-06-01 02:13:28 +09:00
logging_message_notification_test.rb Add logging support 2026-01-26 22:23:46 +09:00
methods_test.rb Add Elicitation skeleton 2025-11-21 02:42:20 +09:00
prompt_test.rb Fix Prompt#validate_arguments! crash when arguments are nil 2026-03-01 17:21:41 +09:00
resource_template_test.rb Omit icons from responses when empty or nil 2026-01-12 09:46:45 +09:00
resource_test.rb Omit icons from responses when empty or nil 2026-01-12 09:46:45 +09:00
server_context_test.rb Fix tool error handling to follow MCP spec 2025-10-21 18:33:42 -07:00
server_notification_test.rb Add logging support 2026-01-26 22:23:46 +09:00
server_test.rb Merge pull request #237 from koic/replace_assert_empty_with_assert_equal_using_explicit_literals 2026-03-03 01:05:16 +09:00
string_utils_test.rb Fix ReDoS vulnerability in StringUtils#underscore 2026-01-09 01:14:52 +09:00
tool_test.rb Allow $ref in Tool::Schema for protocol version 2025-11-25 2026-02-27 14:33:36 +09:00
transport_test.rb Remove redundant require statements 2025-08-02 00:57:31 +09:00