Tencent/WeKnora · error
command path contains invalid characters
Error message
command path contains invalid characters
What it means
After passing the whitelist, ValidateStdioCommand performs a final check that the raw command string contains no ".." path-traversal segments. This blocks tricks where a whitelisted base name is embedded in a traversal path. The error text is generic ("invalid characters") but specifically means ".." was found.
Source
Thrown at internal/utils/security.go:552
if command == "" {
return fmt.Errorf("command cannot be empty")
}
// Normalize command (extract base name if it's a path)
baseCommand := command
if strings.Contains(command, "/") {
parts := strings.Split(command, "/")
baseCommand = parts[len(parts)-1]
}
// Check against whitelist
if !AllowedStdioCommands[baseCommand] {
return fmt.Errorf("command '%s' is not in the allowed list. Allowed commands: uvx, npx, node, python, python3, deno, bun", baseCommand)
}
// Additional check: command should not contain path traversal
if strings.Contains(command, "..") {
return fmt.Errorf("command path contains invalid characters")
}
return nil
}
// ValidateStdioArgs validates the arguments for MCP stdio transport
// Returns an error if any argument contains dangerous patterns
func ValidateStdioArgs(args []string) error {
if len(args) == 0 {
return nil
}
for i, arg := range args {
// Check length
if len(arg) > 1024 {
return fmt.Errorf("argument %d exceeds maximum length (1024 characters)", i)
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Remove ".." from the command path; use an absolute path whose base name is whitelisted (e.g. /usr/bin/node) or just the bare command name and rely on PATH
- Use path.Clean/filepath.Clean to normalize the path and confirm no ".." remains
- Prefer launching via the bare command name ("node") so the OS PATH resolution is used
Example fix
// before
{"command": "../bin/node", "args": ["server.js"]}
// after
{"command": "node", "args": ["server.js"]} Defensive patterns
Strategy: validation
Validate before calling
if strings.Contains(cfg.Command, "..") {
return fmt.Errorf("command path must not contain '..'")
}
err := ValidateStdioConfig(cfg) Try / catch
if err := ValidateStdioConfig(cfg); err != nil {
if strings.Contains(err.Error(), "invalid characters") {
return fmt.Errorf("command %q contains traversal segments; use bare name or absolute path", cfg.Command)
}
return err
} Prevention
- Use bare command names and PATH resolution instead of relative paths
- Normalize any path with filepath.Clean before validation
- Reject '..' in all executable paths at config-parse time
When it happens
Trigger: ValidateStdioConfig called with a command such as "../node", "npx/../node", or any string containing ".." whose base name still matches the whitelist.
Common situations: Relative paths written from a config directory; hand-built command strings joining directories with ".."; copy-pasted paths from shell history with dot-dot segments.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- command '%s' is not in the allowed list. Allowed commands: u
- argument %d contains potentially dangerous pattern: %s
- argument %d contains null bytes
- environment variable '%s' is not allowed for security reason
- path %q is outside this install's skill directory (%s); an i
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/9cb4cc3d14e9ddaf.
Report an issue: GitHub.