/

CVE-2025-61492

Severity:

CRITICAL RISK

(10.0)

Command Injection in terminal-controller-mcp

CVE-2025-61492

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-77

Impact:

Remote Code Execution / Full System Compromise

Severity:

CRITICAL RISK

(10.0)

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 terminal-controller-mcp 0.1.7 allows untrusted input to be passed directly into the execute_command function, enabling arbitrary command execution on the host system.

When user-supplied or otherwise untrusted data is concatenated or interpolated into shell commands without proper validation or escaping, an attacker can craft input that breaks out of the intended command and runs additional system commands.

Affected context

This vulnerability affects environments where terminal-controller-mcp 0.1.7 is used to run system commands on behalf of users or upstream services.

It is most relevant when:

  • The execute_command function receives input derived from users, external APIs, or other untrusted sources.
  • The application executes shell commands with that input, especially via shell-based helpers (e.g., /bin/sh, command strings).
  • The process runs with elevated permissions or access to sensitive files, configuration, or network resources.

Exploit preconditions

  • Attack surface: Any interface (CLI, HTTP, IPC, plugin interface, MCP endpoint) that ultimately passes attacker-controlled data into execute_command.
  • Required access: Ability to supply or influence the command string or its parameters (e.g., as a user of the tool, client application, or integrated service).
  • Trigger point: Invocation of execute_command with a crafted payload that injects shell metacharacters or additional commands.
  • Why exploitation is possible: The implementation likely constructs a shell command string directly from input without strict validation, escaping, or use of safe, argument-based process execution APIs, allowing the shell to interpret injected tokens as separate commands.

Why this happens

The core issue aligns with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').

The execute_command function appears to:

  • Treat untrusted input as part of a shell command string.
  • Rely on the shell to parse the final string, making it sensitive to metacharacters such as ;, &&, |, backticks, or $() substitution.

Instead of passing user input as separate, typed parameters to a process execution API, the code likely concatenates or interpolates raw strings, allowing the shell to interpret attacker-controlled content as command separators, arguments, or redirections.

This pattern is inherently unsafe whenever any part of the command originates from untrusted or weakly validated sources.

Potential impact

  • Execution of arbitrary system commands with the privileges of the terminal-controller-mcp process.
  • Reading, modifying, or deleting local files accessible to the process.
  • Stealing secrets such as API keys, credentials, or configuration from the filesystem or environment variables.
  • Establishing persistent backdoors or reverse shells from the affected host.
  • Pivoting to other internal systems reachable from the compromised host.
  • Disrupting service availability through process termination, resource exhaustion, or data corruption.

General mitigation guidance

Effective mitigation focuses on eliminating the pattern of constructing shell command strings from untrusted data:

  • Prefer parameterized process execution APIs (e.g., passing command and arguments as arrays) that avoid invoking a shell where possible.
  • Constrain allowed operations through allowlists of supported commands and arguments, rejecting or ignoring anything outside the expected set.
  • Apply strict input validation based on the expected format (e.g., regex for filenames, IDs, plain tokens) rather than attempting to blacklist shell metacharacters.
  • Run command-execution components with least privilege, limiting filesystem, network, and environment access to reduce potential blast radius.
  • Consider sandboxing or isolation mechanisms (containers, restricted users, seccomp, or similar) for components that must execute system commands.
  • Design interfaces so that higher-level operations are exposed instead of raw shell access, minimizing the need to handle arbitrary command strings at all.

How teams detect issues like this

Organizations can detect and manage this class of issue through layered approaches:

  • Static analysis: Configure rules to flag use of shell-based execution functions (e.g., system, popen, exec, subprocess with shell=true, or equivalent) when any part of the command originates from variable input.
  • Code review practices: Require reviewers to explicitly check any command execution logic for concatenation, string interpolation, or inclusion of user-controlled data, and to favor parameterized APIs and allowlists.
  • Security testing: Use targeted fuzzing and penetration tests that inject shell metacharacters into inputs passed to terminal-controller-mcp or similar components to reveal injection paths.
  • Runtime monitoring: Enable logging for command execution invocations and monitor for unusual argument patterns (e.g., presence of ;, &&, |, backticks, or redirection operators) that may indicate exploitation attempts.
  • Policy enforcement: Incorporate secure coding guidelines into CI pipelines that block merges when dangerous command patterns are detected by automated tools.

Sources

SourceLink
github.comgithub.com/GongRzhe/terminal-controller-mcp
github.comgithub.com/GongRzhe/terminal-controller-mcp/issues/7
github.comgithub.com/cfdude/super-shell-mcp/issues/19

Frequently asked

questions

It can be, depending on how terminal-controller-mcp is integrated. If a remote user or service can influence the input to execute_command (for example via an API, chat interface, or automation workflow), then command injection becomes remotely exploitable.

An attacker needs the ability to supply or control the data that ultimately becomes the command string passed to execute_command. This might be as a regular user of an application that uses terminal-controller-mcp, or any role that can trigger command execution with custom input.

The safest pattern is to avoid shell interpretation altogether by using parameterized execution APIs that treat each argument as data, combined with strict allowlists for permitted commands and arguments. Where shell use cannot be avoided, comprehensive validation and escaping must be applied, and the executing context should be tightly constrained.

Establish coding standards that prohibit building shell command strings from untrusted input, require allowlists for any system command interface, and enforce these standards with code review and automated static analysis. Additionally, design higher-level abstractions for common operations so developers rarely need to execute raw shell commands directly.

Find out what's already
exploitable in your codebase.