Usage of weak hashing library (SHA-1)
- Rule ID: javascript_lang_weak_hash_sha1
- Languages: javascript
- Source: weak_hash_sha1.yml
Description
Using a weak hashing library like SHA-1 increases the risk of data breaches. SHA-1 in particular 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. It's no longer considered secure against well-funded attackers.
const hash = crypto.createHmac("sha1", key).update(user.password); // unsafe
- Do use stronger hashing algorithms like SHA-256 or SHA-3 for enhanced security.
const hash = crypto.createHmac("sha256", key).update(user.password);
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=javascript_lang_weak_hash_sha1
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=javascript_lang_weak_hash_sha1