Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V5902. OWASP. A cryptographically...
menu mobile close menu
Analyzing projects
Additional information
toggle menu Contents

V5902. OWASP. A cryptographically weak hash algorithm is used in security-sensitive code. Consider using a stronger alternative.

Nov 26 2026

The analyzer has detected the use of a cryptographically weak hash algorithm in security-sensitive code.

Vulnerabilities related to the use of a cryptographically weak hash algorithm can be categorized under the OWASP Top 10 Application Security Risks 2025 as follows:

The example:

hash := md5.Sum([]byte(req.Password))
hashStr := fmt.Sprintf("%x", hash)
_, err := DB.Exec("INSERT ....",
                  req.Username,
                  hashStr)

In this case, the password hash is calculated using the cryptographically weak MD5 algorithm, making the data potentially vulnerable to brute-force, rainbow table, collision attacks, etc.

The fixed example:

import (
  ....
  secrand "crypto/rand"
  "crypto/hex"
  "golang.org/x/crypto/argon2"
)
....
func hashPassword(password string) (string, error) {
  salt := make([]byte, 16)
  if _, err := secrand.Read(salt); err != nil {
    return "", err
  }
.
  key := argon2.IDKey(
    []byte(password), 
    salt,        // random 128-bit salt
    argonTime,   // number of passes, e.g. 3
    argonMemory, // memory size in KB, e.g. 64 * 1024
    argonThreads, // degree of parallelism, e.g. 4
    argonKeyLen,  // length of the derived key in bytes, e.g. 32
  )

  // PHC String Format
  return fmt.Sprintf(
    "$argon2id$v=%d$m=%d,t=%d,p=%d$%s$%s",
    argon2.Version, argonMemory, argonTime, argonThreads, 
    hex.EncodeToString(salt),
    hex.EncodeToString(key),
  ), nil
}

....
hashStr, err := hashPassword(req.Password)
....
_, err = DB.Exec("INSERT ....",
                 req.Username,
                 hashStr)

In the fixed example, the Argon2id algorithm from the golang.org/x/crypto/argon2 package is used as the hash function. The comments list the recommended values for the algorithm parameters, as specified in RFC 9106, Section 4. It also requires the generation of a 128-bit seed, for which a cryptographically secure random number generator from the crypto/rand package is used.

You can find more security recommendations on the OWASP Cheat Sheet Series pages:

This diagnostic rule is classified as: