-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-38431: [10.6] auth switch with long password corrupts database name #4509
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
Merged
+108
−8
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # | ||
| # Setup | ||
| # | ||
| INSTALL PLUGIN IF NOT EXISTS cleartext_plugin_server SONAME ''; | ||
| Warnings: | ||
| Note 1968 Plugin 'cleartext_plugin_server' already installed | ||
| CREATE DATABASE mdev38431_db; | ||
| # | ||
| # Test 1: Short password - baseline test | ||
| # | ||
| CREATE USER shortuser IDENTIFIED VIA cleartext_plugin_server USING 'secret'; | ||
| GRANT ALL ON *.* TO shortuser; | ||
| db | ||
| mdev38431_db | ||
| # | ||
| # Test 2: Long password 260 bytes (triggers 3-byte LENENC) | ||
| # Before fix: ERROR 1044 Access denied to database 'X' (garbage char) | ||
| # After fix: Connects to mdev38431_db correctly | ||
| # | ||
| CREATE USER longuser IDENTIFIED VIA cleartext_plugin_server USING 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; | ||
| GRANT ALL ON *.* TO longuser; | ||
| db | ||
| mdev38431_db | ||
| # | ||
| # Test 3: Even longer password 500 bytes | ||
| # | ||
| CREATE USER verylonguser IDENTIFIED VIA cleartext_plugin_server USING 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'; | ||
| GRANT ALL ON *.* TO verylonguser; | ||
| db | ||
| mdev38431_db | ||
| # | ||
| # Cleanup | ||
| # | ||
| DROP USER shortuser, longuser, verylonguser; | ||
| DROP DATABASE mdev38431_db; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # | ||
| # MDEV-38431: Auth Switch with Long Password Corrupts Database Name | ||
| # | ||
| # When password >= 251 bytes with CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA, | ||
| # the length is encoded in 3 bytes (0xFC + 2 bytes). The server incorrectly | ||
| # calculated the database pointer, causing connection to wrong database. | ||
| # | ||
| # Fix: Use 'passwd + passwd_len' instead of 'db + passwd_len + 1' | ||
| # | ||
|
|
||
| --source include/not_embedded.inc | ||
| --source include/have_plugin_auth.inc | ||
|
|
||
| --echo # | ||
| --echo # Setup | ||
| --echo # | ||
| eval INSTALL PLUGIN IF NOT EXISTS cleartext_plugin_server SONAME '$PLUGIN_AUTH'; | ||
| CREATE DATABASE mdev38431_db; | ||
|
|
||
| --echo # | ||
| --echo # Test 1: Short password - baseline test | ||
| --echo # | ||
| CREATE USER shortuser IDENTIFIED VIA cleartext_plugin_server USING 'secret'; | ||
| GRANT ALL ON *.* TO shortuser; | ||
|
|
||
| # Connect with short password and verify database | ||
| --exec $MYSQL -h 127.0.0.1 -P $MASTER_MYPORT --default-auth=mysql_clear_password -u shortuser -p"secret" --database=mdev38431_db -e "SELECT DATABASE() AS db" | ||
|
|
||
| --echo # | ||
| --echo # Test 2: Long password 260 bytes (triggers 3-byte LENENC) | ||
| --echo # Before fix: ERROR 1044 Access denied to database 'X' (garbage char) | ||
| --echo # After fix: Connects to mdev38431_db correctly | ||
| --echo # | ||
|
|
||
| # Create password with 260 'a' characters | ||
| --let $long_pwd=`SELECT REPEAT('a', 260)` | ||
| eval CREATE USER longuser IDENTIFIED VIA cleartext_plugin_server USING '$long_pwd'; | ||
| GRANT ALL ON *.* TO longuser; | ||
|
|
||
| # This connection uses --default-auth=mysql_clear_password to trigger auth switch | ||
| # With a password >= 251 bytes, the client sends password length in 3-byte format | ||
| # The bug caused the server to read database name from wrong offset | ||
| --exec $MYSQL -h 127.0.0.1 -P $MASTER_MYPORT --default-auth=mysql_clear_password -u longuser -p"$long_pwd" --database=mdev38431_db -e "SELECT DATABASE() AS db" | ||
|
|
||
| --echo # | ||
| --echo # Test 3: Even longer password 500 bytes | ||
| --echo # | ||
| --let $very_long_pwd=`SELECT REPEAT('b', 500)` | ||
| eval CREATE USER verylonguser IDENTIFIED VIA cleartext_plugin_server USING '$very_long_pwd'; | ||
| GRANT ALL ON *.* TO verylonguser; | ||
|
|
||
| --exec $MYSQL -h 127.0.0.1 -P $MASTER_MYPORT --default-auth=mysql_clear_password -u verylonguser -p"$very_long_pwd" --database=mdev38431_db -e "SELECT DATABASE() AS db" | ||
|
|
||
| --echo # | ||
| --echo # Cleanup | ||
| --echo # | ||
| DROP USER shortuser, longuser, verylonguser; | ||
| DROP DATABASE mdev38431_db; | ||
| # Note: Do not uninstall cleartext_plugin_server as it was pre-loaded by MTR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.