Do not create a file with too much permissions

このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

Metadata

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)
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis

PREVIEWING: brett0000FF/node-compatibility