{"record":{"id":"bd48c393225c8eda","repo":"FlowiseAI/Flowise","slug":"security-validation-failed-error-message-bd48c3","errorCode":null,"errorMessage":"Security validation failed: ${error.message}","messagePattern":"Security validation failed: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/MCP/Supergateway/SupergatewayMCP.ts","lineNumber":113,"sourceCode":"            .split(/\\s+/)\n            .map((arg) => {\n                // Remove surrounding double or single quotes if they exist\n                if ((arg.startsWith('\"') && arg.endsWith('\"')) || (arg.startsWith(\"'\") && arg.endsWith(\"'\"))) {\n                    return arg.slice(1, -1)\n                }\n                return arg\n            })\n\n        const serverParams = {\n            command: 'node',\n            args: [packagePath, ...processedArgs]\n        }\n\n        if (process.env.CUSTOM_MCP_SECURITY_CHECK !== 'false') {\n            try {\n                validateMCPServerConfig(serverParams)\n            } catch (error) {\n                throw new Error(`Security validation failed: ${error.message}`)\n            }\n        }\n\n        const toolkit = new MCPToolkit(serverParams, 'stdio')\n        await toolkit.initialize()\n\n        const tools = toolkit.tools ?? []\n\n        return tools as Tool[]\n    }\n}\n\nmodule.exports = { nodeClass: Supergateway_MCP }\n","sourceCodeStart":95,"sourceCodeEnd":127,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/MCP/Supergateway/SupergatewayMCP.ts#L95-L127","documentation":"Thrown by the Supergateway MCP node when its inner call to validateMCPServerConfig rejects the constructed serverParams. The node hardcodes command to 'node' and builds args from getNodeModulesPackagePath('supergateway/dist/index.js') plus the user-supplied _args string, then passes that object through the operator-controlled allow-list validator. The wrapper merely prefixes 'Security validation failed:' onto the underlying validator's message, so the real reason is in error.message after the colon.","triggerScenarios":"Supergateway_MCP.getTools runs with CUSTOM_MCP_SECURITY_CHECK !== 'false' (the default), and validateMCPServerConfig throws for any of: 'node' not in CUSTOM_MCP_ALLOWED_COMMANDS, an arg failing validateArgsForLocalFileAccess/validateCommandInjection/validateCommandFlags, env vars not in CUSTOM_MCP_ALLOWED_ENV_VARS, or a cwd field being set.","commonSituations":"Fresh deploy where the operator has not set CUSTOM_MCP_ALLOWED_COMMANDS=node yet; a user passing flags like --inspect or -e in the arguments string (caught by validateCommandFlags for node); quoting the supergateway path with shell metacharacters; setting CUSTOM_MCP_PROTOCOL=stdio without also allow-listing 'node'.","solutions":["Read the text after 'Security validation failed:' to identify which sub-validator rejected the config (command allow-list, arg injection, flag, env).","Add 'node' to CUSTOM_MCP_ALLOWED_COMMANDS in the worker env (e.g. CUSTOM_MCP_ALLOWED_COMMANDS=node) since the command is hardcoded to node.","Sanitize the node's _args input so it contains no shell metacharacters and no node-dangerous flags (-e, --eval, -r, --require, --loader, --inspect, --env-file, etc.).","To bypass entirely for a trusted operator-only deployment, set CUSTOM_MCP_SECURITY_CHECK=false (disables the check globally; only acceptable on isolated hosts)."],"exampleFix":"// before: operator env unset, node not allow-listed\n// .env (worker)\n// CUSTOM_MCP_ALLOWED_COMMANDS=\n\n// after\nCUSTOM_MCP_ALLOWED_COMMANDS=node\nCUSTOM_MCP_PROTOCOL=stdio","handlingStrategy":"try-catch","validationCode":"// Before calling the node, confirm operator env is configured for the hardcoded 'node' command.\nconst allowed = (process.env.CUSTOM_MCP_ALLOWED_COMMANDS ?? '').split(',').map(s => s.trim()).filter(Boolean)\nif (process.env.CUSTOM_MCP_SECURITY_CHECK !== 'false' && !allowed.includes('node')) {\n  throw new Error('Set CUSTOM_MCP_ALLOWED_COMMANDS=node before using the Supergateway MCP node')\n}","typeGuard":"const isServerParams = (v: unknown): v is { command: string; args: string[] } =>\n  typeof v === 'object' && v !== null && typeof (v as any).command === 'string' && Array.isArray((v as any).args)","tryCatchPattern":"try {\n  const tools = await supergatewayNode.getTools(nodeData, options)\n} catch (e) {\n  if (e.message.startsWith('Security validation failed:')) {\n    // surface the underlying validator reason, then fix env / args\n  }\n  throw e\n}","preventionTips":["Set CUSTOM_MCP_ALLOWED_COMMANDS=node in the worker env at deploy time.","Sanitize the node's _args input in the UI (reject shell metacharacters and node-dangerous flags).","Run validateMCPServerConfig in a pre-deploy smoke test against a sample config."],"tags":["mcp","security","configuration","supergateway"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}