Summary
Godot MCP contained an OS command injection vulnerability where user-controlled parameters such as projectPath were passed directly into exec() for shell execution.
An attacker able to invoke tools that accept projectPath (for example create_scene, add_node, or load_sprite) could inject shell metacharacters and execute arbitrary system commands with the privileges of the MCP server process.
Affected context
This vulnerability appears in deployments using the Godot MCP server where:
- Client tools can invoke operations that accept a
projectPathor similar path argument - The server constructs shell commands incorporating this input and executes them with
exec()or a comparable shell-spawning API - The MCP process runs with sufficient privileges to impact the underlying system or game development environment
The issue is most relevant when Godot MCP is exposed to untrusted clients, shared environments, or integrated into workflows where users are not fully trusted.
Exploit preconditions
- Attack surface: Network-accessible or IPC-exposed Godot MCP server handling MCP tool requests
- Required access: Ability to call affected tools (e.g.,
create_scene,add_node,load_sprite) and supply theprojectPathparameter or any similarly handled parameter - Trigger point: Invocation of
executeOperation(or equivalent dispatcher) that builds a shell command string containing user-controlled input and passes it toexec() - Why exploitation is possible: The implementation concatenates untrusted input directly into a shell command without proper quoting, escaping, or avoiding the shell, allowing injection of metacharacters such as
&,;, or$()that the shell interprets as separate commands
Why this happens
The underlying bug is a classic OS command injection issue, mapped to CWE-78.
The executeOperation function used string interpolation or concatenation to embed user-controlled data (such as projectPath) into a command passed to exec(), which in turn spawns a shell.
Because the shell parses special characters and constructs, any lack of strict validation, proper escaping, or shell-free execution transforms benign parameters into an opportunity to append or replace commands.
This pattern is inherently unsafe: treating input data as part of an executable command line rather than as a purely data parameter passed to a non-shell API.
Potential impact
- Execution of arbitrary system commands under the MCP server's account
- Reading, modifying, or deleting files accessible to the MCP process (including game project assets and scripts)
- Dropping backdoors or additional tooling onto the host system
- Pivoting to other services or resources reachable from the MCP host
- Interference with development workflows, including sabotage of project content or CI integrations
- Potential data exfiltration of proprietary assets, source code, or credentials stored on the system
General mitigation guidance
Effective mitigation focuses on removing the shell from the execution path and strictly treating user input as data:
- Prefer APIs that execute binaries directly without invoking a shell (e.g.,
execFile,spawnwith argument arrays, or equivalent process APIs in the chosen language/runtime) - Avoid constructing command strings via concatenation or interpolation; instead pass user-supplied values as separate arguments in structured arrays
- Restrict the set of allowed operations on file-system paths to a well-defined subset, such as project directories, and normalize paths before use
- Enforce strict validation on path-like inputs, including:
- Rejecting shell metacharacters, newlines, and other control characters
- Rejecting absolute paths or
..segments if the operation should be scoped to a project root - Run the MCP server with least-privilege OS accounts and minimized filesystem permissions
- Implement defense-in-depth controls such as OS-level sandboxing or containerization to limit the blast radius if a command path is compromised
How teams detect issues like this
Detection generally combines code-centric review with runtime monitoring:
- Static analysis and code scanning:
- Flag uses of
exec,system, or equivalent shell-spawning APIs where parameters include untrusted input - Identify string concatenation or template literals that build shell commands with user-controlled fields (e.g.,
projectPath) - Enforce linting rules that disallow generic command execution APIs except in vetted, reviewed locations
- Code review practices:
- Treat any call that executes OS commands as a security-sensitive sink requiring explicit review
- Verify that all path and command parameters are either constants, from trusted configuration, or passed as structured arguments with proper validation
- Runtime and operational monitoring:
- Monitor process creation events originating from the MCP server user or container, alerting on unusual commands
- Use host-based intrusion detection to spot suspicious shells or tool invocations spawned by MCP
- Automated code review tools and SAST platforms can be configured with rules specific to command injection patterns in the language/runtime used by Godot MCP.

