Summary
A critical OS command injection vulnerability in Neo.mjs allows caller-controlled absolutePath values to be inserted into shell commands by the FileSystemService.mjs component.
If an AI agent can be induced to invoke the affected MCP tools, an attacker may execute arbitrary operating-system commands with the privileges of the MCP server process.
Affected context
The vulnerability occurs in the ai/mcp/server/file-system MCP server, specifically in the checkSyntax() and runPlaywrightTest() functions. It becomes risky when an AI agent is available to invoke these tools and attacker-influenced absolutePath values can reach the command construction logic without effective validation or safe argument handling.
Exploit preconditions
- Attack surface: File-system MCP server tools exposed to an AI agent or connected client
- Required access: Ability to influence tool arguments or induce an agent to submit attacker-controlled path values
- Trigger point: Invocation of checkSyntax() or runPlaywrightTest()
- Why exploitation is possible: Caller-controlled absolutePath values are unsafely interpolated into shell commands, allowing command syntax to be interpreted by the operating system
Why this happens
The underlying bug is command construction from untrusted input. The affected functions interpolate a caller-controlled path into a shell command rather than treating it strictly as data or passing it through a safe argument interface.
This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection. Shell metacharacters or other command syntax contained in the input may alter the intended command behavior.
Potential impact
- An attacker may execute arbitrary OS commands in the MCP server environment.
- The process may access files, services, or credentials available to its runtime identity.
- The vulnerability could enable data theft, tampering, or destructive activity.
- A compromised server could facilitate lateral movement or broader system compromise.
- AI-agent workflows and connected developer environments may be affected.
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from file-processing workflows and reducing trust in agent-supplied arguments.
Common defensive patterns include:
- Using APIs that execute programs directly with structured argument arrays instead of invoking a shell.
- Treating tool parameters as untrusted data and applying strict path validation, canonicalization, and allowlisting.
- Restricting file operations to approved directories and rejecting unexpected path forms.
- Separating syntax checking and test execution from highly privileged environments.
- Running MCP services with least-privilege identities, restricted filesystem access, and minimal network permissions.
- Applying explicit authorization and confirmation controls to tools capable of executing commands.
- Avoiding reliance on escaping alone when a shell-free execution alternative is available.
How teams detect issues like this
Detection approaches commonly include:
- Static analysis rules for string interpolation or concatenation used to build shell commands.
- Code review checks for subprocess, shell, exec, or spawn APIs receiving tool parameters.
- Testing with metacharacters and boundary values to verify that inputs remain data rather than executable syntax.
- Policy enforcement requiring shell-free process execution and approved path allowlists for MCP tools.
- Runtime monitoring for unexpected child processes, command-line patterns, file access, or network activity from the MCP server.
Automated security review tools can help identify command construction paths, but findings should be validated against actual agent-to-tool data flows.

