{"record":{"id":"3782902cfb34894d","repo":"Tencent/WeKnora","slug":"command-s-is-not-in-the-allowed-list-allowed-c","errorCode":null,"errorMessage":"command '%s' is not in the allowed list. Allowed commands: uvx, npx, node, python, python3, deno, bun","messagePattern":"command '(.+?)' is not in the allowed list\\. Allowed commands: uvx, npx, node, python, python3, deno, bun","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/utils/security.go","lineNumber":547,"sourceCode":"}\n\n// ValidateStdioCommand validates the command for MCP stdio transport\n// Returns an error if the command is not in the whitelist or contains dangerous patterns\nfunc ValidateStdioCommand(command string) error {\n\tif command == \"\" {\n\t\treturn fmt.Errorf(\"command cannot be empty\")\n\t}\n\n\t// Normalize command (extract base name if it's a path)\n\tbaseCommand := command\n\tif strings.Contains(command, \"/\") {\n\t\tparts := strings.Split(command, \"/\")\n\t\tbaseCommand = parts[len(parts)-1]\n\t}\n\n\t// Check against whitelist\n\tif !AllowedStdioCommands[baseCommand] {\n\t\treturn fmt.Errorf(\"command '%s' is not in the allowed list. Allowed commands: uvx, npx, node, python, python3, deno, bun\", baseCommand)\n\t}\n\n\t// Additional check: command should not contain path traversal\n\tif strings.Contains(command, \"..\") {\n\t\treturn fmt.Errorf(\"command path contains invalid characters\")\n\t}\n\n\treturn nil\n}\n\n// ValidateStdioArgs validates the arguments for MCP stdio transport\n// Returns an error if any argument contains dangerous patterns\nfunc ValidateStdioArgs(args []string) error {\n\tif len(args) == 0 {\n\t\treturn nil\n\t}\n\n\tfor i, arg := range args {","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/utils/security.go#L529-L565","documentation":"ValidateStdioCommand enforces a whitelist of executables allowed for MCP stdio transport: uvx, npx, node, python, python3, deno, bun. Any command whose base name (after stripping path segments) is not in AllowedStdioCommands is rejected with the full allowed list in the message.","triggerScenarios":"ValidateStdioConfig called with a command like \"bash\", \"sh\", \"/usr/bin/curl\", \"npm\", \"docker\", or any executable not in the whitelist — even if the full path version of an allowed tool is used, only the base name is checked against the map.","commonSituations":"MCP server configs copied from tutorials that use arbitrary commands (\"python3.11\", \"/opt/venv/bin/python\", \"./server.sh\"); Windows-style paths; custom interpreters like pipx or poetry run; typos such as \"npxx\".","solutions":["Switch the command to a whitelisted launcher: use \"npx\" instead of \"npm exec\", \"uvx\" instead of \"pipx run\", \"python\" instead of a venv path","If a full path is required, keep the base name whitelisted, e.g. \"/usr/local/bin/node\" resolves to base \"node\" and passes","Wrap the server launch in an allowed launcher's -e/-c invocation (e.g. node -e, python -c) only if security policy permits","Extend AllowedStdioCommands in internal/utils/security.go if your organization genuinely needs another command (review security implications first)"],"exampleFix":"// before\n{\"command\": \"/opt/venv/bin/python3.11\", \"args\": [\"server.py\"]}\n// after\n{\"command\": \"python3\", \"args\": [\"server.py\"]}","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"uvx\":true,\"npx\":true,\"node\":true,\"python\":true,\"python3\":true,\"deno\":true,\"bun\":true}\nbase := filepath.Base(cfg.Command)\nif !allowed[base] {\n    return fmt.Errorf(\"command %q not allowed; use one of uvx, npx, node, python, python3, deno, bun\", base)\n}","typeGuard":null,"tryCatchPattern":"if err := ValidateStdioConfig(cfg); err != nil {\n    if strings.Contains(err.Error(), \"is not in the allowed list\") {\n        return fmt.Errorf(\"unsupported stdio command %q; pick a whitelisted launcher\", cfg.Command)\n    }\n    return err\n}","preventionTips":["Restrict MCP server configs to known launcher commands (uvx/npx) that fetch the actual server","Never run arbitrary executables through stdio transport","Keep a documented list of allowed commands for your team"],"tags":["security","whitelist","mcp","stdio","config"],"backgroundTag":"command-not-allowed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}