Skip to content

Commit 62ff4c2

Browse files
test(conformance): enable DNS rebinding protection in everything server
The SDK has localhostHostValidation() middleware; the conformance test server just wasn't using it. Add it so the dns-rebinding-protection scenario passes instead of baselining it as an expected failure.
1 parent 54fa771 commit 62ff4c2

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

test/conformance/expected-failures.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
client:
55
- auth/pre-registration
66
- auth/cross-app-access-complete-flow
7-
8-
server:
9-
- dns-rebinding-protection

test/conformance/src/everythingServer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { randomUUID } from 'node:crypto';
1111

12+
import { localhostHostValidation } from '@modelcontextprotocol/express';
1213
import { NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node';
1314
import type { CallToolResult, EventId, EventStore, GetPromptResult, ReadResourceResult, StreamId } from '@modelcontextprotocol/server';
1415
import { isInitializeRequest, McpServer, ResourceTemplate } from '@modelcontextprotocol/server';
@@ -876,6 +877,9 @@ function createMcpServer() {
876877
const app = express();
877878
app.use(express.json());
878879
880+
// DNS rebinding protection: reject non-localhost Host headers
881+
app.use(localhostHostValidation());
882+
879883
// Configure CORS to expose Mcp-Session-Id header for browser-based clients
880884
app.use(
881885
cors({

0 commit comments

Comments
 (0)