-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Failing to strip null terminator from authData in case of AuthSwitchRequest causes Access denied #1666
Comments
Is there evidence that it is not an RDS Proxy problem but a problem with this driver? auth data is terminated by EOF, not NUL. |
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
We recently promoted to RDS MySQL 8 in AWS and got the following error:
Error 1045 (28000): Access denied for user 'username'@'10.XXX.XXX.XXX' (using password: YES)
It all started because of this recent change in AWS: https://aws.amazon.com/about-aws/whats-new/2024/12/amazon-rds-proxy-sha2-password-authentication-mysql-aurora-rds// . Apparently, connecting to RDS via a proxy now tries to promote the plugin to
caching_sha2_password
.Our Java apps connect successfully. Also,
mysql
from CLI connects succesfully.So this is what happens in code:
mysql_native_password
.[254 99 97 99 104 105 110 103 95 115 104 97 50 95 112 97 115 115 119 111 114 100 0 3 67 113 67 11 105 47 18 75 27 28 34 37 111 81 43 44 102 83 43 0]
. Let's analyze what you do with this packet in the following methodmysql/packets.go
Line 485 in 85c6311
case iEOF
. The first null terminated string, is[99 97 99 104 105 110 103 95 115 104 97 50 95 112 97 115 115 119 111 114 100 0]
which translates tocaching_sha2_password
. So the server is trying to promote us tocaching_sha2_password
as expected. TheauthData
which is later used to scramble the SHA256 is the rest of the packet, however you are forgetting to strip the null termination from it. The current code is:which in our case is
[3 67 113 67 11 105 47 18 75 27 28 34 37 111 81 43 44 102 83 43 0]
- i.e., null terminated.For testing purposes, I stripped the 0 from the end, by changing it to:
and now the client connects successfully and performs the queries without Access denied.
Thanks
The text was updated successfully, but these errors were encountered: