Skip to content

mcp-server-git: arbitrary command execution via a repository's own Git configuration (core.fsmonitor) during read-only tools

High
cliffhall published GHSA-6hqx-gqrx-c5r2 Nov 11, 2026

Package

pip mcp-server-git (pip)

Affected versions

< 2026.11.11

Patched versions

2026.11.11

Description

Patched versions

Fixed in mcp-server-git 2026.11.11 (#5514). Upgrade to 2026.11.11 or later. The report below was written against 2026.11.4, before the fix; its "Fixed versions: none" line predates it.

The fix covers every sink the report lists, not only core.fsmonitor:

  • Every Git command the server runs overrides, through GIT_CONFIG_COUNT (which outranks every configuration file and is inherited by the Git processes Git itself starts), the settings that would make Git run a program: core.fsmonitor is false; core.hooksPath points at the null device, so no hook runs; commit.gpgSign and merge.verifySignatures are false; submodule.recurse, status.submoduleSummary and merge.autoStash are false; and core.pager is cat.
  • Every filter driver (filter.<name>.clean, smudge, process), merge driver (merge.<name>.driver) and branch.<name>.mergeOptions that the repository's own configuration defines is emptied. Drivers from the user's global or system configuration, such as Git LFS, keep working.
  • git_merge also passes --no-gpg-sign and --no-verify-signatures, and every diff shown as a patch passes --no-ext-diff and --no-textconv, so diff.external, diff.<driver>.command and textconv filters are ignored.
  • git_status and the diff tools pass --ignore-submodules=dirty, so Git never looks inside a submodule under the submodule's own configuration.
  • A Git older than 2.31, which ignores GIT_CONFIG_COUNT, is refused rather than run unprotected.

git_log and git_show do not run git log or git show, so log.showSignature is never consulted.

Workarounds

None for affected versions other than upgrading. Until then, point the server only at repositories whose .git directory you trust.


Original report

mcp-server-git: arbitrary command execution via a repository's own Git configuration (core.fsmonitor) during read-only tools

Asset: https://github.com/modelcontextprotocol (scoped asset of the HackerOne anthropic program)
Component: mcp-server-git (PyPI), the reference Git MCP server in modelcontextprotocol/servers (src/git)
Package version tested: mcp-server-git==2026.11.4 (PyPI wheel sha256 0cdaa8f446554d020f8ffa0e44ef45b89df4ed4deaeb961b4305d8a2852b4e0e, published 2026-11-04T21:34:52Z)
Default-branch revision tested: 36380287ed3b15d115b55f546617d723072b1296 (2026-11-04, src/git version 2026.11.4); the installed wheel's mcp_server_git/server.py is byte-identical to src/git/src/mcp_server_git/server.py at that revision (sha256 2304871e38ddd95ed807f628cc68b0e0cdd8ec2e82401110211ea8ea647715a5)
CWE: CWE-94 — Improper Control of Generation of Code ("Code Injection"); supporting: CWE-829 — Inclusion of Functionality from Untrusted Control Sphere
CVSS 4.0: 7.0 (HIGH) — CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Affected versions: mcp-server-git up to and including 2026.11.4 (verified on 2026.11.4 and 2026.10.28; earlier versions run the same Git commands and are presumed affected)
Fixed versions: none as of 2026-11-07
Also reproduced on: mcp-server-git==2026.10.28 (previous release; evidence/11-older-version.txt), with and without --repository confinement (evidence/12-unconfined-mode.txt)


Summary

mcp-server-git runs Git commands inside repositories chosen by the client without neutralising the repository's own configuration. Git honours command-bearing configuration keys from .git/config; core.fsmonitor names a program that Git executes whenever it refreshes the index. A call to the read-only git_status tool on an untrusted repository therefore executes an attacker-chosen program with the MCP server's privileges — its environment (including credentials from the client's env block), its filesystem access and its user — without any approval prompt and outside any sandbox that governs the model's own tool calls.

A second command-bearing key, diff.external, gives the same result through the read-only git_diff_unstaged and git_diff_staged tools. The command need not ship as a separate file: it can be inlined in the configuration line itself (core.fsmonitor = sh -c '…'), so a single edited .git/config is enough. The repository's configuration is never overridden: the server's only -c override is core.quotepath=false (src/git/src/mcp_server_git/server.py:104).

This is the vulnerability class publicly tracked as GitSpawn (CSA research note, 2026-09-03) and assigned CVEs for other agent tooling that shells out to Git: CVE-2026-45033 (GitHub Copilot CLI, core.fsmonitor, 8.5), CVE-2026-72718 (Goose, CWE-94, 7.0) and CVE-2026-71963 (Hermes Agent, 8.6). The mcp-server-git reference server has not applied the mitigation those vendors shipped, and no advisory or issue in the repository covers it.

Attack delivery

The malicious configuration lives in .git/config, so the repository must reach the user with its .git directory intact. That is the normal case for the delivery channels this class was reported against (Copilot CLI, Goose, Hermes Agent): a project archive or CI artifact, a backup, a shared network folder, a vendored dependency tree checked into or unpacked beside the user's project, or an agent workspace whose files were copied rather than cloned. A plain git clone of a repository does not copy server-side .git/config, and GitHub's source ZIP excludes .git; those two channels alone do not carry the payload. Everything else that preserves the folder structure does, and the user does not have to run anything inside the repository — one git_status call from the MCP server is enough.

Root cause

open_repo() (server.py:981-990) builds git.Repo(path), and GitPython executes git in that repository. The only configuration override anywhere in the server is core.quotepath=false:

# server.py:104
output = getattr(repo.git(c="core.quotepath=false"), command)(
    *args, stdout_as_string=False
)

Git reads all other configuration from the repository's .git/config. Keys that name a program Git then runs include:

key runs when server tool that triggers it
core.fsmonitor any index refresh git_status, git_diff_unstaged, git_add, git_merge
diff.external / diff.<driver>.command diff output git_diff_unstaged, git_diff_staged, git_diff
core.hooksPath + hooks merge git_merge
log.showSignature + gpg.program log git_log
filter.<driver>.clean staging git_add
commit.gpgSign + gpg.program merge commit git_merge

The demonstrated sink is core.fsmonitor, because it fires on the most innocuous, typically auto-approved tool (git_status) and the payload need not print anything, so the tool result looks completely normal.

Steps to reproduce

Full runnable PoC: poc/ in this packet. The repository is self-contained: the payload script ships inside the repository and is named by its own .git/config, so it travels intact through any channel that preserves a .git directory (an archive, a shared folder, a vendored dependency tree, a CI workspace).

  1. Install the exact published package (Python 3.10+; 3.12/3.15 used here):

    python3 -m venv .venv
    ./.venv/bin/pip install "mcp-server-git==2026.11.4"
  2. Create a project workspace that is itself a Git repository, and a nested "untrusted" repository inside it:

    mkdir -p /tmp/poc/workspace/vendor/untrusted-repo
    git -C /tmp/poc/workspace init -q
    git -C /tmp/poc/workspace/vendor/untrusted-repo init -q
    cd /tmp/poc/workspace/vendor/untrusted-repo
    echo hello > README.md
    git add README.md && git -c user.email=a@b -c user.name=a commit -qm init
    printf '#!/bin/sh\nid > /tmp/poc/payload-ran.txt\n' > payload.sh
    chmod +x payload.sh
    git config core.fsmonitor ./payload.sh
  3. Start the server confined to the workspace and call the read-only git_status tool on the nested repository. The PoC does this over stdio:

    ./poc/run.sh            # fsmonitor scenario, tool git_status

    The JSON-RPC exchanged is:

    {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"poc","version":"1.0"}}}
    {"jsonrpc":"2.0","method":"notifications/initialized"}
    {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"git_status","arguments":{"repo_path":"/tmp/poc/workspace/vendor/untrusted-repo"}}}
  4. Observe that the payload ran. On this host:

    [*] version       : mcp-server-git 2026.11.4
    [*] git_status result: Repository status:\nOn branch main\nUntracked files:\n ... payload.sh ...
    [*] marker .../payload-executed.txt: EXISTS
    PASS: repository-supplied command executed with the MCP server's environment
          and read a file outside the repository
    uid=501 pid=12741 canary=canary-b33fd412a6ff4100b37fb5652a9e5472 outside=outside-the-repository-content-2928
    

    The marker records the payload's uid and pid, the value of an environment variable that exists only in the server process (MCP_GIT_POC_CANARY), and the contents of a file outside the repository — arbitrary code execution in the server's context, not a data-only bug.

  5. Optional second sink and negative control:

    ./poc/run.sh --scenario diff-external   # diff.external + git_diff_unstaged, same result
    ./poc/run.sh --scenario control         # same repository, no key: nothing runs (PASS)

Raw transcripts of all three runs are in evidence/03-poc-fsmonitor.txt, evidence/04-poc-diff-external.txt and evidence/05-control.txt.

Observed vs expected

Observed. A read-only git_status (or git_diff_unstaged) call performs its normal work and returns a normal result, while a program named by the inspected repository's .git/config executes with the MCP server's privileges. git trace2 shows the exact command the server issues:

argv: ["git", "-c", "core.quotepath=false", "status"]

No core.fsmonitor override is present, so Git uses the repository's value (evidence/07-trace2-argv.txt).

Expected. Inspecting a repository with a read-only tool must not execute code supplied by that repository. The server should run Git with command-bearing configuration keys neutralised (for example -c core.fsmonitor=false, -c diff.external=, an empty hooks path), so the call in step 3 produces no process outside Git's own.

Impact

  • Arbitrary code execution as the user running the MCP server. A developer running uvx mcp-server-git executes the payload as themselves; a CI/agent runner executes it as the runner account.
  • Credential and data theft. The payload inherits the server's environment — including any secrets passed through the MCP client's env block — and can read the user's home directory, SSH keys, cloud credentials and every repository on the disk.
  • No approval and no sandbox. The execution happens inside git, not through the model's own command-execution tool, so client-side confirmation dialogs and tool sandboxes never engage. From the client's perspective it merely asked Git for status.
  • No visible signal. The payload's output can be empty, and the tool result is the ordinary status text, so neither the user nor the model sees anything unusual.
  • Trigger surface. git_status is the most frequently called tool in the server (models call it to orient themselves), and the git_commit_message / git_summarize_changes prompts call git_diff_staged / git_status as well. diff.external was verified to fire on git diff --cached too, so the commit-message prompt is a second trigger.

Suggested fix

Neutralise the repository's configuration for every Git invocation, with the highest-precedence mechanism (GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n overrides every config file, exactly as GitHub's Copilot CLI fix for CVE-2026-45033 does). In open_repo(), immediately after git.Repo(path) and before validate_opened_repo() runs any Git command:

import tempfile

empty_hooks_dir = tempfile.mkdtemp(prefix="mcp-git-no-hooks-")  # never populated
repo = git.Repo(path)
repo.git.update_environment(
    GIT_CONFIG_COUNT="8",
    GIT_CONFIG_KEY_0="core.fsmonitor",        GIT_CONFIG_VALUE_0="false",
    GIT_CONFIG_KEY_1="core.hooksPath",        GIT_CONFIG_VALUE_1=str(empty_hooks_dir),
    GIT_CONFIG_KEY_2="diff.external",         GIT_CONFIG_VALUE_2="",
    GIT_CONFIG_KEY_3="log.showSignature",     GIT_CONFIG_VALUE_3="false",
    GIT_CONFIG_KEY_4="commit.gpgSign",        GIT_CONFIG_VALUE_4="false",
    GIT_CONFIG_KEY_5="merge.verifySignatures", GIT_CONFIG_VALUE_5="false",
    GIT_CONFIG_KEY_6="safe.bareRepository",   GIT_CONFIG_VALUE_6="explicit",
    GIT_CONFIG_KEY_7="core.pager",            GIT_CONFIG_VALUE_7="cat",
)

and pass --no-ext-diff --no-textconv to the diff-producing commands (git_diff, git_diff_unstaged, git_diff_staged, and the diffs in git_show). For git_add, also override every filter.*.clean / filter.*.smudge key the repository defines (enumerate with git config --get-regexp '^filter\.'), or reject repositories that define filters. Add regression tests under src/git/tests/ that point core.fsmonitor and diff.external at a marker script and assert the marker is never created.

The minimal fix for the demonstrated sink is one key — core.fsmonitor=false — which this packet verified stops the payload (evidence/10-mitigation-check.txt). The broader set above is recommended because a fix scoped to one key leaves the other sinks live, the same scoping mistake Manifold's research found in other agents.

References

Notes on scope

  • Non-DoS: this is arbitrary code execution, not a hang or allocation.
  • The other reference-server classes in scope were probed and held: see submission-checklist.md §"Other classes checked" and evidence/08-filesystem-path-probes.txt, evidence/09-fetch-ssrf-probes.txt.
  • No existing advisory or issue covers this: evidence/06-existing-advisories.txt.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

CVE ID

No known CVE

Weaknesses

Improper Control of Generation of Code

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. Learn more on MITRE.

Inclusion of Functionality from Untrusted Control Sphere

The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. Learn more on MITRE.

Credits