Do not create a file with too much permissions
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください。
ID: go-security/write-file-permissions
Language: Go
Severity: Warning
Category: Security
CWE: 284
Description
Granting write access to a file is a security since other users can modify the content of the file. The issue is amplified for executable files that can be easily compromised (like scripts). Avoid giving write permissions to others to files.
Learn More
Non-Compliant Code Examples
package main
import (
"fmt"
"os"
)
func main() {
d1 := []byte("something somethingn")
err := ioutil.WriteFile("myfile", d1, 0777)
check(err)
}
Compliant Code Examples
package main
import (
"fmt"
"os"
)
func main() {
d1 := []byte("something somethingn")
err := ioutil.WriteFile("myfile", d1, 0770)
check(err)
}