fix: honor git global core.excludesFile as an ignore source#542
fix: honor git global core.excludesFile as an ignore source#542mvanhorn wants to merge 2 commits into
Conversation
Implements 2026-06-20-013-fix-global-core-excludesfile-ignore-source. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Hi @mvanhorn — thank you for this. Honoring git's global excludes (#499) is a real gap, and your layering ( Before we can land it, there's one security issue in the resolution order we need to sort out. Because cbm indexes arbitrary directories on request (an MCP client/agent can point it at any path, including an untrusted repo someone just cloned), a repository can ship a [core]
excludesFile = ~/.ssh/id_rsaand simply indexing that repo will open and read that file. git itself is safe here because it only reads a repo's The direction we'd suggest:
One note on timing: we think this is worth doing, but we're capacity-constrained right now, so even once the security fix is in it may take a while to land in a release. If others want it, a 👍 on #499 helps us prioritize. And if you'd rather not carry the rework, we're happy to build on top of your branch and credit you — just say the word. Really appreciate the PR and the careful tests. 🙏 |
Drop the repo-local .git/config pass in resolve_global_excludes_path() so an untrusted repo cannot point core.excludesFile at an arbitrary file (e.g. ~/.ssh/id_rsa) and have cbm open and read it merely by being indexed. git is safe here because it only trusts a repo's .git/config after a deliberate clone/init; the indexer has no such trust step. Global excludes now resolve only from the user-owned ~/.gitconfig and $XDG_CONFIG_HOME/git/config. A repo's own ignores remain handled by .gitignore / .cbmignore. Add a guard test asserting a repo-local .git/config whose excludesFile points outside the repo is ignored, not read. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Follow-up after a closer security review — I want to reframe my earlier comment. On reflection this isn't a blocking vulnerability: reading So please treat the earlier note as recommended hardening / defense-in-depth, not a blocker: restricting a repo-local |
|
Done in 9f66e42.
Verified locally with the discover suite under ASan/UBSan (319 passing, including the new test). No rush on landing given your capacity note, and happy to leave it here as-is. Thanks for the careful review. |
What does this PR do?
Honors git's global
core.excludesFile(including the XDG default~/.config/git/ignore) as a repo-root ignore source during discovery, matching git's own ignore precedence. Previously only in-repo.gitignore/.git/info/excludewere consulted, so files a user globally ignores were still indexed.This resolves the half of #499 the maintainer separated from the in-flight
.git/info/excludework in #493: the global excludes chain (explicitcore.excludesFile, then$XDG_CONFIG_HOME/git/ignore, then~/.config/git/ignore) is now read and applied at the repo root.Closes #499
Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)AI was used for assistance.