-
Notifications
You must be signed in to change notification settings - Fork 77
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
bcrypt: reject passwords > 72 bytes #1389
Conversation
@@ -140,6 +140,8 @@ const problems = { | |||
|
|||
encodingNotSupported: problem(400.37, () => 'Encoding not supported.'), | |||
|
|||
passwordTooLong: problem(400.38, () => 'The password or passphrase provided exceeds the maximum length.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you thinking this is likely rare enough that we just leave a raw backend message (vs. introducing localizable frontend error messages)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the distinction? Should there be an accompanying PR for odk-central-frontend
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better approach would be to move max-length validation into lib/util/crypto.js.
But you're keeping it there for now because the short length validation is already there, right?
This looks good to me provided there are no surprises in the answers to the clarifying questions I've asked.
@ktuite @sadiqkhoja FYI in case you want to take another quick look.
What prompts this change? The datatype of password column is varchar(64), isn't that sufficient? |
We're not storing passwords in plaintext 😁 Also is there a reason for that column to be |
Yes. Maybe they should both be moved into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing I would like to add is the reason i.e. "bcrypt truncates input to 72 bytes before hashing" in the PR description or commit message for future reference.
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
This issue seems unrelated, but has been filed at #1407 |
What has been done to verify that this works as intended?
Manual testing - there are no existing tests for short passwords.
Why is this the best possible solution? Were any other approaches considered?
I think a better approach would be to move max-length validation into
lib/util/crypto.js
.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Should not affect existing users with very long passwords, but will prevent new passwords being saved with >72 bytes.
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
No - the docs do not currently mention any restrictions on password length.
Before submitting this PR, please make sure you have:
make test
and confirmed all checks still pass OR confirm CircleCI build passes