Re-check the game folder right before git deletes or overwrites files, so a swapped-in junction is refused #162
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ethan-hann/SavePoint#162
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A security review found a check-then-use race in the git operations that delete or overwrite files. DiscardChangesAsync (src/Savepoint.Core/Git/GitEngine.Checkout.cs:124-144) runs CheckWorkTree and RepoMarker.Verify once, then several git processes later runs git clean -f -d -x (254-263); CleanAsync (215-227) and the checkout at 293 are the same. GitRunner.cs:182 passes GIT_WORK_TREE as Path.GetFullPath of the original path, not the link-resolved path PathSafety approved, and each git process reopens the folder by name. On a shared PC where another local account can modify the folder above a game folder (a secondary NTFS drive, a folder made under C:), that account can swap the game folder for a junction to the victim's Documents between the check and git clean, and SavePoint deletes untracked files there. Fix: pass PathSafety.ResolveRealPath as GIT_WORK_TREE and record the folder identity; re-check identity and the consent marker right before each reset --hard, checkout --force and clean; on Windows hold a handle on the folder without FILE_SHARE_DELETE for the whole operation so it cannot be renamed. Severity medium: needs a second local account with write access to the parent folder.
Shipped in 0.9.15 (pull request 174).