Repository navigation
Commit 4063e6f
Redesign (3rd eliminate in the worktree security series, after leave-branch
and core.symlinks=false). The original createWorktree wrote .worktrees/ into
<gitDir>/info/exclude to keep the worktree dir out of git status. That write
was the entire #16 vulnerability: if gitDir resolved outside repoRoot
(separate-git-dir, crafted .git gitfile, linked worktree), the exclude write
landed at an attacker-controlled location.
Detection-based fixes (boundary checks) broke after 2 iterations: git
introspection cannot authenticate external common-dirs — legit linked worktrees
gitdir in <main>/.git/worktrees/ is indistinguishable from attack separate-git-dir
via path inspection. Two independent Codex runs converged on the same conclusion:
eliminate the write, don't detect.
Fix: delete the entire git-dir/info/exclude block. git worktree add works WITHOUT
it (the exclude was cosmetic, from openai#137 commit 4bca062). Keep .worktrees/
out of git status via an in-repo .worktrees/.gitignore containing *, written
inside the already-validated worktreesDir (#14 guard ensures inside repoRoot,
not a symlink). No git-dir metadata write = no write outside repoRoot = #16 dead.
Regression tests: separate-git-dir repo now works (previously attack case);
linked worktree works (previously broken by boundary check); external
info/exclude untouched.
Verified: worktree 18/18; full npm test 161 pass / 4 pre-existing.
Co-authored-by: axisrow <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 3bbf13c commit 4063e6f
2 files changed
Lines changed: 73 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
340 | 356 | | |
341 | 357 | | |
342 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
0 commit comments