-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace bcrypt with scrypt #1274
Comments
Scrypt has been my go-to key derivation algorithm since I read Colin Percival's paper on "Stronger Key Derivation Via Sequential Memory-Hard Functions" (check it out here if you're a math geek like me). Scrypt is awesome because it makes brute-force attackers pay penalties both in CPU and in memory usage. Plus, it has a higher theoretical-safety-to-compute-time factor than bcrypt.
An article by IRCMaxel pointed out this weakness. While I DO NOT agree with his assessment that scrypt should not used for password storage, his analysis is spot on. Care must be taken with the settings we use to ensure we take advantage of the time-memory trade-off factor offered by scrypt. Properly configured scrypt can be more secure that bcrypt. @morenoh149, I'm very pro scrypt. I'm wondering, though, what is your motivation behind the suggested change? Is it simply to improve security? Is it an attempt to improve speed, in response to issue #1237? |
I read that blog post today 🐲 Looks like you'd want |
@morenoh149, What is your motivation behind the suggested change though? Is it simply to improve security? Is it an attempt to improve speed, in response to issue #1237? I'm just curious. |
Improve security. I reread issue #1237 . If your concern is the impact it would have on keystone installation it'd just require an extra step to install OpenSSL on windows machines. https://github.com/barrysteyn/node-scrypt#installation-instructions |
@morenoh149 are you willing to make a PR? |
@dcousens the code change itself is trivial. The complicated part is how to deal with existing keystone sites. Greenfield sites wouldn't have issues. But there must be an upgrade path for existing sites. I imagine the only way is to prompt all users to reenter their password and then scrypt encrypt it. |
@morenoh149 is right about needing an upgrade path. I don't see prompting users to re-enter their passwords as a direction we can enforce at a framework level. I think the right solution here is to give developers the option to select either by setting an option on the e.g
We would (for now, at least) default to (p.s I'm open to suggestions other than |
Its a key stretching algorithm, but I guess just And I guess the upgrade path could just be (pseudo-code): var latestAndGreatest = 'scrypt'
function auth(user, password, callback) {
// ...
User.findOne(user, function(err, data) {
if (err) return callback(err)
var storedPassword = data.password.value
var storedAlgorithm = data.password.algorithm
var stretchFn = algorithms[storedAlgorithm]
var verified = (storedPassword === stretchFn(password))
// update storage with new algorithm if necessary
if (storedAlgorithm !== latestAndGreatest) {
var wantedStretchFn = algorithms[latestAndGreatest]
user.password = new Password({
value: wantedStretchFn(password),
algorithm: latestAndGreatest
})
user.save(function(err) {
if (err) return callback(err)
callback(null, verified)
})
// we must have already updated this, continue as normal
} else {
callback(null, verified)
}
})
} |
In the upgrade case, that could be an easy way to allow for upgrades without asking users for their passwords as an extra-curricular activity; while still providing you the ability to do a call-out to non-upgraded users after some time period if you feel the threat level is high enough. |
We could publish a reference implementation for anyone who wants to do a migration using the method you suggest @dcousens, based on the yeoman generated structure. |
re |
How 'bout |
Happy for a PR implementing this option as described above, by the way. |
I don't think there is any scientific consensus that any of |
Keystone 4 is going in maintenance mode. Expect no major change. see #4913 for details. |
Re http://chargen.matasano.com/chargen/2015/3/26/enough-with-the-salts-updates-on-secure-password-schemes.html
Use https://github.com/barrysteyn/node-scrypt Not sure if this requires an upgrade path for existing hashes using bcrypt @JedWatson please advise. But I definitely think its the right default for new projects.
The text was updated successfully, but these errors were encountered: