Repository navigation
fix(git): GHSA-6663-fm5v-gqm5 - Git LFS runs programs named in a repository's own configuration - #5672
Conversation
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>
|
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 14 | 2 | 0 | 0 |
| Head | 14 | 2 | 0 | 0 |
Updated by this run for d61bddaf8989d95a1b00ad11139992c384e7ae2e.
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:gatepassed 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-onlygit_status(and ongit_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:
_LISTED_KEYS): every repository-scopelfs.extension.<name>.clean/.smudge,lfs.customtransfer.<name>.path/.args, andlfs.standalonetransferagentis overridden with an empty value throughGIT_CONFIG_COUNT, as filter and merge drivers already are. Matching uses.*for the name, so dotted and empty names are covered, and because_submodule_driversshares 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.GIT_LFS_SKIP_SMUDGE=1, set byharden_reponext toGIT_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, andgit_addwould stage raw content as a plain blob.Server Details
mcp-server-git)src/git/src/mcp_server_git/server.py(_LISTED_KEYSand its comment, new_LFS_ENV,harden_repo),src/git/README.md("A repository's own programs"), newsrc/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?
VULNERABLEonorigin/v2/main. With the fix it printsnot reproduced: no program ran, andgit_statusreturns Git LFS's error.tests/test_lfs_config.py:harden_repoempties each Git LFS program key (plain, dotted and empty names), keeps the user's own global ones, setsGIT_LFS_SKIP_SMUDGE=1, and lists a submodule's keys. These run everywhere.git-lfsfilter that reads these keys withgit configand runs what they name, as Git LFS does. It runs in CI without Git LFS installed (POSIX only). The test drivesgit_status,git_diff_unstaged,git_diff,git_addandgit_checkoutboth ways, with and without--repository, and asserts that nothing runs.git-lfsis not on PATH): the extension case (nothing runs, and the tool reports an error), the transfer-agent case (nothing runs, andgit_checkoutsucceeds and writes the pointer file), and a plain LFS repository whosegit_statusstill works.origin/v2/main'sserver.py, 12 of the 14 tests fail. With git-lfs installed, the real-LFS tests record the canary (['clean'],['agent', 'agent']).@modelcontextprotocol/inspector@2.9.0 --cli, stdio,--repositoryset to the hostile repository, real git-lfs, isolatedGIT_CONFIG_GLOBAL), on both--protocol-era legacyandmodern:git_status(extension)ext(ran)git_checkout(custom agent)agent agent(ran)git_status(extension)isError: true, Git LFS "executable file not found"git_checkout(custom agent)z.binis the pointer filenpm run local:gate: EXIT=0 on the head commit.Breaking Changes
There is no configuration change. There are two behavior changes for LFS users, documented in the README:
git_checkoutandgit_mergenow 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 pullorgit lfs checkoutreplaces the pointers afterwards..git/configdefines a Git LFS extension now fails the tools that run the LFS clean or smudge filter.Types of changes
Checklist
Additional context
What the fix leaves open:
harden_repotests on every OS it runs, and skips the real-LFS tests.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