Skip to content

fix(review): the index copy goes into a fresh private dir, not a guessable temp path - #160

Merged
backnotprop merged 3 commits into
plannotator:mainfrom
sebastianst:seb/review-temp-index
Nov 20, 2026
Merged

backnotprop merged 3 commits into
plannotator:mainfrom
sebastianst:seb/review-temp-index

Conversation

@sebastianst

Copy link
Copy Markdown
Contributor

TempIndex copied the git index with fs::copy to temp_dir()/plannotator-tui-index-<pid>-<n>, a guessable path in a shared directory. On a shared /tmp, another local user could plant a symlink there, so the copy overwrote any file the reviewer can write. They could also plant a file they control and swap the index that git then reads. This is the same flaw class as #143.

The copy now goes into a directory created exclusively, mode 0700 on Unix, at <dir>/index; drop removes the directory, git's index.lock included. Linux's default fs.protected_symlinks/fs.protected_regular already blunt this on many systems, and macOS and Windows use a per-user temp dir.

🤖 Co-created with Claude Opus 5.5

sebastianst and others added 2 commits November 16, 2026 12:47
…sable temp path

TempIndex copied the git index with fs::copy to temp_dir()/plannotator-tui-index-<pid>-<n>. On a shared /tmp another user could plant a symlink there, so the copy overwrote any file the reviewer can write, or plant a file they control and swap the index git then reads. The copy now goes into a directory created exclusively, mode 0700 on Unix, which drop removes with git's lock file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its one test reads mode bits, so on Windows the module's import went unused and failed clippy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sebastianst

Copy link
Copy Markdown
Contributor Author

The failing check job is a flaky upstream test, capture::tests::notes_follow_their_lines_across_a_recapture (from #150). It fails about 2 runs in 120 on plain main too, and nothing in this PR touches it. Windows and musl pass. A fix for the flake is coming in a separate PR.

🤖 Co-created with Claude Opus 5.5

@sebastianst

Copy link
Copy Markdown
Contributor Author

The flake fix is #161: the index copy got a fresh mtime, which defeats git's racy-clean check. Once it's in, rerunning check here should pass.

🤖 Co-created with Claude Opus 5.5

@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into plannotator:main with commit ee525a6 Nov 20, 2026
3 checks passed
@sebastianst
sebastianst deleted the seb/review-temp-index branch November 20, 2026 02:17
@backnotprop backnotprop mentioned this pull request Nov 23, 2026
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.

2 participants