Skip to content
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

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/model/query/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ update.audit = (user, data) => (log) => log('user.update', user.actor, { data: d
const updatePassword = (user, cleartext) => ({ run }) =>
(cleartext.length < 10
? reject(Problem.user.passwordTooShort())
: hashPassword(cleartext))
: Buffer.from(cleartext).length > 72
? reject(Problem.user.passwordTooLong())
: hashPassword(cleartext))
.then((hash) => run(sql`update users set password=${hash} where "actorId"=${user.actor.id}`));
updatePassword.audit = (user) => (log) => log('user.update', user.actor, { data: { password: true } });

Expand Down
2 changes: 2 additions & 0 deletions lib/util/problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
Copy link
Member

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)?

Copy link
Contributor Author

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?


// no detail information for security reasons.
authenticationFailed: problem(401.2, () => 'Could not authenticate with the provided credentials.'),

Expand Down