Skip to content

Commit dec8ffc

Browse files
committed
Local storage should not store files as executable
The PR go-gitea#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 go-gitea#22161 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 998fe26 commit dec8ffc

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
@@ -102,7 +102,8 @@ func (l *LocalStorage) Save(path string, r io.Reader, size int64) (int64, error)
102102
return 0, err
103103
}
104104
// 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)
105-
if err := util.ApplyUmask(p, os.ModePerm); err != nil {
105+
// but we don't want to make these files executable - so ensure that we mask out the executable bits
106+
if err := util.ApplyUmask(p, os.ModePerm&0o666); err != nil {
106107
return 0, err
107108
}
108109

0 commit comments

Comments
 (0)