Skip to content

Commit 56bded9

Browse files
authored
Local storage should not store files as executable (#22162) (#22163)
Backport #22162 The PR #21198 introduced a probable security vulnerability which resulted in making all storage files be marked as executable. This PR ensures that these are forcibly marked as non-executable. Fix #22161 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]>
1 parent e88218f commit 56bded9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/storage/local.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ func (l *LocalStorage) Save(path string, r io.Reader, size int64) (int64, error)
103103
return 0, err
104104
}
105105
// Golang's tmp file (os.CreateTemp) always have 0o600 mode, so we need to change the file to follow the umask (as what Create/MkDir does)
106-
if err := util.ApplyUmask(p, os.ModePerm); err != nil {
106+
// but we don't want to make these files executable - so ensure that we mask out the executable bits
107+
if err := util.ApplyUmask(p, os.ModePerm&0o666); err != nil {
107108
return 0, err
108109
}
109110

0 commit comments

Comments
 (0)