Usage of weak hashing library (MD5)

Description

Using a weak hashing library like MD5 increases the risk of data breaches. MD5 is vulnerable to collision attacks, where two different inputs produce the same output, compromising data integrity and security.

Remediations

  • Do not use MD5 for hashing purposes. This algorithm is no longer considered secure and can compromise data integrity.
    MessageDigest md = MessageDigest.getInstance("MD5"); // unsafe
  • Do opt for stronger hashing algorithms like SHA-256 to ensure data security.
    MessageDigest md = MessageDigest.getInstance("SHA-256");

References

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=java_lang_weak_hash_md5

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=java_lang_weak_hash_md5