Open
Conversation
Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
bdf87b4 to
716538f
Compare
Collaborator
|
@saucow some of these checks are being performed already, right? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Updated the MCP Gateway transport layer to safely handle HTTP-based requests by validating the Origin header and aligning the stdio transport lifecycle with other transports.
The gateway now correctly blocks non-localhost browser origins to prevent DNS rebinding and cross-origin attacks, while preserving compatibility with CLI and SDK clients that do not send an Origin header.
This allows the MCP Gateway to be tested and run locally with HTTP / streaming transports in a secure and predictable way.
Related issue
Fixed #336
What was the problem?
When running the MCP Gateway locally using HTTP-based transports (streaming / SSE), the gateway accepted requests from arbitrary browser origins.
Specifically:
Additionally:
As a result:
How this change fixes it
The gateway transport logic was updated to enforce safe defaults while preserving developer workflows.
Specifically:
HTTP-based transports now validate the Origin header
Requests without an Origin header continue to work
The stdio transport now runs asynchronously
Comprehensive unit tests were added to validate:
Origin validation logic
Middleware behavior
Defense-in-depth with authentication
This preserves security guarantees while restoring a clean and predictable local developer experience.
Before / After (Summary)
Before
After