Skip to content

fix(git): GHSA-6663-fm5v-gqm5 - Git LFS runs programs named in a repository's own configuration - #5672

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/fix/ghsa-6663-fm5v-gqm5
Nov 27, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/fix/ghsa-6663-fm5v-gqm5

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5664

Fix for GHSA-6663-fm5v-gqm5. It was written and reviewed in the advisory's private fork, where a subagent reviewer stood in for Copilot (which cannot review a private fork) until a clean round. Per the advisory flow this PR gets no Copilot review. The private fork has no Actions, so this PR's CI is the first CI run on the change; the full npm run local:gate passed on this exact head and on a rollup of all eight advisory fixes.

Description

The git server trusts the Git LFS filter from the user's global or system configuration, but Git LFS then reads its own settings from the repository's .git/config, and several of them name programs. A repository supplied by someone else could therefore run a program as the server's user on the read-only git_status (and on git_diff_unstaged, git_diff, git_add, git_checkout, git_merge).

The fix covers the whole class, in the same two ways the server already handles repository-named programs:

  1. Programs named by key are emptied (_LISTED_KEYS): every repository-scope lfs.extension.<name>.clean / .smudge, lfs.customtransfer.<name>.path / .args, and lfs.standalonetransferagent is overridden with an empty value through GIT_CONFIG_COUNT, as filter and merge drivers already are. Matching uses .* for the name, so dotted and empty names are covered, and because _submodule_drivers shares the regex, a checked-out submodule's keys are emptied too. User (global/system) values are untouched. Git LFS fails a command whose extension program is empty ("executable file not found") rather than running anything.
  2. Downloads are turned off (GIT_LFS_SKIP_SMUDGE=1, set by harden_repo next to GIT_NO_LAZY_FETCH). A download runs programs that no single key can pin: core.sshCommand, credential.helper (multi-valued; emptying it would also wipe the user's helpers), core.askpass, all for an endpoint the repository chooses (lfs.url, remote.*.lfsurl, url.*.insteadOf, ...). Git LFS reads this variable from the environment only, so the repository cannot turn it back on.

Option 2 from the advisory (disabling the LFS filter entirely) was rejected: with no clean filter, every LFS file with real content shows as modified in git_status, and git_add would stage raw content as a plain blob.

Server Details

  • Server: git (mcp-server-git)
  • Changed: src/git/src/mcp_server_git/server.py (_LISTED_KEYS and its comment, new _LFS_ENV, harden_repo), src/git/README.md ("A repository's own programs"), new src/git/tests/test_lfs_config.py. No tool schema, description or annotation changes.

Motivation and Context

GHSA-6663-fm5v-gqm5. The README promises that the server never runs a program a repository's own configuration names. With Git LFS installed (the official Docker image always runs git lfs install --system), that did not hold.

How Has This Been Tested?

  • Reproduced first with git 2.54.0 and git-lfs 3.7.1 (the release binary, sha256-verified, placed on PATH for test runs only). The advisory's PoC prints VULNERABLE on origin/v2/main. With the fix it prints not reproduced: no program ran, and git_status returns Git LFS's error.
  • Regression tests in tests/test_lfs_config.py:
    • harden_repo empties each Git LFS program key (plain, dotted and empty names), keeps the user's own global ones, sets GIT_LFS_SKIP_SMUDGE=1, and lists a submodule's keys. These run everywhere.
    • Protocol level, with a stand-in git-lfs filter that reads these keys with git config and runs what they name, as Git LFS does. It runs in CI without Git LFS installed (POSIX only). The test drives git_status, git_diff_unstaged, git_diff, git_add and git_checkout both ways, with and without --repository, and asserts that nothing runs.
    • Protocol level, with the real Git LFS (skipped when git-lfs is not on PATH): the extension case (nothing runs, and the tool reports an error), the transfer-agent case (nothing runs, and git_checkout succeeds and writes the pointer file), and a plain LFS repository whose git_status still works.
    • On origin/v2/main's server.py, 12 of the 14 tests fail. With git-lfs installed, the real-LFS tests record the canary (['clean'], ['agent', 'agent']).
  • Inspector CLI (@modelcontextprotocol/inspector@2.9.0 --cli, stdio, --repository set to the hostile repository, real git-lfs, isolated GIT_CONFIG_GLOBAL), on both --protocol-era legacy and modern:
Build Era Tool Canary Result
v2/main legacy and modern git_status (extension) ext (ran) exit 0, status text
v2/main legacy and modern git_checkout (custom agent) agent agent (ran) exit 5, download error
fix legacy and modern git_status (extension) none exit 5, isError: true, Git LFS "executable file not found"
fix legacy and modern git_checkout (custom agent) none exit 0, "Switched to branch 'other'", z.bin is the pointer file
  • npm run local:gate: EXIT=0 on the head commit.
  • LLM client: not run. No LLM client is available from this environment, so this is not tested with one; the Inspector CLI runs above are the client evidence.

Breaking Changes

There is no configuration change. There are two behavior changes for LFS users, documented in the README:

  • git_checkout and git_merge now write each Git LFS file as its pointer file. Git LFS's skip mode does this even when the object is already in the local store. git lfs pull or git lfs checkout replaces the pointers afterwards.
  • A repository whose own .git/config defines a Git LFS extension now fails the tools that run the LFS clean or smudge filter.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly
  • I have added a changeset (not applicable: Python server)
  • I have tested this with an LLM client (not done: no LLM client available here; Inspector CLI evidence above)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

What the fix leaves open:

  • The analysis covers only Git LFS among trusted drivers. Another driver from the user's own configuration that reads repository config and runs programs from it would have the same shape. None is known, and the README says LFS specifically.
  • Not verified inside the Docker image, or on Linux or Windows hosts. All dynamic tests ran on macOS. CI covers the stand-in and harden_repo tests on every OS it runs, and skips the real-LFS tests.
  • Git LFS reads repository keys beyond those emptied here (lfs.url, lfs.<url>.access, ...). They name no program, and the programs they could reach all sit behind a download, which is now off.

🤖 Generated with Claude Code

cliffhall and others added 2 commits November 27, 2026 00:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 label Nov 27, 2026
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d61bdda

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

git: MCP interface diff

Base: 90e6a48c8c90 (Merge pull request #5652 from modelcontextprotocol/v2/feat/5651-everything-events)
Head: the build in this checkout, at 468eca571a7c (Merge d61bdda into 90e6a48)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 14 2 0 0
Head 14 2 0 0

Updated by this run for d61bddaf8989d95a1b00ad11139992c384e7ae2e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GHSA-6663-fm5v-gqm5] - mcp-server-git: Git LFS runs programs named in a repository's own configuration

1 participant