-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reject password inputs looking like raw bcrypt #9
Conversation
If a password arrives in the authorization header as a string looking like bcrypt (according to standard Modular Crypt Format) instead of normal-looking plain-text, then reject the authentication. This is to avoid being able to pass the crypted version of the password, in case it was leaked.
test.sh
Outdated
|
||
test=$( | ||
cat <<'EOF' | node ./index.js http-basic-auth --realm='"node-red"' --username='"test"' --password='"$2y$10$5TSZDldoJ7MxDZdtK/SG2O3cwORqLDhHabYlKX9OsM.W/Z/oLwKW6"' | ||
{"req":{"headers":{"authorization":"Basic dGVzdDokMnkkMTAkNVRTWkRsZG9KN014RFpkdEsvU0cyTzNjd09ScUxEaEhhYllsS1g5T3NNLlcvWi9vTHdLVzY="}}} |
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.
It might be less opaque if the test input isn't hardcoded in base64 but just calls the base64
command as a subshell or using a variable.
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.
Good idea. Here you are c6842f5
* Is the password matching the Modular Crypt Format of bcrypt | ||
*/ | ||
function isBcryptMcf(hash) { | ||
return (typeof hash === 'string') && hash.match(/^\$2[abxy]?\$/); |
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.
While unlikely, we now reject some passwords if they match that regex. While unlikely, it might be an issue for some esoteric password generators.
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.
Yes indeed. There is the same behaviour in e.g. Apache htpasswd approach, which I try to be compatible with
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.
That would probably be the better solution then
If a password arrives in the authorization header as a string looking like bcrypt (according to standard Modular Crypt Format) instead of normal-looking plain-text, then reject the authentication.
This is to avoid being able to pass the crypted version of the password, in case it was leaked.