Severity:

HIGH RISK

(7.8)

OS Command Injection in ssh-mcp

CVE-2026-7039

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-74, CWE-77

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection vulnerability in tufantunc ssh-mcp up to version 1.5.0 allows crafted input passed to the shell.write function to be interpreted as part of a system command.

When a local attacker can influence the Description argument, they may execute arbitrary commands with the privileges of the ssh-mcp process.

Affected context

This vulnerability affects environments where ssh-mcp (up to 1.5.0) is installed and used to interact with a shell via the shell.write function in src/index.ts.

The issue arises when user-controllable data, specifically the Description argument, is incorporated into shell commands without proper sanitization or escaping.

It primarily impacts local workflows, scripts, or tools that expose shell.write to untrusted or semi-trusted input.

Exploit preconditions

  • Attack surface: Local system where ssh-mcp is installed and executed.
  • Required access: Ability to run ssh-mcp or to pass data into the Description argument that is ultimately used by shell.write.
  • Trigger point: Invocation of shell.write with unvalidated Description content that becomes part of a shell command or shell-interpreted string.
  • Why exploitation is possible: The application constructs or forwards shell commands using unsanitized input, allowing shell metacharacters and operators to alter command boundaries and inject additional commands.

Why this happens

The underlying issue maps to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') and CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.

In ssh-mcp, the shell.write function appears to directly interpolate or forward the Description argument into a shell execution context without carefully filtering, escaping, or separating data from executable command syntax.

This pattern treats user-controllable strings as part of the command line, enabling shell control characters (such as pipes, redirections, or command separators) to be interpreted as executable instructions instead of inert data.

Potential impact

  • Execution of arbitrary OS commands with the privileges of the ssh-mcp process
  • Reading or modification of local files accessible to the affected user account
  • Installation or execution of additional malicious software or scripts
  • Local privilege escalation when combined with other misconfigurations or vulnerabilities
  • Tampering with local development, build, or deployment workflows that rely on ssh-mcp

General mitigation guidance

Effective mitigation focuses on eliminating direct command construction from untrusted data and constraining interactions with the shell:

  • Use parameterized or API-based execution (e.g., spawn commands with argument arrays instead of concatenated strings) to clearly separate data from command syntax.
  • Apply strict input validation and allowlist-based filtering on the Description argument, rejecting or encoding shell metacharacters rather than attempting ad-hoc sanitization.
  • Prefer higher-level abstractions over raw shell invocation, such as language-native libraries for file and process operations instead of shelling out.
  • Run ssh-mcp with the least privileges required (non-root user, limited filesystem and environment access) to minimize damage if command injection occurs.
  • Introduce defensive coding guidelines and code review checklists that flag any string concatenation used in command execution paths.

How teams detect issues like this

Identifying this class of issue typically combines static analysis, code review, and behavioral monitoring:

  • Configure static analysis tools to detect command execution functions that receive concatenated or string-interpolated arguments containing user input (e.g., use of exec, spawn, backticks, or shell wrappers).
  • During code review, look for patterns where shell commands are assembled using template literals, string concatenation, or unescaped variables, especially around shell.write and similar abstractions.
  • Implement secure coding policies that require argument-array APIs for process execution and forbid passing entire command lines as unstructured strings when user input is involved.
  • Use runtime monitoring or audit logs to flag unusual command lines spawned by ssh-mcp, such as unexpected operators, chained commands, or access to sensitive paths.

Sources

SourceLink
github.comgithub.com/tufantunc/ssh-mcp/
github.comgithub.com/tufantunc/ssh-mcp/issues/44
vuldb.comvuldb.com/submit/798528
vuldb.comvuldb.com/vuln/359619
vuldb.comvuldb.com/vuln/359619/cti

Frequently asked

questions

The vulnerability is described as requiring a local attack. Exploitation generally assumes the attacker can run ssh-mcp or otherwise supply data that flows into the Description argument used by shell.write. Remote exploitability would only arise if another component exposes this input surface over a network.

An attacker typically needs local access to the system where ssh-mcp runs, along with the ability to control or influence the Description value. This could be via direct CLI usage, scripts, or any application logic wrapping ssh-mcp that passes through user input.

Refactor command execution so that user-supplied data is never embedded directly into shell command strings. Use APIs that accept command and arguments separately, enforce strict validation or allowlists on all user-controlled inputs, and remove any unnecessary shell interpretation layers.

Adopt a defensive development approach where any interface to the shell is treated as high risk: mandate use of argument-array process APIs, integrate automated checks for string-based command construction, and include command-injection reviews in pull request templates and security testing pipelines.

Find out what's already
exploitable in your codebase.