Summary
9Router contains a command injection issue where unvalidated MCP plugin arguments are passed into child_process.spawn(), allowing arbitrary command execution on the host.
When combined with a Host header bypass of localhost-only routes, an authenticated remote attacker can use the /api/mcp//sse endpoint to run malicious commands via custom plugins.
Affected context
This vulnerability appears in 9Router deployments that expose the MCP plugin routing functionality and rely on localhost-only routes for protection.
It is most relevant where:
- The application trusts the HTTP Host header for access control to internal routes
- MCP plugin arguments are forwarded directly to child_process.spawn() without strict validation
- Authenticated users can register or invoke custom MCP plugins via the /api/mcp//sse endpoint
Exploit preconditions
- Attack surface: HTTP interface exposing /api/mcp//sse and related MCP plugin endpoints
- Required access: Authenticated user with the ability to invoke or define MCP plugins
- Trigger point: Host header manipulation to reach localhost-only routes, followed by plugin invocation with crafted arguments
- Why exploitation is possible: The application uses the Host header for route protection and passes unvalidated plugin arguments into child_process.spawn(), enabling command injection within the host operating system context
Why this happens
The underlying bug is a classic command injection pattern (CWE-78) in which user-controlled values are used as arguments to process execution APIs without sufficient validation or restriction.
In this case, MCP plugin arguments are treated as trusted input and passed directly to child_process.spawn(), allowing an attacker to influence the commands or parameters executed on the host.
The trust in the HTTP Host header for segregating localhost-only routes further expands the reachable attack surface, letting remote authenticated users access internal endpoints intended to be shielded from external traffic.
Potential impact
- Remote execution of arbitrary system commands on the host operating system
- Full compromise of the 9Router runtime environment and associated credentials
- Lateral movement to other services or data stores reachable from the host
- Tampering with AI routing behavior and token usage patterns
- Exfiltration or destruction of sensitive data accessible from the compromised host
General mitigation guidance
Mitigation should focus on reducing trust in user-controlled inputs and hardening process execution boundaries.
Recommended patterns include:
- Decouple route protection from the HTTP Host header and rely on server-side checks, explicit binding, or authentication/authorization controls
- Avoid passing raw user or plugin inputs into child_process.spawn() or similar APIs; restrict execution to predefined commands with fixed argument sets
- Apply strict validation and sanitization to any parameters that must reach process execution APIs, using allowlists and structured types
- Run components that execute commands with least privilege, using dedicated service accounts and constrained OS-level permissions
- Segment internal management or plugin endpoints from general user traffic to limit exposure of sensitive routes
How teams detect issues like this
Detection can leverage a combination of code-level and operational signals:
- Static analysis rules that flag direct use of child_process.spawn(), exec, or similar APIs with tainted arguments derived from HTTP requests or plugin configuration
- Code review checklists emphasizing validation and allowlist enforcement around process execution and plugin systems
- Application-level logging of MCP plugin invocations and command execution paths to spot anomalous arguments or unexpected command patterns
- Runtime monitoring and host-based intrusion detection tuned to detect suspicious process trees, unusual binaries, or shell invocations originating from the 9Router service
- CI/CD pipeline policies that automatically highlight new usage of process execution APIs or changes to access control based on HTTP headers

