mcp-ssh-manager 3.8.4 → 3.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/README.md +18 -10
- package/cli/lib/menu.sh +2 -2
- package/docs/ALIASES_AND_HOOKS.md +54 -25
- package/docs/SECURITY_MODES.md +33 -3
- package/package.json +6 -3
- package/profiles/default.json +6 -4
- package/scripts/setup-hooks.sh +16 -7
- package/server.json +2 -2
- package/src/backup-manager.js +92 -62
- package/src/command-aliases.js +9 -6
- package/src/config-paths.js +12 -0
- package/src/database-manager.js +202 -40
- package/src/deploy-helper.js +15 -7
- package/src/health-monitor.js +20 -11
- package/src/hooks-system.js +298 -57
- package/src/index.js +59 -27
- package/src/logger.js +49 -17
- package/src/policy.js +46 -25
- package/src/profile-loader.js +18 -12
- package/src/server-aliases.js +9 -6
- package/src/shell-quote.js +54 -0
- package/src/shell-segments.js +189 -0
- package/src/ssh-key-manager.js +123 -76
- package/src/ssh-manager.js +17 -41
- package/src/user-state.js +60 -0
- package/.hooks-config.json +0 -131
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,102 @@ All notable changes to MCP SSH Manager will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.8.6] - 2026-10-08
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
|
|
12
|
+
Six advisories, five reported to us and one found while replacing our previous
|
|
13
|
+
tool with this one. **Upgrade.**
|
|
14
|
+
|
|
15
|
+
- **Command injection on the machine running mcp-ssh-manager, through the
|
|
16
|
+
default `on-error` hook** (GHSA-759m-wfpq-xmx3, high). The hook ran
|
|
17
|
+
`echo "… {error}" >> errors.log` through a shell, with the connection error
|
|
18
|
+
pasted inside double quotes. That text comes from the server: an SSH server
|
|
19
|
+
that disconnects with `$(…)` in its reason, before any key exchange, ran a
|
|
20
|
+
command on your machine. Hook values never become command text any more:
|
|
21
|
+
each `{placeholder}` becomes a reference to a shell variable holding the value
|
|
22
|
+
(`SSH_MANAGER_HOOK_SERVER`, …), and the default `on-error` hook is a `log`
|
|
23
|
+
action written without a shell, to `~/.ssh-manager/errors.log`.
|
|
24
|
+
- **`restricted` mode only checked how a line started** (GHSA-rfxw-26h6-7w42,
|
|
25
|
+
high, reported by @uozergit). The allow patterns were tested against the
|
|
26
|
+
whole line, so `^echo ` let `echo hi; id` through, and `^rm ` as a deny pattern
|
|
27
|
+
missed `echo x; rm -rf /data`. Every command in a list or pipeline must now
|
|
28
|
+
match, deny patterns apply to each, and command substitution and redirections
|
|
29
|
+
that write a file are refused. `readonly` also checks the commands inside
|
|
30
|
+
`$(…)` and backticks.
|
|
31
|
+
- **`cwd` reached the shell unquoted, past the security policy**
|
|
32
|
+
(GHSA-37fv-fcpc-j236, high, reported by @uozergit). `ssh_execute`,
|
|
33
|
+
`ssh_execute_group` and `ssh_execute_sudo` built `cd ${cwd} && …`; the
|
|
34
|
+
directory is now quoted, `~/` still expanding to the remote home.
|
|
35
|
+
- **`ssh_db_query` could write** (GHSA-9w6j-vg8f-hp8g, medium, reported by
|
|
36
|
+
@zaara2004; GHSA-q37w-vhpx-q5q9, high, reported by @davutselcuk). On MySQL,
|
|
37
|
+
`SELECT … INTO OUTFILE` wrote a file on the database server; on PostgreSQL,
|
|
38
|
+
`SELECT … INTO` created a table; on MongoDB, the collection and the query were
|
|
39
|
+
pasted into JavaScript, so `drop()` or `run()` ran on a tool documented as
|
|
40
|
+
read-only. SQL is now one `SELECT`, without `INTO` or the server-file
|
|
41
|
+
functions, run inside a read-only transaction — which also stops a stored
|
|
42
|
+
function that writes; a MySQL error no longer comes back as an empty result.
|
|
43
|
+
A MongoDB query must be a filter document (JSON or mongo shell syntax such as
|
|
44
|
+
`ObjectId("…")`), `$where`, `$function` and `$accumulator` are refused, and the
|
|
45
|
+
collection is passed as a string. Checked against MariaDB 11, PostgreSQL 16
|
|
46
|
+
and MongoDB 5.
|
|
47
|
+
- **Host keys were never compared** (GHSA-cwg3-pfmm-w8rm, high, reported by
|
|
48
|
+
Francesco Canovi (@TheDarkMist), Black Studio Solutions). The key a server presented was
|
|
49
|
+
accepted for known and unknown hosts alike. It is now compared with
|
|
50
|
+
`known_hosts` (hashed entries, `[host]:port`, wildcards and `@revoked`
|
|
51
|
+
included): an unknown host is trusted on first use and recorded, **a changed
|
|
52
|
+
key is refused** before any credential is sent.
|
|
53
|
+
- **`ssh_deploy` and `ssh_backup_schedule` still spliced values into commands**,
|
|
54
|
+
the class fixed in 3.8.5 (GHSA-qwwm-vrm9-4mw8) but missed here: the remote path
|
|
55
|
+
sat in double quotes, where `$(…)` runs; owner, permissions and the temporary
|
|
56
|
+
file name were bare; the scheduled script pasted the database and the paths.
|
|
57
|
+
And quoting the crontab line was not enough: cron runs whatever follows the
|
|
58
|
+
fifth field, so a schedule such as `* * * * * curl … | sh #` installed a job of
|
|
59
|
+
the caller's choosing. A schedule must now be five cron fields or an `@` macro.
|
|
60
|
+
|
|
61
|
+
Each fix carries a test that fails without it.
|
|
62
|
+
|
|
63
|
+
### Behaviour changes
|
|
64
|
+
|
|
65
|
+
- **A changed host key is refused.** A server reinstalled since its key was
|
|
66
|
+
recorded stops connecting until the old entry is removed
|
|
67
|
+
(`ssh-keygen -R <host>`) — this is what an interception looks like, so it is
|
|
68
|
+
the one change that cannot be opt-in. `SSH_MANAGER_KNOWN_HOSTS` points at a
|
|
69
|
+
separate file.
|
|
70
|
+
- **A `restricted` allowlist is now checked per command.** A pipe into a
|
|
71
|
+
command you never allowed, a `;` followed by another command, a `$(…)`, a `>`
|
|
72
|
+
into a file: each is refused, and the refusal names the command. Add a pattern
|
|
73
|
+
for each command you do want.
|
|
74
|
+
- **Hook settings, aliases, the active profile, the log and the command
|
|
75
|
+
history live in `~/.ssh-manager/`** (or `SSH_MANAGER_HOME`), readable by you
|
|
76
|
+
alone, instead of inside the installed package, where every upgrade lost them
|
|
77
|
+
and the log was readable by any local user
|
|
78
|
+
([#87](https://github.com/bvisible/mcp-ssh-manager/issues/87)). Nothing is
|
|
79
|
+
written on start; a log needs `~/.ssh-manager` to exist. An old file in the
|
|
80
|
+
package is still read until your next change writes the new one.
|
|
81
|
+
- **The package no longer ships a `.hooks-config.json`.** The one it carried
|
|
82
|
+
was a development copy that turned Frappe hooks on for every npm user: each
|
|
83
|
+
`ssh_deploy` ran `git status` and `npm test` in your working directory, and any
|
|
84
|
+
command containing `bench update` first ran a full `bench backup` on the
|
|
85
|
+
server. The hooks now come from your profile, as documented; the `frappe`
|
|
86
|
+
profile still has them.
|
|
87
|
+
|
|
88
|
+
## [3.8.5] - 2026-08-28
|
|
89
|
+
|
|
90
|
+
### Security
|
|
91
|
+
|
|
92
|
+
Three reported advisories, all the same class of bug, all confirmed present in 3.8.4 and fixed here. The v3.6.7 fix (CVE-2026-77383) introduced `shellQuote()` but applied it to `src/database-manager.js` only; the parallel builders for backups and monitoring were never covered.
|
|
93
|
+
|
|
94
|
+
- **RCE through every `ssh_backup_*` builder** (GHSA-qwwm-vrm9-4mw8, high). `src/backup-manager.js` concatenated `database`, `dbUser`, `dbPassword`, `dbHost`, `backupDir`, `paths` and `exclude` into shell strings with no escaping — 0 uses of `shellQuote` across 9 builders. Arbitrary command execution as the SSH user on every managed server.
|
|
95
|
+
- **RCE through `ssh_db_dump` and the MongoDB backup path** (GHSA-796j-h5q5-jx6p, critical). The follow-up `stat` command interpolated `outputFile` raw, after the dump itself had been fixed — the earlier patch stopped one line short.
|
|
96
|
+
- **RCE bypassing readonly/restricted mode** (GHSA-m793-whw6-f537, critical). `ssh_service_status` and `ssh_tail` are read-only, so they stay enabled on servers the operator locked down — and neither quoted its arguments nor consulted the policy layer. `buildServiceStatusCommand` interpolated the service name unquoted six times; `ssh_tail` built `tail -n ${lines} "${file}" | grep "${grep}"` with double quotes only, so a `"` breakout ran. **This defeated the exact control those modes exist to provide**, and the README had just started advertising them.
|
|
97
|
+
|
|
98
|
+
Fixes: `shellQuote()` extracted to `src/shell-quote.js` and applied across `backup-manager.js` (54 call sites), `health-monitor.js` and the remaining inline commands in `index.js`; a `safeInteger()` helper for numeric arguments that still land in command strings; `buildProcessInfoCommand` now validates its PID like `buildKillProcessCommand` always did; and `ssh_tail` and `ssh_service_status` now call the policy layer.
|
|
99
|
+
|
|
100
|
+
Guarded by `npm run test:backupinjection`: **340 builder × argument × payload combinations** driven through a real `/bin/sh` with a canary file, asserting no payload ever executes. Verified by mutation — removing any single quote-call is caught.
|
|
101
|
+
|
|
102
|
+
**Upgrade if you use `ssh_backup_*`, `ssh_db_dump`, `ssh_service_status` or `ssh_tail`, and especially if you rely on `readonly` or `restricted` mode.**
|
|
103
|
+
|
|
8
104
|
## [3.8.4] - 2026-08-28
|
|
9
105
|
|
|
10
106
|
### Security
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
8
8
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
9
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.6)
|
|
10
10
|
[](https://claude.ai/code)
|
|
11
11
|
[](https://openai.com/codex)
|
|
12
12
|
[](https://modelcontextprotocol.io)
|
|
@@ -23,16 +23,20 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
## 🎉 What's New in v3.8.
|
|
26
|
+
## 🎉 What's New in v3.8.6
|
|
27
27
|
|
|
28
|
-
**🔒
|
|
28
|
+
**🔒 Security release — six advisories fixed. Upgrade.** (Released: October 8, 2026)
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
30
|
+
- **🔴 Command injection on your own machine through the default `on-error` hook** (GHSA-759m-wfpq-xmx3) — the connection error, whose text a server chooses, was pasted into a shell command. Any SSH server you connected to could run a command on the machine running mcp-ssh-manager. Hook values now reach commands as shell variables, never as command text, and the default hook writes its log without a shell.
|
|
31
|
+
- **🔴 `restricted` mode only checked how a line started** (GHSA-rfxw-26h6-7w42) — `^echo ` let `echo hi; id` through. Every command in a list or pipeline must now match your allowlist; command substitution and writes to files are refused.
|
|
32
|
+
- **🔴 `cwd` reached the shell unquoted** (GHSA-37fv-fcpc-j236), past the security policy.
|
|
33
|
+
- **🔴 `ssh_db_query` could write** (GHSA-9w6j-vg8f-hp8g, GHSA-q37w-vhpx-q5q9) — `SELECT … INTO OUTFILE`, `SELECT … INTO` a new table, and JavaScript in MongoDB queries. Queries now run in a read-only transaction, and a MongoDB query must be a filter document.
|
|
34
|
+
- **🟠 Host keys were never compared** (GHSA-cwg3-pfmm-w8rm) — **a changed host key is now refused**, as OpenSSH does. A server reinstalled since its key was recorded needs `ssh-keygen -R <host>` once.
|
|
35
|
+
- `ssh_deploy` and `ssh_backup_schedule` quote every value, and a cron schedule must be a schedule.
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Hook settings, aliases, the active profile and the logs now live in `~/.ssh-manager/`, readable by you alone, instead of inside the installed package, where every upgrade lost them.
|
|
38
|
+
|
|
39
|
+
[Read full changelog →](CHANGELOG.md#386---2026-10-08) · Previous: [v3.8.5](CHANGELOG.md#385---2026-08-28), three command-injection advisories.
|
|
36
40
|
|
|
37
41
|
---
|
|
38
42
|
|
|
@@ -75,7 +79,11 @@ Alongside that:
|
|
|
75
79
|
## Previous Releases
|
|
76
80
|
|
|
77
81
|
<details>
|
|
78
|
-
<summary><b>📜 Release history — v3.8.
|
|
82
|
+
<summary><b>📜 Release history — v3.8.4 down to v1.0.0</b> (click to expand)</summary>
|
|
83
|
+
|
|
84
|
+
### v3.8.4 - Secrets stop reaching the log, CodeQL on every commit (August 28, 2026)
|
|
85
|
+
|
|
86
|
+
- **🔒 The logger no longer writes secrets in clear text** — it writes to `~/.ssh-manager.log` and stderr (which your MCP host captures), so one call site handing it a server config would have persisted a production password. Redaction now happens inside the logger. Also: CodeQL on every push, every action pinned by SHA, and a broken example that never parsed. [Full changelog →](CHANGELOG.md#384---2026-08-28)
|
|
79
87
|
|
|
80
88
|
### v3.8.2 / v3.8.3 - Sudo password leak fixed, MCP Registry, signed releases (August 28, 2026)
|
|
81
89
|
|
|
@@ -710,7 +718,7 @@ SSH Manager uses profiles to configure aliases and hooks for different project t
|
|
|
710
718
|
|
|
711
719
|
1. **Set active profile**:
|
|
712
720
|
- Environment variable: `export SSH_MANAGER_PROFILE=frappe`
|
|
713
|
-
- Configuration file:
|
|
721
|
+
- Configuration file: `~/.ssh-manager/profile` holds the profile name (switching from your assistant writes it)
|
|
714
722
|
- Default: Uses `default` profile if not specified
|
|
715
723
|
|
|
716
724
|
2. **Available profiles**:
|
package/cli/lib/menu.sh
CHANGED
|
@@ -273,7 +273,7 @@ wizard_edit_server() {
|
|
|
273
273
|
return 1
|
|
274
274
|
fi
|
|
275
275
|
|
|
276
|
-
local server_name="$
|
|
276
|
+
local server_name="$selected_server"
|
|
277
277
|
|
|
278
278
|
# Load existing configuration
|
|
279
279
|
local current_host=$(get_server_config "$server_name" "HOST")
|
|
@@ -586,4 +586,4 @@ wizard_create_tunnel() {
|
|
|
586
586
|
|
|
587
587
|
echo
|
|
588
588
|
read -p "Press Enter to continue..."
|
|
589
|
-
}
|
|
589
|
+
}
|
|
@@ -19,7 +19,8 @@ export SSH_MANAGER_PROFILE=frappe
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
2. **Configuration File**:
|
|
22
|
-
|
|
22
|
+
Write the name into `profile` in your settings directory (`~/.ssh-manager/`, or
|
|
23
|
+
`SSH_MANAGER_HOME`), which is what switching profiles from Claude Code does:
|
|
23
24
|
```
|
|
24
25
|
frappe
|
|
25
26
|
```
|
|
@@ -105,7 +106,7 @@ Hooks provide automated actions that run before, after, or on error during SSH o
|
|
|
105
106
|
Each profile defines relevant hooks:
|
|
106
107
|
|
|
107
108
|
#### Default Profile
|
|
108
|
-
- **on-error**: Logs errors to
|
|
109
|
+
- **on-error**: Logs errors to `errors.log` in your settings directory (see below)
|
|
109
110
|
|
|
110
111
|
#### Frappe Profile
|
|
111
112
|
- **pre-bench-update**: Creates backup, checks disk space
|
|
@@ -145,25 +146,53 @@ Each profile defines relevant hooks:
|
|
|
145
146
|
|
|
146
147
|
## Configuration Files
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
149
|
+
Everything you change at run time lives in your settings directory, beside your
|
|
150
|
+
`.env`: `~/.ssh-manager/`, or the directory named by `SSH_MANAGER_HOME`. Files
|
|
151
|
+
are created only when you change something, readable by you alone.
|
|
152
|
+
|
|
153
|
+
| What | File |
|
|
154
|
+
|---|---|
|
|
155
|
+
| Active profile | `profile` |
|
|
156
|
+
| Custom command aliases (override the profile's) | `command-aliases.json` |
|
|
157
|
+
| Custom hook definitions (override the profile's) | `hooks.json` |
|
|
158
|
+
| Server aliases | `server-aliases.json` |
|
|
159
|
+
| Logs written by `log` hook actions | `errors.log`, `deployments.log`, `ssh-key-changes.log` |
|
|
160
|
+
|
|
161
|
+
Up to 3.8.5 these were written inside the installed package (`.ssh-manager-profile`,
|
|
162
|
+
`.command-aliases.json`, `.hooks-config.json`, `.server-aliases.json`), so an
|
|
163
|
+
upgrade lost them, and the default `errors.log` landed in whatever directory the
|
|
164
|
+
server was started from. An old file there is still read until your next change
|
|
165
|
+
writes the new one.
|
|
166
|
+
|
|
167
|
+
Profile definitions stay in the package's `profiles/` directory.
|
|
168
|
+
|
|
169
|
+
## Writing Hook Actions
|
|
170
|
+
|
|
171
|
+
A hook action is one of:
|
|
172
|
+
|
|
173
|
+
- **`log`** — appends a timestamped line to a file, with no shell involved:
|
|
174
|
+
```json
|
|
175
|
+
{ "type": "log", "name": "log-error", "file": "errors.log", "message": "Error on {server}: {error}" }
|
|
176
|
+
```
|
|
177
|
+
A relative `file` lands in your settings directory, never in the working directory.
|
|
178
|
+
- **`command`** — a shell command run on this machine.
|
|
179
|
+
- **`remoteCommand`** — a shell command run on the server, for hooks fired with an
|
|
180
|
+
open connection (`pre-bench-update`, `post-bench-update`).
|
|
181
|
+
|
|
182
|
+
### How `{placeholders}` reach a command
|
|
183
|
+
|
|
184
|
+
A placeholder is **never pasted into the command text**. It becomes a reference to
|
|
185
|
+
a shell variable that holds the value — `{server}` becomes `"${SSH_MANAGER_HOOK_SERVER}"`,
|
|
186
|
+
`{backupId}` becomes `"${SSH_MANAGER_HOOK_BACKUP_ID}"` — quoted to fit where it sits.
|
|
187
|
+
A shell does not run what a variable expands to, so a value such as a connection
|
|
188
|
+
error chosen by a hostile server cannot become a command. Up to 3.8.5 values were
|
|
189
|
+
pasted in, and the default `on-error` hook ran such an error inside double quotes
|
|
190
|
+
([GHSA-759m-wfpq-xmx3](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-759m-wfpq-xmx3)).
|
|
191
|
+
|
|
192
|
+
You can also read the variables directly (`$SSH_MANAGER_HOOK_SERVER`). Do not hand
|
|
193
|
+
them to anything that evaluates text again — `eval`, `sh -c`, arithmetic — where a
|
|
194
|
+
value would become code once more. On Windows, local hooks run under `cmd.exe`,
|
|
195
|
+
where values are inserted with every character cmd treats specially removed.
|
|
167
196
|
|
|
168
197
|
## Environment Variables for Hooks
|
|
169
198
|
|
|
@@ -272,14 +301,14 @@ Example:
|
|
|
272
301
|
### Hooks not executing
|
|
273
302
|
- Check if hook is enabled: `"Show SSH hooks status"`
|
|
274
303
|
- Verify required environment variables are set
|
|
275
|
-
- Check
|
|
304
|
+
- Check `~/.ssh-manager/hooks.json` for proper configuration
|
|
276
305
|
|
|
277
306
|
### Command aliases not working
|
|
278
307
|
- List aliases to verify: `"List all command aliases"`
|
|
279
|
-
- Check
|
|
308
|
+
- Check `~/.ssh-manager/command-aliases.json` for syntax errors
|
|
280
309
|
- Ensure the base command is valid
|
|
281
310
|
|
|
282
311
|
### Deployment failures
|
|
283
|
-
- Check
|
|
284
|
-
- Review
|
|
312
|
+
- Check `~/.ssh-manager/deployments.log` for history
|
|
313
|
+
- Review `~/.ssh-manager/errors.log` for error details
|
|
285
314
|
- Verify disk space and permissions on target server
|
package/docs/SECURITY_MODES.md
CHANGED
|
@@ -24,7 +24,27 @@ attacks, layered between the MCP client and the SSH session.
|
|
|
24
24
|
|---|---|
|
|
25
25
|
| `unrestricted` (default) | No filter. Identical to pre-v3.5.0 behavior. Zero overhead — `evaluatePolicy()` early-returns. |
|
|
26
26
|
| `readonly` | Blocks mutating tools at the tool level (`ssh_upload`, `ssh_deploy`, `ssh_sync`, `ssh_execute_sudo`, `ssh_backup_create/restore/schedule`, `ssh_db_import/dump`, `ssh_key_manage` write actions, `ssh_alert_setup` set, `ssh_process_manager kill`). For `ssh_execute` / `ssh_execute_sudo` / `ssh_execute_group` / `ssh_session_send`, applies a built-in denylist (rm, mv, dd, mkfs, chmod, chown, sudo, systemctl restart/stop, docker rm/stop, pipe-to-sh, redirect outside `/tmp`, etc.). |
|
|
27
|
-
| `restricted` | All readonly blocks plus: every command must match at least one `ALLOW_PATTERNS` regex
|
|
27
|
+
| `restricted` | All readonly blocks plus: **every command on the line** must match at least one `ALLOW_PATTERNS` regex, and neither the line nor any command in it may match a `DENY_PATTERNS` regex. **DENY wins over ALLOW**. Command substitution and redirections that write a file are refused. With no `ALLOW_PATTERNS`, every command is refused (fail-closed). |
|
|
28
|
+
|
|
29
|
+
### How a command line is checked in `restricted` mode
|
|
30
|
+
|
|
31
|
+
The line is split into the commands it would run — at `;`, `&&`, `||`, `|`, `&`
|
|
32
|
+
and line breaks, outside quotes — and **each one** must match an allow pattern.
|
|
33
|
+
`^docker ps` therefore allows `docker ps -a`, but not `docker ps; id`, and
|
|
34
|
+
`docker ps | grep web` only if `grep` is allowed too. Up to 3.8.5 the patterns
|
|
35
|
+
were tested against the whole line, so an allowed start carried anything
|
|
36
|
+
appended to it ([GHSA-rfxw-26h6-7w42](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-rfxw-26h6-7w42)).
|
|
37
|
+
|
|
38
|
+
Also refused, because they run or change things the patterns never see:
|
|
39
|
+
|
|
40
|
+
- command substitution: `$(…)`, backticks, `<(…)`, `>(…)`, even inside double quotes;
|
|
41
|
+
- redirections that write a file: `>`, `>>`, `>|`, `&>`, `<>` — except to
|
|
42
|
+
`/dev/null`, `/dev/stdout`, `/dev/stderr` and descriptor copies such as `2>&1`;
|
|
43
|
+
- a line that cannot be read with confidence (an unterminated quote, for example).
|
|
44
|
+
|
|
45
|
+
Comments are not recognised: `ls # a; b` is checked as `ls # a` and ` b`, which
|
|
46
|
+
refuses it rather than missing a command. `readonly` mode also checks the commands
|
|
47
|
+
inside `$(…)` and backticks against its built-in list.
|
|
28
48
|
|
|
29
49
|
## Configuration
|
|
30
50
|
|
|
@@ -151,7 +171,8 @@ SSH_SERVER_CLIENT_PROD_AUDIT_LOG=~/.ssh-manager/audit/client-prod.jsonl
|
|
|
151
171
|
**Not gated** (pure reads or local-only state — no remote effect to block):
|
|
152
172
|
`ssh_list_servers`, `ssh_download`, `ssh_tail`, `ssh_monitor`, `ssh_history`,
|
|
153
173
|
`ssh_health_check`, `ssh_service_status`, `ssh_db_list`, `ssh_db_query`
|
|
154
|
-
(
|
|
174
|
+
(one SELECT run in a read-only transaction; for MongoDB a filter document,
|
|
175
|
+
never code), `ssh_backup_list`, `ssh_session_start`,
|
|
155
176
|
`ssh_session_list`, `ssh_session_close`, `ssh_connection_status`,
|
|
156
177
|
`ssh_tunnel_*`, `ssh_group_manage`, `ssh_command_alias`, `ssh_alias`,
|
|
157
178
|
`ssh_hooks`, `ssh_profile`.
|
|
@@ -164,7 +185,9 @@ SSH_SERVER_CLIENT_PROD_AUDIT_LOG=~/.ssh-manager/audit/client-prod.jsonl
|
|
|
164
185
|
- **Regex-based filtering can be bypassed** with creative command crafting
|
|
165
186
|
(encoded payloads, indirection via shell variables, etc.). Treat `readonly`
|
|
166
187
|
as protection against accidents and prompt injection of the common form,
|
|
167
|
-
not as an unbreakable shell escape.
|
|
188
|
+
not as an unbreakable shell escape. `restricted` is the stronger of the two:
|
|
189
|
+
every command must be one you allowed, so keep its patterns narrow — an
|
|
190
|
+
allowed interpreter (`^python`, `^bash`, `^sh`) allows everything.
|
|
168
191
|
- **Aliases are expanded before policy evaluation** — you can't bypass a DENY
|
|
169
192
|
by hiding `rm` behind an alias defined via `ssh_command_alias`.
|
|
170
193
|
- **No transport-level / per-client policies.** All clients see the same
|
|
@@ -187,3 +210,10 @@ A v3.4.x `.env` or TOML loads identically under v3.5.0:
|
|
|
187
210
|
so the client never sees a new prompt.
|
|
188
211
|
|
|
189
212
|
See `CHANGELOG.md` v3.5.0 for the full diff.
|
|
213
|
+
|
|
214
|
+
**One deliberate exception, in 3.8.6 and 4.0:** a `restricted` server now checks
|
|
215
|
+
every command on a line, so an existing allowlist refuses lines it used to let
|
|
216
|
+
through — a pipe into a command you never allowed, a `;` followed by another
|
|
217
|
+
command, a `$(…)`, a `>` into a file. That was the hole. Add a pattern for each
|
|
218
|
+
command you do want (`^grep `, `^head `), and the refusal names the command that
|
|
219
|
+
did not match. Servers without `MODE`, and `readonly` ones, are unaffected.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"mcpName": "io.github.bvisible/mcp-ssh-manager",
|
|
5
5
|
"description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
15
15
|
"configure": "python tools/server-manager.py",
|
|
16
16
|
"test-connection": "python tools/test-connection.py",
|
|
17
|
-
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:dbrowcount",
|
|
17
|
+
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:hostkeys && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:backupinjection && npm run test:dbrowcount && npm run test:cli-edit",
|
|
18
18
|
"test:lockfile": "node tests/test-lockfile.js",
|
|
19
19
|
"test:sudostdin": "node tests/test-sudo-stdin.js",
|
|
20
20
|
"test:redaction": "node tests/test-logger-redaction.js",
|
|
21
21
|
"test:profiles": "node tests/test-profiles.js",
|
|
22
22
|
"test:aliases": "node tests/test-command-aliases.js",
|
|
23
23
|
"test:hooks": "node tests/test-hooks.js",
|
|
24
|
+
"test:hostkeys": "node tests/test-host-key-verification.js",
|
|
24
25
|
"test:tools": "node tests/test-tool-registry.js",
|
|
25
26
|
"test:policy": "node tests/test-policy.js",
|
|
26
27
|
"test:ping": "node tests/test-ssh-ping.js",
|
|
@@ -34,7 +35,9 @@
|
|
|
34
35
|
"test:sync-path": "node tests/test-rsync-path.js",
|
|
35
36
|
"test:dbquoting": "node tests/test-database-query-quoting.js",
|
|
36
37
|
"test:dbinjection": "node tests/test-database-injection.js",
|
|
38
|
+
"test:backupinjection": "node tests/test-backup-monitor-injection.js",
|
|
37
39
|
"test:dbrowcount": "node tests/test-database-row-count.js",
|
|
40
|
+
"test:cli-edit": "node tests/test-cli-edit-server.js",
|
|
38
41
|
"test:all": "npm test && npm run typecheck && ./scripts/validate.sh",
|
|
39
42
|
"validate": "./scripts/validate.sh",
|
|
40
43
|
"typecheck": "tsc -p tsconfig.json",
|
|
@@ -92,7 +95,7 @@
|
|
|
92
95
|
"homepage": "https://github.com/bvisible/mcp-ssh-manager#readme",
|
|
93
96
|
"dependencies": {
|
|
94
97
|
"@iarna/toml": "^2.2.5",
|
|
95
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
98
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
96
99
|
"dotenv": "^16.4.5",
|
|
97
100
|
"ssh2": "^1.17.0",
|
|
98
101
|
"zod": "^4.4.3"
|
package/profiles/default.json
CHANGED
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"description": "Run after successful deployment",
|
|
32
32
|
"actions": [
|
|
33
33
|
{
|
|
34
|
-
"type": "
|
|
34
|
+
"type": "log",
|
|
35
35
|
"name": "log-deployment",
|
|
36
|
-
"
|
|
36
|
+
"file": "deployments.log",
|
|
37
|
+
"message": "Deployment completed to {server}"
|
|
37
38
|
}
|
|
38
39
|
]
|
|
39
40
|
},
|
|
@@ -42,9 +43,10 @@
|
|
|
42
43
|
"description": "Run when an error occurs",
|
|
43
44
|
"actions": [
|
|
44
45
|
{
|
|
45
|
-
"type": "
|
|
46
|
+
"type": "log",
|
|
46
47
|
"name": "log-error",
|
|
47
|
-
"
|
|
48
|
+
"file": "errors.log",
|
|
49
|
+
"message": "Error on {server}: {error}"
|
|
48
50
|
}
|
|
49
51
|
]
|
|
50
52
|
}
|
package/scripts/setup-hooks.sh
CHANGED
|
@@ -16,17 +16,23 @@ if ! command -v node &> /dev/null; then
|
|
|
16
16
|
exit 1
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# Versions are pinned on purpose. An unpinned install in a setup script hands
|
|
20
|
+
# every contributor whatever version is current that day, and the tools below
|
|
21
|
+
# gate commits — a silent major bump changes what passes.
|
|
20
22
|
echo "📦 Installing pre-commit..."
|
|
21
|
-
pip install pre-commit
|
|
23
|
+
pip install 'pre-commit==4.0.1'
|
|
22
24
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
# eslint and prettier are already devDependencies, at versions the CI gates
|
|
26
|
+
# depend on. `npm install --save-dev eslint prettier` would re-resolve both to
|
|
27
|
+
# their latest majors (ESLint 10 over the pinned ^8.56.0) and rewrite
|
|
28
|
+
# package.json in the contributor's working tree. npm ci installs exactly what
|
|
29
|
+
# package-lock.json pins.
|
|
30
|
+
echo "📦 Installing Node.js dev dependencies from the lockfile..."
|
|
31
|
+
npm ci
|
|
26
32
|
|
|
27
33
|
# Install Python linting tools
|
|
28
34
|
echo "📦 Installing Python linting tools..."
|
|
29
|
-
pip install black flake8 isort
|
|
35
|
+
pip install 'black==24.10.0' 'flake8==7.1.1' 'isort==5.13.2'
|
|
30
36
|
|
|
31
37
|
# Install pre-commit hooks
|
|
32
38
|
echo "🔗 Installing git hooks..."
|
|
@@ -34,7 +40,10 @@ pre-commit install
|
|
|
34
40
|
|
|
35
41
|
# Create secrets baseline
|
|
36
42
|
echo "🔐 Creating secrets baseline..."
|
|
37
|
-
|
|
43
|
+
# Pinned: an unpinned install in a setup script gives every developer whatever
|
|
44
|
+
# version is current that day, and this one writes the secrets baseline the
|
|
45
|
+
# pre-commit hooks then trust.
|
|
46
|
+
pip install 'detect-secrets==1.5.0'
|
|
38
47
|
detect-secrets scan > .secrets.baseline
|
|
39
48
|
|
|
40
49
|
# Run hooks on all files (optional first run)
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/bvisible/mcp-ssh-manager",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "3.8.
|
|
9
|
+
"version": "3.8.6",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "mcp-ssh-manager",
|
|
14
|
-
"version": "3.8.
|
|
14
|
+
"version": "3.8.6",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|