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

In caching sha2 password xor, b length can be less than a. #1044

Closed
normano opened this issue Oct 23, 2019 · 6 comments
Closed

In caching sha2 password xor, b length can be less than a. #1044

normano opened this issue Oct 23, 2019 · 6 comments
Labels

Comments

@normano
Copy link
Contributor

normano commented Oct 23, 2019

You could use xorRotating func to fix:
https://github.com/normano/node-mysql2/blob/72aaf4a07680d26edb5ac6bb828027207e97e004/lib/auth_41.js#L137

@sidorares
Copy link
Owner

Good catch @normano !
I wonder if mysql server actually expects xor rotated this way. Are you able to test this scenario?
Scramble is usually 20 bytes, this means you need to create a user with > 20 char password to be able to test

@normano
Copy link
Contributor Author

normano commented Oct 24, 2019 via email

@normano
Copy link
Contributor Author

normano commented Oct 24, 2019 via email

@sidorares
Copy link
Owner

Thanks, do you want to create a PR with this change? Note that currently xor function is not shared between different auth plugins, maybe worth refactoring now

@sidorares
Copy link
Owner

I think this is only affects caching_sha2_password where seed is xored against password, in all 4.1 auth scenarios both arguments to xor are sha1 hashes exactly 32 bytes.

I can confirm that current code fails to login for a user with 01234567890123456789 ( or longer ) password and logs in no issues with rolling xor ( Mysql 8.0.17, caching_sha2_password default auth )

@normano
Copy link
Contributor Author

normano commented Oct 24, 2019

Just got home, I can pull in your changes and attempt to implement.

@normano normano mentioned this issue Oct 24, 2019
vlasky added a commit to vlasky/mysql that referenced this issue Apr 16, 2021
…ail for passwords longer than 19 characters.

Thanks to sidorares and normano for their guidance.

Refer to:

mysqljs#2233 (comment)
sidorares/node-mysql2#1044
sidorares/node-mysql2#1045

Updated version to 2.18.3
cavenator added a commit to cavenator/node-mysql2 that referenced this issue Jul 14, 2022
In short, replacing `xor` for `xorRotating` when authenticating passwords that are greater than 20 characters in length.  The original issue was first spotted in the auth_plugin `caching_sha2_password` but is also present in the `sha256_password` auth_plugin as well.

The link to the original issue (and fix) can be found here:  sidorares#1044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants