Severity:

HIGH RISK

(7.3)

Command Injection in MCP Tool Server

CVE-2026-7812

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-74, CWE-77

Impact:

Remote Command Execution

Severity:

HIGH RISK

(7.3)

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 the git_operation function of src/code_mcp/server.py allows untrusted input from the operation argument to be incorporated into system-level commands.

When exposed over a network, an attacker can remotely manipulate this argument to execute arbitrary commands with the privileges of the MCP Tool server process.

Affected context

This vulnerability affects deployments of the 54yyyu code-mcp MCP Tool that:

  • Expose the git_operation functionality over a networked interface (e.g., HTTP, RPC, or MCP protocol)
  • Accept an operation argument originating from a client or other untrusted source
  • Construct and execute system commands (such as git operations) using that argument without strict validation or safe APIs

Because the project uses continuous delivery with rolling releases, the exact affected commit range is unclear, and operators should assume instances using this logic may be impacted until verified otherwise.

Exploit preconditions

  • Attack surface: Remote interface exposing the MCP Tool's git_operation functionality.
  • Required access: Ability to invoke or influence calls to git_operation, typically as any client able to reach the MCP server endpoint.
  • Trigger point: Supplying a crafted operation argument that is embedded into a shell command or command-line invocation without robust sanitization or argument separation.
  • Why exploitation is possible: The server-side code appears to interpolate the operation argument into command strings (e.g., shell or subprocess calls) in a way that allows special characters, separators, or additional tokens to be interpreted as new commands or arguments, matching CWE-77/74 patterns.

Why this happens

The underlying bug is a classic command injection flaw, where untrusted data is mixed into command execution contexts.

In the git_operation function, the operation argument is treated as trusted and used to build git-related commands without:

  • Strictly whitelisting allowed operations or subcommands
  • Safely separating arguments from the command using non-shell APIs
  • Neutralizing or rejecting metacharacters and control operators

This aligns with:

  • CWE-77: Command Injection — untrusted input is used to construct OS commands.
  • CWE-74: Improper Neutralization of Special Elements in Output — special characters in the output context (command string) are not properly handled, allowing them to alter command structure.

Potential impact

  • Remote execution of arbitrary OS commands with the privileges of the MCP Tool server process
  • Reading, modifying, or deleting files accessible to the service account
  • Interference with CI/CD or development workflows that rely on the MCP Tool
  • Pivoting to other internal services or resources reachable from the compromised host
  • Data exfiltration or tampering of repositories and build artifacts

General mitigation guidance

Effective mitigation generally focuses on eliminating direct command construction from untrusted input and constraining the allowed operations:

  • Adopt a strict allowlist of supported git operations and map incoming values to predefined, constant command templates instead of passing user-controlled strings directly.
  • Use safe process execution APIs that avoid shell interpretation (e.g., pass command and arguments as lists, disable shell features) so metacharacters are not interpreted.
  • Treat the operation parameter as untrusted: validate against known patterns (e.g., exact keywords) and reject anything unexpected rather than attempting to sanitize arbitrary input.
  • Run the MCP Tool with least privilege, using dedicated low-privilege accounts and minimal filesystem/network access to reduce blast radius if a compromise occurs.
  • Isolate the service using containers, process-level sandboxing, or restricted execution environments so that even successful command injection has limited reach.

How teams detect issues like this

Organizations can look for command injection risks and active exploitation using several approaches:

  • Static analysis: Configure rules to flag usage of shell-based execution (e.g., subprocess with shell=True, os.system, or equivalent APIs) when arguments originate from network or request data such as the operation parameter.
  • Code review: Examine the git_operation function and similar helpers for:
  • String concatenation or interpolation that builds command lines
  • Passing user-controlled values directly into process execution calls
  • Lack of explicit allowlists or argument validation for operations.
  • Runtime monitoring: Enable detailed command execution logging, including arguments and calling services, to detect unusual or multi-part commands originating from the MCP Tool.
  • Security testing: Incorporate automated application security tests (e.g., SAST/DAST) into CI/CD pipelines to catch injected shell metacharacters and anomalous behavior before deployment.

Sources

SourceLink
github.comgithub.com/54yyyu/code-mcp/
github.comgithub.com/54yyyu/code-mcp/issues/5
vuldb.comvuldb.com/submit/807752
vuldb.comvuldb.com/vuln/361072
vuldb.comvuldb.com/vuln/361072/cti

Frequently asked

questions

Yes, as described, the attack can be initiated remotely if the MCP Tool's git_operation interface is reachable by an attacker or through a compromised client that can send crafted requests.

The attacker generally needs the capability to invoke or influence calls to the git_operation function. This can be as minimal as network access to the service endpoint; no local shell access is required if the server accepts requests over the network.

The safest approach is to stop constructing shell commands from untrusted input. Use a strict allowlist of permissible operations mapped to fixed command templates and execute them via non-shell APIs that separate command and arguments, removing the ability for user input to change command structure.

Establish engineering guidelines that prohibit shell command construction with user-controlled data, enforce input validation and allowlisting for any operation selector parameters, and integrate automated security checks (such as SAST rules for dangerous command APIs) into your development and review processes.

Find out what's already
exploitable in your codebase.