Repository navigation
feat(mcp): opt-in DNS rebinding protection for localhost Host/Origin - #3022
Merged
howardjohn merged 3 commits intoAug 14, 2026
Merged
Conversation
Add dnsRebindingProtection on MCP backends (off by default). When enabled, requests whose Host or Origin is not localhost/127.0.0.1/[::1] are rejected with 403, matching the MCP localhost DNS-rebinding requirement without breaking typical proxy deployments. Signed-off-by: Piyush Jagadish Bag <[email protected]>
Keep dnsRebindingProtection off-by-default out of serialized MCP backends and document the field in config.md so proxy-lint and snapshot tests pass. Signed-off-by: Piyush Jagadish Bag <[email protected]>
howardjohn
approved these changes
Aug 14, 2026
Signed-off-by: John Howard <[email protected]>
howardjohn
force-pushed
the
feat/mcp-dns-rebinding-protection
branch
from
August 14, 2026 19:34
2ebb93d to
0083d57
Compare
gaogaoSpark
pushed a commit
to gaogaoSpark/agentgateway
that referenced
this pull request
Aug 28, 2026
…gentgateway#3022) ## Summary - Opt-in `dnsRebindingProtection` on MCP backends (default off), as requested in agentgateway#1855. - When enabled, Host/Origin must be `localhost`, `127.0.0.1`, or `[::1]` (optional port); otherwise the gateway returns 403. - Off by default so typical proxy deployments are unchanged. Fixes agentgateway#1855 ## Test plan - [x] Unit tests for Host/Origin localhost parsing - [x] E2E: protection off still allows `Origin: http://evil.example` - [x] E2E: protection on rejects non-localhost Origin (403) and allows localhost Origin (200) - [x] E2E: raw HTTP `Host: evil.example` returns 403 ```text $ cargo test -p agentgateway --lib dns_rebinding -- --nocapture test mcp::dns_rebinding::tests::rejects_non_localhost_origin_even_with_localhost_host ... ok test mcp::dns_rebinding::tests::rejects_non_localhost_host ... ok test mcp::dns_rebinding::tests::accepts_localhost_origin ... ok test mcp::dns_rebinding::tests::accepts_localhost_hosts ... ok test mcp::dns_rebinding::tests::reject_non_localhost_builds_403 ... ok test mcp::tests::dns_rebinding_protection_rejects_non_localhost_host ... ok test mcp::tests::dns_rebinding_protection_off_allows_non_localhost_origin ... ok test mcp::tests::dns_rebinding_protection_rejects_non_localhost_origin ... ok test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 1725 filtered out ``` --------- Signed-off-by: Piyush Jagadish Bag <[email protected]> Signed-off-by: John Howard <[email protected]> Co-authored-by: John Howard <[email protected]> Signed-off-by: rayze <[email protected]>
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.
Summary
dnsRebindingProtectionon MCP backends (default off), as requested in Support MCP DNS rebinding specification #1855.localhost,127.0.0.1, or[::1](optional port); otherwise the gateway returns 403.Fixes #1855
Test plan
Origin: http://evil.exampleHost: evil.examplereturns 403