fix(auth): harden tht auth mutations

This commit is contained in:
2026-08-16 19:37:12 +02:00
parent 9646ae09a0
commit 856ac05edc
6 changed files with 245 additions and 31 deletions
@@ -47,6 +47,21 @@ func replaceCanonicalRegular(path string, contents []byte) error {
return nil
}
func removeCanonicalPrivateRegular(path string) error {
parents, target, err := openCanonicalWindowsParent(path)
if err != nil {
return ErrUnsafeFile
}
defer parents.Close()
if err := ValidatePrivateRegular(path); err != nil {
return ErrUnsafeFile
}
if err := windows.DeleteFile(windows.StringToUTF16Ptr(filepath.Join(parents.directory, target))); err != nil {
return ErrUnsafeFile
}
return nil
}
func safeExistingRegular(path string) bool {
return ValidatePrivateRegular(path) == nil
}