-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(sql): correct byte order in MySQL caching_sha2_password auth #26196
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
base: main
Are you sure you want to change the base?
Conversation
The caching_sha2_password scramble function was concatenating bytes in the wrong order when computing SHA256(SHA256(SHA256(password)) + nonce). The MySQL protocol requires SHA256(digest2 || nonce), but the code was computing SHA256(nonce || digest2), causing "Access denied" errors for users on MySQL 8.0+ with caching_sha2_password authentication. Fixes #26195 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Updated 8:34 AM PT - Jan 17th, 2026
❌ Your commit
🧪 To try this PR locally: bunx bun-pr 26196That installs a local version of the PR into your bun-26196 --bun |
WalkthroughFixes MySQL 8.0 caching_sha2_password authentication by changing the concatenation order in the scramble routine so the second digest is copied before the nonce, and adds a regression test verifying caching_sha2_password logins against a containerized MySQL instance. Changes
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/regression/issue/26195.test.ts`:
- Around line 21-28: The test double-closes the SQL instance: when using the
"await using sql = new SQL(...)" pattern the resource is automatically disposed
at scope end, so remove the explicit "await sql.end()" calls (references:
variable "sql" and method "end()" in this test) and rely on "await using" only;
update the other occurrences that match the same pattern (the blocks around
lines with the same pattern, e.g., the sections noted 33-42 and 45-48) to avoid
calling "end()" after "await using".
The `await using` syntax automatically disposes resources at scope end, making explicit `await sql.end()` calls unnecessary. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
caching_sha2_passwordscramble functionSHA256(nonce || digest2)toSHA256(digest2 || nonce)per MySQL protocolTest plan
test/regression/issue/26195.test.tsthat testscaching_sha2_passwordauthentication on MySQL 8.0+caching_sha2_passwordby default) with both empty password and password-protected usersFixes #26195
🤖 Generated with Claude Code