Security Flaws in Anthropic MCP Git Server Expose File Access and Enable Code Execution

The git_init tool in the server would accept an arbitrary filesystem path and turn that path into a Git repo without validating whether that path should be touched. That means a malicious input (for example, coming from a repository README or from a repo path argument supplied by an LLM/agent) could cause the server to write Git metadata and files into any directory the service account can access. This could be used to plant configuration files or make other files eligible for later Git operations by the server.

How it can be chained / exploited in practice

  • Attacker poisons content the agent will read (README, issue text, or code file) to instruct the LLM to call git_init on a chosen path.
  • git_init creates .git metadata at that path, making it an operative repo the MCP server will later accept for git operations.
  • Subsequent operations (diff/checkout) can then be used to overwrite files, add malicious hooks, or change config that causes later code execution (depending on surrounding tooling).

MITRE ATT&CK mapping (likely):

  • T1190 (Exploit Public-Facing Application) — because the attack leverages a publicly reachable tool, and
  • T1204 / T1059 variants (depending on whether agent is induced to run commands). (Map to relevant technique IDs in your tracking system.)

PoC availability: no polished public exploit chain was widely published; advisory authors and maintainers closed the issue quickly and pushed a patch. Some community writeups demonstrate the concept (how git_init can create .git in arbitrary locations), but not a packaged exploit.

How to detect (symptoms / payload signs):

  • New .git directories appearing in unexpected locations (look for creation events on filesystem).
  • Unusual git init or git command invocations by the MCP server process in process execution logs.
  • Sudden changes to repository config files outside normal deployment windows.

Detection rules (practical examples you can add to your SIEM / EDR):

  • File creation rule: alert when a .git directory is created outside approved repo paths (example pseudo-rule):
    if file_created AND path matches "*/.git/*" AND NOT path startswith /opt/allowed-repos THEN alert
  • Process monitoring rule: alert on python/server process spawning git init with a path outside configured repo roots.
  • Integrity check: nightly verification that all repo paths are within a known allowlist and that no new top-level .git folders appear.

Log sources to monitor:

  • Host-level file audit logs (inotify, Windows ETW or Sysmon filecreate events).
  • Process execution logs (Sysmon Event ID 1 / auditd execve).
  • MCP server access logs (what tool call was requested, by whom).
  • Git operation logs (if you capture STDOUT/args of the git commands).

Official patch (vendor): upgrade mcp-server-git to 2025.9.25 (removes or restricts git_init behavior). Use the project’s security advisory and GitHub advisory entry for the exact patched package.


CVE-2025-68144 — Argument injection in git_diff / git_checkout

Summary : certain server tools accepted user inputs and passed them directly into git commands without proper sanitization. That allowed an attacker to craft arguments that alter git’s behavior (for example, passing additional flags or refs), which can be used to overwrite local files or otherwise manipulate the target system.

How it can be exploited (typical chain):

  • Malicious text instructs the LLM to run git_diff or git_checkout with a crafted ref or argument.
  • Because the MCP server forwards that argument unsafely, git interprets additional flags or refnames and can be made to write unexpected files or overwrite existing ones.
  • If the server runs with file permissions allowing it, attackers can overwrite code, config, or deploy artifacts that later cause code execution.

MITRE mapping (likely):

  • T1222 (File and Directory Permissions Modification) — in case of overwrites;
  • T1059 (Command and Scripting Interpreter) — if the overwritten files lead to script execution later.

PoC status: vulnerability databases and advisory summaries describe the mechanism and demonstrate file overwrite scenarios; full public exploit packages are not widespread. Treat claimed PoCs cautiously — they often require specific deployment options to succeed.

Detection / payload signatures:

  • Unexpected git arguments that start with - or include shell metacharacters in server access logs.
  • Alerts on git checkout or git diff run with refs that contain suspicious characters (e.g., -- or semicolons).
  • Hash mismatches for checked-out files vs known good baselines (integrity monitoring alerts).

Detection rule examples (SIEM / IDS):

  • Block or alert when git command arguments captured in logs include -- followed by nonstandard flags or when refnames contain whitespace or shell meta-chars.
  • Monitor for git checkout operations that modify binary or sensitive config files outside normal change windows.

Log sources to inspect:

  • MCP server tool call logs (arguments passed).
  • Process commandline captures (Sysmon 1 or equivalent).
  • File integrity monitoring (Tripwire, OS native integrity logs).

Official patch (vendor): upgrade mcp-server-git to 2025.12.18 where argument validation for git_diff/git_checkout was added; patched releases validate refs and reject unsafe args.


CVE-2025-68145 — Path validation bypass with --repository flag

Summary : when operators configured the server with a --repository flag intended to restrict operations to a specific repo path, subsequent tool calls could supply an alternate repository path that the server did not properly validate. That allowed tool calls to operate on other file locations the server process could access. In effect, a configured restriction was bypassable.

How it can be exploited:

  • The LLM/agent is induced to request operations referencing an attacker-chosen repo_path.
  • Because the server fails to resolve symlinks/validate the final path against the allowed root, operations execute on an attacker-controlled or arbitrary path, enabling data disclosure or modification.
  • Combined with git_init or argument injection, this can widen impact (read/write outside expected scope).

MITRE mapping (likely):

  • T1213 (Data from Information Repositories) for exfiltration possibilities;
  • T1105 (Remote File Copy) if attacker can push files via git operations.

PoC status: advisory records and GHSA entries show the condition and the fix; practical exploitation is trivial if the server is configured with --repository and accepts external inputs — but public exploit packages are not broadly circulated.

Detection / payload signs:

  • Tool calls referencing repo paths outside the configured root.
  • File operations in unexpected repo directories (file create/modify alerts in non-approved repo set).

Detection rule examples:

  • Alert when an MCP repo_path argument resolves (after symlink resolution) to a path outside the configured allowlist. (Implement path resolution logic server-side or in a detection rule.)
  • Periodic scans to verify the server’s --repository constraint matches active repo call targets.

Log sources to monitor:

  • MCP server API/logs (capture repo_path arguments).
  • Filesystem audit logs to correlate repo_path uses and file changes.

Official patch (vendor): upgrade to mcp-server-git 2025.12.17 / 2025.12.18 (the vendor advisory lists the fixed release and added path resolution and validation; use the GitHub security advisory entry for the exact patched tag).


Practical remediation checklist (what we recommend, step-by-step)

  1. Patch immediately: upgrade mcp-server-git to the patched releases (see official advisories listed above). Prioritize systems exposed to untrusted repos or internet-facing interfaces.
  2. Harden MCP server runtime: run the server under minimal privileges and inside a restrictive container or sandbox; mount only approved repo directories read-only where possible.
  3. Treat all tool inputs as untrusted: add server-side validation for all arguments (reject arguments starting with -, resolve symlinks and verify path within allowlist, canonicalize ref names).
  4. Enable aggressive logging: capture full tool-call arguments, process execs, and file creation events for post-incident analysis.
  5. Add integrity monitoring: watch for new .git directories or unexpected config file changes.
  6. Educate LLM/agent workflows: don’t direct agents to run dangerous tool calls on raw untrusted content; require human approval for file-system-affecting operations.