ssh-mcp 2.0.3 → 2.0.4

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.
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Anything through which the shell can start a second command.
3
+ *
4
+ * This gate decides whether an allowlisted binary counts as read-only, and the
5
+ * allowlist only vouches for the binary — never for what a shell might run
6
+ * beside it. It used to test /[>;|]/, which let `ls $(touch /tmp/x)` through as
7
+ * read-only: `ls` is allowlisted, no listed metacharacter appears, and the
8
+ * remote shell expands the substitution and runs the inner command anyway
9
+ * (GHSA-r8hm-vpm8-cfh6).
10
+ *
11
+ * Listing every dangerous construct is a losing game — `$()`, backticks,
12
+ * `<(...)`, `${x:=...}`, `&&`, a bare newline — so this refuses every character
13
+ * with syntactic meaning to the shell instead, and `$` wholesale rather than
14
+ * just `$(`. The cost is that `echo $HOME` is no longer classified read-only.
15
+ * That is the right trade for the tool whose entire promise is that it cannot
16
+ * write: run-command still accepts it under policy.
17
+ */
18
+ const SHELL_CONTROL_CHARS = /[;&|<>`$(){}\n\r]/;
1
19
  const READ_ONLY_ALLOWLIST = new Set([
2
20
  'ls', 'cat', 'grep', 'find', 'stat', 'df', 'du', 'head', 'tail', 'wc',
3
21
  'ps', 'uname', 'uptime', 'hostname', 'id', 'who', 'whoami', 'date',
@@ -98,7 +116,7 @@ export function classifyCommand(command) {
98
116
  }
99
117
  const twoWordPrefix = fullCommand.split(/\s+/).slice(0, 2).join(' ');
100
118
  if (READ_ONLY_ALLOWLIST.has(binary) || READ_ONLY_ALLOWLIST.has(twoWordPrefix)) {
101
- if (/[>;|]/.test(trimmed)) {
119
+ if (SHELL_CONTROL_CHARS.test(trimmed)) {
102
120
  return { binary, fullCommand, class: 'safe' };
103
121
  }
104
122
  return { binary, fullCommand, class: 'read-only' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-mcp",
3
3
  "license": "MIT",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "description": "MCP server exposing policy-gated, audited SSH access for Linux and Windows hosts via the Model Context Protocol.",
6
6
  "type": "module",
7
7
  "bin": {