`createMcpExpressApp` / `createMcpHonoApp`: non-loopback `host` silently skips Host/Origin checks (only `0.0.0.0`/`::` warn) |
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend-api-design, security
Research direction
The issue is in packages/middleware/express/src/express.ts and packages/middleware/hono/src/hono.ts. Look at the logic that adds localhostHostValidation middleware and logs warnings. The task is to extend the warning or validation to non-loopback hosts like '192.168.1.10'. Check how allowedHosts and allowedOrigins options are used. A test should verify the warning appears or validation is applied for a non-loopback host.
Written by the indexing model from the issue text.
Description
Static review of public source at commit 603217008710. No traffic was sent to any MCP environment.
createMcpExpressApp (and the matching Hono helper) auto-arm Host + Origin validation only for loopback hosts. Binding to 0.0.0.0 / :: logs a warning, but any other non-loopback host (LAN IP, container hostname, public DNS name) gets neither middleware nor that warning:
packages/middleware/express/src/express.ts (same ladder in packages/middleware/hono/src/hono.ts):
const localhostHosts = ['127.0.0.1', 'localhost', '::1'];
if (localhostHosts.includes(host)) {
app.use(localhostHostValidation());
} else if (host === '0.0.0.0' || host === '::') {
console.warn(
`Warning: Server is binding to ${host} without DNS rebinding protection. ` +
'Consider using the allowedHosts option...'
);
}
// Origin: only armed for loopback or explicit allowedOrigins
So createMcpExpressApp({ host: '192.168.1.10' }) or { host: 'mcp.internal' } serves without Host/Origin checks and without the operator nudge that 0.0.0.0 already gets. DNS rebinding / browser-origin abuse is exactly what those middleware exist for on HTTP MCP endpoints.
Suggested change:
- Treat every non-loopback
hostlike0.0.0.0: requireallowedHosts(and ideallyallowedOrigins), or at least emit the same warning. - Or fail closed: refuse to construct the app for non-loopback binds unless allowlists are provided.
- Keep the explicit opt-out path for demos that truly need an open bind.
Severity: medium as insecure default / defense-in-depth for non-loopback HTTP mounts; not claiming a working exploit against a specific deployment. No proof-of-concept.
Happy to send a focused PR if this direction is useful.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/typescript-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Auth metadata discovery: fallback URL built on resource host instead of authorization-server host Openv1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
modelcontextprotocol/typescript-sdk#2783 · 1 comment ·
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelcontextprotocol/typescript-sdk#2773 · 1 comment ·
-
v2
Difficulty 1/5 Under an hour Newbie friendliness 92/100
modelcontextprotocol/typescript-sdk#2766 · 1 comment ·
All issues in modelcontextprotocol/typescript-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
AOSSIE-Org/DebateAI#582 · 2 comments ·
-
📕documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
db-ux-design-system/core-web#8239 ·