Skip to content

fix(git): strictly validate repo path, working tree, and git directory - #4723

Open
AbhiPra24 wants to merge 1 commit into
modelcontextprotocol:mainfrom
AbhiPra24:fix/git-server-repo-path-validation
Open

fix(git): strictly validate repo path, working tree, and git directory#4723
AbhiPra24 wants to merge 1 commit into
modelcontextprotocol:mainfrom
AbhiPra24:fix/git-server-repo-path-validation

Conversation

@AbhiPra24

Copy link
Copy Markdown
Contributor

Description

Hardens repository path validation in mcp-server-git to strictly prevent path traversal or symlink escapes outside the allowed repository root directory.

  • Adds validation of repo.working_dir and repo.git_dir against the allowed repository path in call_tool to prevent escapes via worktrees, submodules, or symlinked git directories.
  • Adds test cases covering prefix collision, nested symlink chains, and internal symlinks.

Fixes #4550

…apes

- Validate repo working directory and git directory against allowed repository
- Ensure repository path containment prevents path traversal and symlink escapes
- Add tests for prefix collision, nested symlink chains, and internal symlinks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] mcp-server-git: validate_repo_path opt-in bypass (architectural complement of CVE-2025-68145)

1 participant