Repository navigation
Conversation
Closes #16 (MEDIUM). createWorktree resolved git rev-parse --git-dir with path.resolve(repoRoot, rawGitDir) without a boundary check. When --git-dir returns an absolute path outside repoRoot (separate-git-dir, crafted .git gitfile, core.worktree), path.resolve swallows it and the info/exclude write lands at an attacker-controlled location. Fix: after resolve, realpath-normalize gitDir and assert it is contained within realRepoRoot (startsWith with separator). Throw otherwise. Legit linked worktrees (gitdir inside main .git/) pass. Regression test: repo with --separate-git-dir pointing outside repoRoot → createWorktreeSession throws, external exclude untouched. Verified: worktree 17/17; full npm test 160 pass / 4 pre-existing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Owner
Author
|
Closing — Codex review found the fix breaks legit linked worktrees (gitdir in main .git/, not in repoRoot) AND info/exclude symlinks bypass the containment. Needs a redesign anchored on git-common-dir, not repoRoot. Reopening #16. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16. createWorktree resolved git-dir without boundary check; absolute path outside repoRoot (separate-git-dir) would write info/exclude at attacker location. Fix: realpath boundary check. Regression test: separate-git-dir outside repoRoot -> throws. worktree 17/17.