Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
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.

04 Fév 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:

This diagnostic is classified as:

close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I want to join the test
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si l'e-mail n'apparaît pas dans votre boîte de réception, recherchez-le dans l'un des dossiers suivants:

  • Promotion
  • Notifications
  • Spam