mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Feat/Enhance security validation for MCP configurations (#5232)
feat: enhance security validation for MCP configurations - Added environment variable checks for CUSTOM_MCP_SECURITY_CHECK, CUSTOM_MCP_PROTOCOL, and HTTP_DENY_LIST across various Docker and application files. - Implemented validation functions in MCP core to prevent command injection and ensure safe environment variable usage
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Tool } from '@langchain/core/tools'
|
||||
import { ICommonObject, IDatabaseEntity, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../../src/Interface'
|
||||
import { MCPToolkit } from '../core'
|
||||
import { MCPToolkit, validateMCPServerConfig } from '../core'
|
||||
import { getVars, prepareSandboxVars } from '../../../../src/utils'
|
||||
import { DataSource } from 'typeorm'
|
||||
import hash from 'object-hash'
|
||||
@@ -75,8 +75,8 @@ class Custom_MCP implements INode {
|
||||
},
|
||||
placeholder: mcpServerConfig,
|
||||
warning:
|
||||
process.env.CUSTOM_MCP_SECURITY_CHECK === 'true'
|
||||
? 'In next release, only Remote MCP with url is supported. Read more <a href="https://docs.flowiseai.com/tutorials/tools-and-mcp#streamable-http-recommended" target="_blank">here</a>'
|
||||
process.env.CUSTOM_MCP_PROTOCOL === 'sse'
|
||||
? 'Only Remote MCP with url is supported. Read more <a href="https://docs.flowiseai.com/tutorials/tools-and-mcp#streamable-http-recommended" target="_blank">here</a>'
|
||||
: undefined
|
||||
},
|
||||
{
|
||||
@@ -174,6 +174,14 @@ class Custom_MCP implements INode {
|
||||
serverParams = JSON.parse(serverParamsString)
|
||||
}
|
||||
|
||||
if (process.env.CUSTOM_MCP_SECURITY_CHECK !== 'false') {
|
||||
try {
|
||||
validateMCPServerConfig(serverParams)
|
||||
} catch (error) {
|
||||
throw new Error(`Security validation failed: ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Compatible with stdio and SSE
|
||||
let toolkit: MCPToolkit
|
||||
if (process.env.CUSTOM_MCP_PROTOCOL === 'sse') {
|
||||
|
||||
Reference in New Issue
Block a user