Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V5314. OWASP. Use of an outdated hash a…
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Micro-Optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C++)
OWASP errors (C#)
OWASP errors (Java)
Problems related to code analyzer
Additional information
toggle menu Contents

V5314. OWASP. Use of an outdated hash algorithm is not recommended.

Feb 04 2025

The analyzer has detected the use of an outdated hash algorithm. These algorithms are considered weak due to their collision issues.

Vulnerabilities stemming from the use of weak encryption algorithms can be categorized under the OWASP Top 10 2021 as follows:

Look at the example:

public String calculateHash(String input) {
    MessageDigest digest = null;

    try {
        digest = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }

    var output = digest.digest(input.getBytes(StandardCharsets.UTF_8));
    return Arrays.toString(output);
}

When analyzing the code fragment, the analyzer will warn against using the SHA-1 and MD5 algorithms. In this case, the issue with the algorithms lies in their well-known collision problems. Therefore, using them is not recommended.

It is better to replace outdated algorithms with more modern alternatives. In the example above, one possible solution is to replace SHA-1 with SHA-256:

public String calculateHash(String input) {
    MessageDigest digest = null;

    try {
        digest = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }

    var output = digest.digest(input.getBytes(StandardCharsets.UTF_8));
    return Arrays.toString(output);
}

Oracle's website provides documentation on standard implementations of various hash algorithms. For hashing, the Java SE 21 specification includes the following algorithms, which are considered weak by modern standards:

  • MD2
  • MD5
  • SHA1

It is worth noting that the JavaDoc for MessageDigest guarantees the availability of only the SHA-1 and SHA-256 algorithms across all Java platform implementations. In Java versions up to 11, MD5 is also available.

The official OWASP website provides various techniques for testing applications for potential vulnerabilities caused by the use of weak encryption algorithms.

Additional links:

close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam