Usage of weak hashing library on a password (SHA-1)
- Rule ID: java_lang_weak_password_hash_sha1
- Languages: java
- Source: weak_password_hash_sha1.yml
Description
Using a weak hashing library like SHA-1 for passwords increases the risk of data breaches. SHA-1 is vulnerable to collision attacks, where two different inputs can produce the same hash value, compromising data integrity and security.
Remediations
- Do not use SHA-1 for hashing passwords or sensitive data due to its vulnerabilities.
MessageDigest md = MessageDigest.getInstance("SHA-1");
- Do opt for stronger hashing algorithms such as SHA-256 to enhance 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_password_hash_sha1
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=java_lang_weak_password_hash_sha1