Usage of weak hashing library on a password (Argon2)
- Rule ID: javascript_lang_weak_password_hash_argon2
- Languages: javascript
- Source: weak_password_hash_argon2.yml
Description
Choosing a weak hashing algorithm for passwords compromises security. Argon2 has three variants: Argon2i, Argon2d, and Argon2id. Argon2id is the strongest and most recommended for password hashing because of its balanced resistance against both side-channel and GPU attack vectors.
Remediations
- Do not override the Argon2 type when implementing the Argon2 hashing library. Using Argon2id ensures the highest level of security for password storage.
const argon2 = require("argon2");
const hash = await argon2.hash(req.params.password, { type: argon2.argon2i }) // unsafe - Do rely on the default Argon2 type - Argon2id as it is the most secure.
const argon2 = require("argon2");
const hash = await argon2.hash(req.params.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_password_hash_argon2
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=javascript_lang_weak_password_hash_argon2