Skip to content

fix(git): validate branch names to prevent path injection#462

Merged
chaliy merged 1 commit intomainfrom
claude/fix-423-Y2nIj
Mar 2, 2026
Merged

fix(git): validate branch names to prevent path injection#462
chaliy merged 1 commit intomainfrom
claude/fix-423-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 2, 2026

Summary

  • Added validate_ref_name() to reject .., control chars, trailing .lock, leading dots/dashes
  • Called in branch_create, branch_delete, and checkout
  • Prevents branch_create("../../config") from overwriting .git/config

Test plan

  • test_validate_ref_name_blocks_traversal../../config rejected
  • test_validate_ref_name_blocks_invalid — empty, .hidden, .lock, -dash, spaces, null
  • test_validate_ref_name_allows_validmain, feature/branch, fix-123, v1.0
  • test_branch_create_rejects_traversal — integration test

Closes #423

branch_create, branch_delete, checkout now validate ref names against
git ref rules: no .., no control chars, no trailing .lock, no leading
dots or dashes. Prevents overwriting .git/config via branch names.

Closes #423

https://claude.ai/code/session_01WZjYqxm5xMPAEe7FSHJkDy
@chaliy chaliy merged commit 1e42124 into main Mar 2, 2026
17 checks passed
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.

[M-9] Git branch name path injection in VFS

2 participants