Summary
mcp-ssh-manager backup tools build remote shell commands using caller-controlled arguments without neutralizing shell metacharacters. If a malicious or compromised MCP client supplies crafted values, commands may execute on managed servers as the configured SSH user; scheduled backups may also create persistent execution.
Affected context
The issue affects backup operations in mcp-ssh-manager, including create, restore, schedule, and list handlers. It becomes risky when caller-controlled values are incorporated into remote shell commands without effective neutralization. The list handler also lacks the server policy check used by other operations, so it may remain available in readonly or restricted modes.
Exploit preconditions
- Attack surface: MCP backup tools that construct commands for remote execution over SSH
- Required access: Ability to supply arguments through an MCP client; the attacker may be a malicious or compromised client, or may influence a client through indirect prompt injection
- Trigger point: A backup tool processes caller-controlled values such as database, connection, directory, path, exclusion, schedule, or comment arguments
- Why exploitation is possible: Values are incorporated into shell commands without adequate shell metacharacter neutralization
- Scope and privilege: Commands run on the managed remote server with the configured SSH user's permissions; scheduling may allow execution to persist through cron
Why this happens
Backup command builders incorporate caller-controlled values into shell command strings without safely separating data from command syntax. Shell metacharacters can therefore alter the meaning of the generated command when it is executed remotely. This is CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection. A prior fix in a separate database helper did not cover these parallel backup command builders.
Potential impact
- Arbitrary commands may execute on a managed remote server as the configured SSH user.
- Attackers may access or modify files and data available to that account.
- Scheduled tasks may enable persistent command execution through cron.
- The list operation may permit command execution even in readonly or restricted modes.
- Compromised servers may be used to affect other systems accessible to the SSH account.
General mitigation guidance
Common defensive patterns focus on avoiding shell interpretation and consistently enforcing authorization:
- Prefer APIs that pass commands and arguments directly to the process, without invoking a shell.
- Where shell use cannot be avoided, use well-tested argument-escaping mechanisms and strict allowlists for values such as paths, identifiers, and schedule fields.
- Treat every tool argument as untrusted, including values supplied through trusted-looking workflows or natural-language interactions.
- Apply server-side policy and authorization checks uniformly to every backup operation, including list operations and restricted modes.
- Run remote operations with least-privilege SSH accounts and limit their access to required files and commands.
- Keep scheduled jobs constrained, reviewable, and removable through controlled mechanisms.
How teams detect issues like this
- Use static analysis to identify shell execution APIs and command strings assembled with user-controlled values.
- Review all backup handlers for consistent argument handling and policy checks, including inline handlers and parallel command builders.
- Add tests that verify special characters are treated as data and that restricted modes enforce policy across every tool.
- Use policy enforcement to prohibit shell execution where direct process APIs are available and to require authorization checks for remote operations.
- Review audit trails and remote host logs for unexpected commands or changes to scheduled tasks.

