Skip to content

Commit b186512

Browse files
author
Jah-yee
committed
fix: enable DNS rebinding protection by default for secure-by-default
Per issue #2269, the current default disables DNS rebinding protection, which makes MCP servers vulnerable to DNS rebinding attacks on local networks. This change switches the default to secure-by-default (enable_dns_rebinding_protection=True), with developers able to explicitly opt-out for backwards compatibility if needed. Reported by @hhhashexe (SkillFence Security)
1 parent 04df856 commit b186512

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mcp/server/transport_security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class TransportSecurityMiddleware:
3737
"""Middleware to enforce DNS rebinding protection for MCP transport endpoints."""
3838

3939
def __init__(self, settings: TransportSecuritySettings | None = None):
40-
# If not specified, disable DNS rebinding protection by default for backwards compatibility
41-
self.settings = settings or TransportSecuritySettings(enable_dns_rebinding_protection=False)
40+
# Secure by default - DNS rebinding protection enabled
41+
self.settings = settings or TransportSecuritySettings(enable_dns_rebinding_protection=True)
4242

4343
def _validate_host(self, host: str | None) -> bool: # pragma: no cover
4444
"""Validate the Host header against allowed values."""

0 commit comments

Comments
 (0)