cd /news/ai-agents/a-submodule-s-git-config-could-make-… · home › topics › ai-agents › article
[ARTICLE · art-181334] src=yusefsyed.github.io ↗ pub= topic=ai-agents verified=true sentiment=↓ negative

A submodule's .git/config could make mcp-server-git run a program

The Model Context Protocol's reference Git server, mcp-server-git, was patched in version 2026.11.18 after security advisory GHSA-8wv7-r664-7594 showed that a submodule's own .git/config could make the server execute a program named in settings such as diff.external, textconv or filter.<name>.clean during git_diff, git_checkout or git_add. The flaw bypassed the harden_repo function added in 2026.11.11 for earlier advisory GHSA-6hqx-gqrx-c5r2, which only read the top-level repo's config; in the advisory's reproduction the payload wrote its marker 3 times out of 3 with the config in place and 0 out of 3 in control repos. Only repos that arrive with their .git folders intact — a zipped project, shared dev volume or CI artifact, not a plain git clone or GitHub source ZIP — can trigger it, and the server had about 460K PyPI downloads in the last 30 days; 2026.11.27 is the latest release.

recommendation

Update mcp-server-git to 2026.11.18 or later and avoid pointing it at repos that arrive with .git folders intact, such as zipped projects or shared volumes, since submodule config can execute programs.

more in playbook: Securing agents and AI tools
read6 min views5 publishedDec 3, 2026

Yusef Syed. .

If an AI agent used mcp-server-git on a repo someone else prepared, a diff, a checkout or a git add . could run a program named in a submodule's own .git/config. It's fixed in 2026.11.18, so update (2026.11.27 is the latest right now). A plain git clone doesn't trigger it, because the repo has to arrive with its .git folders still inside, like a zipped project or a shared dev volume.

mcp-server-git is the Model Context Protocol project's reference Git server. An agent uses it to run tools like git_status, git_diff, git_checkout and git_add on a repo you point it at, and it had about 460K PyPI downloads in the last 30 days (pypistats). Its README says it never runs a program a repo's configuration names. A submodule got around that. The diff case also needs one setting in the parent repo, covered below. The advisory is GHSA-8wv7-r664-7594.

What happened #

Git config can name programs. diff.external runs a diff tool, a textconv driver converts files before a diff, and a filter.<name>.clean command runs when Git hashes a working-tree file, for git add or to check whether the file changed. That's fine in your own repos. In a repo someone else hands you, git diff can run their program, which is what the server promises to prevent.

The README puts it this way: "A repository's configuration and hooks travel with it (an unpacked archive, a shared folder, a vendored tree), so the server never runs a program they name, with or without --repository."

To keep that promise, the server runs a function called harden_repo on every repo it opens. It pins a list of safe settings through GIT_CONFIG_COUNT overrides, which outrank every config file. It also reads which filter and merge drivers the repo's config defines and overrides each one with an empty command. The diff tools pass --no-ext-diff --no-textconv on top of that. All of this landed in 2026.11.11 as the fix for an earlier advisory, GHSA-6hqx-gqrx-c5r2.

But harden_repo only reads the config of the top-level repo. A submodule is its own repo with its own .git/config, and the server never read that file. For the diff tools, the chain looks like this:

git_diff -> git diff in the parent (parent config has diff.submodule=diff)
         -> nested git diff inside the submodule (no --no-ext-diff)
         -> the submodule's diff.external runs

The advisory's reproduction used a payload that only appends a word to a file in a temporary directory. Each affected call wrote that marker 3 times out of 3 with the config in place, and 0 out of 3 in the control repos.

Am I affected? #

Only if the server was pointed at a repo that arrived with its .git folders inside. A plain git clone doesn't copy .git/config, and GitHub's source ZIP leaves out .git completely, so cloning a repo off GitHub doesn't trigger this. A zipped project, a shared dev volume, a CI artifact or a workspace where something else already wrote the config can. When it happens, the program runs as whatever user is running the server.

Running plain git diff in a folder like that yourself would do the same thing. The difference is that this server says it never does, and an agent will call it on a repo you haven't looked at. I haven't seen this happen. The case I have in mind is an agent handed a zipped repo and asked what changed, which would call git_diff first.

To check, look at the version your MCP client actually runs. From a Python environment:

pip show mcp-server-git

Anything before 2026.11.18 is affected. Also run git --version: on Git older than 2.33, the fixed server refuses repos with a checked-out submodule. If you can't update yet, don't point the server at repos that arrived with their .git folders.

It's rated High, CVSS 7.8. The vector has AV:L/UI:R: the config has to already be on disk, and someone has to point the server at the repo. My report suggested the same vector as the earlier advisory, and the maintainers kept it.

Why the hardening missed it #

A comment in the 2026.11.11 code says that when Git compares the working tree, it looks inside each submodule using that submodule's own config, which harden_repo never sees. So git_status, git_diff and git_diff_unstaged got a flag:

_NO_SUBMODULE_STATUS = "--ignore-submodules=dirty"

That covered the case in the comment. Two other paths were still open.

Add and checkout were one. In 2026.11.11 they come down to:

repo.git.add(".")
repo.git.checkout(branch_name)

Neither passes a submodule flag, and git add and git checkout don't accept --ignore-submodules anyway. Git checks the submodule's working tree and can run the filter.<name>.clean command from the submodule's config. The repo doesn't need a .gitmodules entry for this. A gitlink (the submodule's entry in the index) is enough.

The diff tools were the other, and this one needs diff.submodule=diff in the parent's config. Then git diff runs a nested git diff inside each submodule that changed. The nested one doesn't inherit --no-ext-diff --no-textconv, so the submodule's diff.external or textconv driver runs. That reaches git_diff, git_diff_staged and git_diff_unstaged, the tools that are supposed to be read-only.

git_status, git_show, git_reset and git_create_branch were not affected. git_show builds its diff through GitPython rather than running git show, which would have been. The advisory has the full reproduction, which was run against the published 2026.11.11 package with Git 2.53.0 on macOS.

The fix #

The fix is in PR #5587. The diff path needs one new line in the list of pinned settings:

+    ("diff.submodule", "short"),

With short, Git prints only the two Subproject commit IDs, so the nested diff never starts. For add and checkout, a new function, _submodule_drivers(), walks the gitlinks in the index, including nested ones, and empties the filter and merge drivers that each checked-out submodule defines. Skipping submodule paths would have been simpler, but then git add . would stop staging a moved submodule commit.

Checkout now runs with --quiet. The server also refuses a repo with a checked-out submodule when Git is older than 2.33, because, per the maintainers' code comment, Git 2.31 and 2.32 drop GIT_CONFIG_COUNT for the Git that runs inside a submodule.

The maintainers wrote the merged fix themselves. My report suggested the first two changes, and the --quiet checkout and the 2.33 minimum were their additions.

Status #

I reported this privately on November 13. The fix, the 2026.11.18 release and the advisory all went out on November 18. Thanks to the maintainers for turning it around in five days.

I'm one of the two credited reporters. I found it with AI-assisted code analysis and an automated test harness, and the report says so.

What I took from it #

The hardening was careful. It checked that Git actually applied its overrides, and the code even had a comment about this risk. But a list of overrides only covers the configs the server reads, and Git reads one more for every submodule.

── more in #ai-agents 4 stories · sorted by recency
── more on @mcp-server-git 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-submodule-s-git-co…] indexed:0 read:6min 2026-12-03 · —