Skip to content

JS: Fix qhelp after file rename #12741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2023
Merged

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Apr 3, 2023

This broke in #12666 The qhelp probably needs a more substantial update, as an example has been added which is not referred to in the qhelp.

@jketema jketema requested a review from a team as a code owner April 3, 2023 07:28
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

QHelp previews:

javascript/ql/src/Security/CWE-916/InsufficientPasswordHash.qhelp

Use of password hash with insufficient computational effort

Storing cryptographic hashes of passwords is standard security practice, but it is equally important to select the right hashing scheme. If an attacker obtains the hashed passwords of an application, the password hashing scheme should still prevent the attacker from easily obtaining the original cleartext passwords.

A good password hashing scheme requires a computation that cannot be done efficiently. Standard hashing schemes, such as md5 or sha1, are efficiently computable, and are therefore not suitable for password hashing.

Recommendation

Use a secure password hashing scheme such as bcrypt, scrypt, PBKDF2, or Argon2.

Example

In the example below, the md5 algorithm computes the hash of a password.

const crypto = require("crypto");
function hashPassword(password) {
    var hasher = crypto.createHash('md5');
    var hashed = hasher.update(password).digest("hex"); // BAD
    return hashed;
}

This is not secure, since the password can be efficiently cracked by an attacker that obtains the hash. A more secure scheme is to hash the password with the bcrypt algorithm:

const bcrypt = require("bcrypt");
function hashPassword(password, salt) {
  var hashed = bcrypt.hashSync(password, salt); // GOOD
  return hashed;
}

References

Copy link
Contributor

@asgerf asgerf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jketema jketema merged commit ecf92f0 into github:main Apr 3, 2023
@jketema jketema deleted the js-qhelp-example-fix branch April 3, 2023 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants