Go

Go

Made by DeepSource

Using a cost factor of less than 32768 for scrypt GO-S1046

Security
Major
a01 owasp top 10 cwe-329

Using a more significant cost factor significantly increases the compute required to brute-force the passwords from the keys. It is recommended to use a cost factor of more than (or equal to) 32768 for scrypt. But note that there's a trade-off, a higher iteration count will increase the cost of an exhaustive search and make hashing proportionally slower.

Bad practice

package main

import (
    "golang.org/x/crypto/scrypt"
)

func main() {
    _, _ = scrypt.Key([]byte("pass"), []byte("salt"), 1000, 8, 1, 32)
}

Recommended

package main

import (
    "golang.org/x/crypto/scrypt"
)

func main() {
    _, _ = scrypt.Key([]byte("pass"), []byte("salt"), 32768, 8, 1, 32)
}

References