feat(http): hardens rebinding defenses (#317)
This commit is contained in:
1 parent
fd28e3e7b3
commit
576bd312d7
10 files changed
+680
-7
No files matched your search
+10
-1
@@ -4,6 +4,7 @@ import config from '../config.js';
|
||||
import createMcpServer from '../server.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
import { ListToolsRequest, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { createDnsRebindingGuard } from './rebinding.js';
|
||||
|
||||
const yieldGenericServerError = (res: Response) => {
|
||||
res.status(500).json({
|
||||
@@ -62,7 +63,15 @@ const getTransport = async (request: Request): Promise<StreamableHTTPServerTrans
|
||||
const createApp = () => {
|
||||
const app = express();
|
||||
|
||||
app.use(express.json());
|
||||
app.use(
|
||||
'/mcp',
|
||||
createDnsRebindingGuard({
|
||||
allowedHosts: config.allowedHosts,
|
||||
allowedOrigins: config.allowedOrigins,
|
||||
})
|
||||
);
|
||||
|
||||
app.use('/mcp', express.json());
|
||||
|
||||
app.all('/mcp', async (req: Request, res: Response) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user