Skip to content

Commit 5921efd

Browse files
committed
Ensure temporary file for editing is only read-writable by owner.
Signed-off-by: Felix Fontein <felix@fontein.de>
1 parent 8c6c9b6 commit 5921efd

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

cmd/sops/edit.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func editTree(opts editOpts, tree *sops.Tree, dataKey []byte) ([]byte, error) {
109109
}
110110
// Ensure that in any case, the temporary file is always closed.
111111
defer tmpfile.Close()
112+
// Ensure that the file is read+write for owner only.
113+
if err = tmpfile.Chmod(0600); err != nil {
114+
return nil, common.NewExitError(fmt.Sprintf("Could not change permissions of temporary file to read-write for owner only: %s", err), codes.CouldNotWriteOutputFile)
115+
}
112116

113117
tmpfileName := tmpfile.Name()
114118

0 commit comments

Comments
 (0)