Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ To prevent DNS rebinding attacks, the MCP Inspector validates the `Origin` heade
ALLOWED_ORIGINS=http://localhost:6274,http://localhost:8000 npm start
```

Validation fails closed: a request whose `Origin` header is **missing** is rejected with `403` just like one whose `Origin` is not on the allow list. Browsers always send `Origin` on the cross-origin requests the Inspector client makes, so normal use is unaffected — but a non-browser client (curl, Postman, a CI script) driving the proxy API directly must send the header explicitly, for example `-H "Origin: http://localhost:6274"`. The unauthenticated `/health` endpoint is not origin-checked, so container health checks are unaffected.

### Configuration

The MCP Inspector supports the following configuration settings. To change them, click on the `Configuration` button in the MCP Inspector UI:
Expand Down
12 changes: 9 additions & 3 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,18 @@ const originValidationMiddleware = (
defaultOrigin,
];

if (origin && !allowedOrigins.includes(origin)) {
console.error(`Invalid origin: ${origin}`);
if (!origin || !allowedOrigins.includes(origin)) {
Comment thread
cliffhall marked this conversation as resolved.
// Distinguish the two rejection causes so operators can tell a genuine
// cross-origin attempt from a non-browser client that sent no Origin at all.
console.error(
origin
? `Invalid origin: ${origin}`
: "Missing origin header - request rejected",
);
res.status(403).json({
error: "Forbidden - invalid origin",
message:
"Request blocked to prevent DNS rebinding attacks. Configure allowed origins via environment variable.",
"Request blocked to prevent DNS rebinding attacks. Requests must send an Origin header matching an allowed origin; configure allowed origins via the ALLOWED_ORIGINS environment variable.",
});
return;
}
Expand Down