Skip to content

Allow the end-to-end test's host under DNS rebinding protection - #614

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:allow_the_end_to_end_host_under_dns_rebinding_protection
Oct 15, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:allow_the_end_to_end_host_under_dns_rebinding_protection

Conversation

@koic

@koic koic commented Oct 15, 2026

Copy link
Copy Markdown
Member

Motivation and Context

MCP::Server::OAuth::EndToEndTest drives the SDK's HTTP client against a Rack stack through WebMock's to_rack, which until WebMock 3.32 passed the app no Host header. WebMock 3.34.0 fills HTTP_HOST in from the request URL, so the transport's DNS rebinding protection, on by default, now refuses mcp.example.com with 403 Forbidden: Invalid Host header, and the test errors with "You are forbidden to make initialize requests" on every CI run since that release.

The test now builds the transport with allowed_hosts: ["mcp.example.com"], as a deployment serving that host would, so it passes with either WebMock. The library is unchanged.

How Has This Been Tested?

test/mcp/server/oauth/end_to_end_test.rb with WebMock 3.34.0, where it errored before, and with WebMock 3.26.4, where it passed before and still does.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

`MCP::Server::OAuth::EndToEndTest` drives the SDK's HTTP client against a Rack stack through WebMock's
`to_rack`, which until WebMock 3.32 passed the app no `Host` header. WebMock 3.34.0 fills `HTTP_HOST` in
from the request URL, so the transport's DNS rebinding protection, on by default, now refuses
`mcp.example.com` with `403 Forbidden: Invalid Host header`, and the test errors with
"You are forbidden to make initialize requests" on every CI run since that release.

The test now builds the transport with `allowed_hosts: ["mcp.example.com"]`, as a deployment serving
that host would, so it passes with either WebMock. The library is unchanged.

## How Has This Been Tested?

`test/mcp/server/oauth/end_to_end_test.rb` with WebMock 3.34.0, where it errored before, and with
WebMock 3.26.4, where it passed before and still does.

## Breaking Changes

None.
@koic
koic merged commit 0019b4d into modelcontextprotocol:main Oct 15, 2026
11 checks passed
@koic
koic deleted the allow_the_end_to_end_host_under_dns_rebinding_protection branch October 15, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant