A password is hashed with a salt written into the program, the same for every password
What it finds
pbkdf2.Key(password, []byte("s3cr3t-salt"), 4096, 32, sha256.New): a salt makes the same password hash differently for each account, so that precomputed tables and one guess against all accounts at once do not work. A salt written into the program is the same for everyone and defeats that. Each password gets its own random salt from crypto/rand, stored next to the hash.
Reported are salts that are constant bytes, as described for constant byte values of the pack, given to Key of golang.org/x/crypto/pbkdf2, crypto/pbkdf2 or golang.org/x/crypto/scrypt, or to Key or IDKey of golang.org/x/crypto/argon2.
From the rule's source, constant_salt.rs.
package p import ( "crypto/sha256" "golang.org/x/crypto/pbkdf2") var fixed = []byte("s3cr3t-salt") func hash(password, salt []byte) [][]byte { local := []byte{1, 2, 3, 4} return [][]byte{ pbkdf2.Key(password, []byte("s3cr3t-salt"), 4096, 32, sha256.New),tx0 reports: the salt is written into the program pbkdf2.Key(password, fixed, 4096, 32, sha256.New),tx0 reports: the salt is written into the program pbkdf2.Key(password, local, 4096, 32, sha256.New),tx0 reports: the salt is written into the program pbkdf2.Key(password, salt, 4096, 32, sha256.New), }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:constant-salt" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:constant-salt] reason="..."tx0 explain tx0/go:constant-salt shows the same in the terminal. Found a false positive? Report it.