Summary
dvladimirov MCP up to version 0.1.0 contains a command injection vulnerability in the GitSearchRequest handler of the Git Search API, where user-controlled repo_url or pattern values are passed into shell commands.
A remote attacker who can invoke this API with crafted input may execute arbitrary OS commands with the privileges of the MCP server process.
Affected context
The vulnerability occurs in the Git Search API implementation of dvladimirov MCP, specifically in the GitSearchRequest function in mcp_server.py.
It manifests when the server uses user-supplied repo_url or pattern values to build command-line invocations (e.g., git or search utilities), and those values are concatenated or interpolated into shell commands without robust sanitization.
Environments that expose this API over a network or through chained tools (such as agents or plugins) are affected when they allow untrusted or semi-trusted users to reach the Git search functionality.
Exploit preconditions
- Attack surface: Network-exposed or tool-integrated Git Search API endpoint that processes GitSearchRequest.
- Required access: Ability to send a GitSearchRequest containing controlled
repo_urland/orpatternparameters (e.g., via HTTP, MCP client, or integrated tool). - Trigger point: The server constructs and executes system commands using these parameters, typically via a shell or shell-like interface.
- Why exploitation is possible: User-controlled strings are injected directly into command lines without strict argument separation, escaping, or allowlisting, allowing an attacker to break out of expected parameters and introduce additional commands or shell metacharacters.
Why this happens
The core issue is an unsafe pattern of building OS command strings from untrusted input, mapping to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Instead of treating repo_url and pattern as opaque arguments, the code likely concatenates them into a shell command, relying on the shell to parse the complete string.
Without strict neutralization or the use of non-shell invocation APIs, attackers can insert metacharacters such as ;, &&, |, or backticks to inject additional commands or alter the command structure.
The related CWE-74 aspect reflects that user-controlled data is being incorporated into command-line contexts without appropriate validation, encoding, or contextual escaping.
Potential impact
- Execution of arbitrary system commands with the privileges of the MCP server process
- Unauthorized access to source code repositories or local files
- Exfiltration of sensitive data such as credentials, SSH keys, or configuration secrets
- Destruction or tampering with local repositories and application data
- Establishment of a foothold for further lateral movement in the hosting environment
General mitigation guidance
Effective mitigation focuses on eliminating direct shell interpretation of user-controlled input and strictly controlling how external commands are invoked:
- Prefer APIs that bypass the shell entirely (e.g., direct library calls or subprocess invocation with argument arrays and
shell=False-style patterns). - Treat
repo_urlandpatternas data-only arguments: avoid string concatenation or interpolation into command strings. - Apply rigorous validation and allowlisting for structured parameters such as repository URLs, branch names, and search patterns (e.g., restrict to expected formats and characters).
- Enforce least-privilege execution for the MCP server so that, if a command is abused, its impact is limited.
- Where possible, isolate VCS and search operations in a constrained environment (e.g., containers, sandboxes, or dedicated service accounts with restricted permissions).
How teams detect issues like this
Detection often combines code-level review with runtime monitoring:
- Static analysis: Configure rules to flag uses of shell execution APIs (e.g., generic shell invocation functions) where any part of the command string is influenced by external input such as
repo_urlorpattern. - Code review signals: Look for string concatenation or formatting used to build command lines, especially in request handlers or API endpoints handling user parameters.
- Policy enforcement: Introduce development policies and pre-commit hooks disallowing shell-based command construction in server-side components without explicit security review.
- Runtime monitoring: Use process auditing to detect unusual child processes spawned by the MCP server, anomalous arguments, or command patterns indicative of injection attempts.
- Automated security testing tools and fuzzers can be pointed at the Git Search API to identify unexpected command execution paths.

