-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
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. |
|
DennisRasey
pushed a commit
to DennisRasey/forgejo
that referenced
this issue
Mar 22, 2025
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | require | minor | `v1.8.1` -> `v1.9.1` | --- ### Release Notes <details> <summary>go-sql-driver/mysql (github.com/go-sql-driver/mysql)</summary> ### [`v1.9.1`](https://github.com/go-sql-driver/mysql/blob/HEAD/CHANGELOG.md#v191-2025-03-21) [Compare Source](go-sql-driver/mysql@v1.9.0...v1.9.1) ##### Major Changes - Add Charset() option. ([#​1679](go-sql-driver/mysql#1679)) ##### Bugfixes - go.mod: fix go version format ([#​1682](go-sql-driver/mysql#1682)) - Fix FormatDSN missing ConnectionAttributes ([#​1619](go-sql-driver/mysql#1619)) ### [`v1.9.0`](https://github.com/go-sql-driver/mysql/blob/HEAD/CHANGELOG.md#v190-2025-02-18) [Compare Source](go-sql-driver/mysql@v1.8.1...v1.9.0) ##### Major Changes - Implement zlib compression. ([#​1487](go-sql-driver/mysql#1487)) - Supported Go version is updated to Go 1.21+. ([#​1639](go-sql-driver/mysql#1639)) - Add support for VECTOR type introduced in MySQL 9.0. ([#​1609](go-sql-driver/mysql#1609)) - Config object can have custom dial function. ([#​1527](go-sql-driver/mysql#1527)) ##### Bugfixes - Fix auth errors when username/password are too long. ([#​1625](go-sql-driver/mysql#1625)) - Check if MySQL supports CLIENT_CONNECT_ATTRS before sending client attributes. ([#​1640](go-sql-driver/mysql#1640)) - Fix auth switch request handling. ([#​1666](go-sql-driver/mysql#1666)) ##### Other changes - Add "filename:line" prefix to log in go-mysql. Custom loggers now show it. ([#​1589](go-sql-driver/mysql#1589)) - Improve error handling. It reduces the "busy buffer" errors. ([#​1595](go-sql-driver/mysql#1595), [#​1601](go-sql-driver/mysql#1601), [#​1641](go-sql-driver/mysql#1641)) - Use `strconv.Atoi` to parse max_allowed_packet. ([#​1661](go-sql-driver/mysql#1661)) - `rejectReadOnly` option now handles ER_READ_ONLY_MODE (1290) error too. ([#​1660](go-sql-driver/mysql#1660)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIwNS4xIiwidGFyZ2V0QnJhbmNoIjoiZm9yZ2VqbyIsImxhYmVscyI6WyJkZXBlbmRlbmN5LXVwZ3JhZGUiLCJ0ZXN0L25vdC1uZWVkZWQiXX0=--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7293 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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: