Skip to content

fix(mysql): repair caching_sha2_password fast-auth path#4245

Open
altmannmarcelo wants to merge 1 commit intolaunchbadge:mainfrom
altmannmarcelo:repair_caching_sha2_password_fast_path
Open

fix(mysql): repair caching_sha2_password fast-auth path#4245
altmannmarcelo wants to merge 1 commit intolaunchbadge:mainfrom
altmannmarcelo:repair_caching_sha2_password_fast_path

Conversation

@altmannmarcelo
Copy link
Copy Markdown

The client-side scramble mixed the SHA-256 inputs in the wrong order, so no spec-compliant MySQL server could validate it. Every connection fell through to perform_full_authentication and the plugin's cache was never exercised.

Two changes:

  1. scramble_sha256 now hashes as SHA256(SHA256(SHA256(pw)) || nonce) to match the server's generate_sha2_scramble. Adds a unit test that simulates the server's XOR verification.

  2. handle(..) returned true on fast_auth_success (0x01 0x03) without consuming the trailing OK_Packet, which then corrupted the next read. This was latent because 0x03 was never reached. It now yields back to the handshake loop so the OK is consumed by the existing 0x00 branch.

fixes #4244

The client-side scramble mixed the SHA-256 inputs in the wrong order, so
no spec-compliant MySQL server could validate it. Every connection fell
through to perform_full_authentication and the plugin's cache was never
exercised.

Two changes:

1. scramble_sha256 now hashes as SHA256(SHA256(SHA256(pw)) || nonce) to
   match the server's generate_sha2_scramble. Adds a unit test that
   simulates the server's XOR verification.

2. handle(..) returned true on fast_auth_success (0x01 0x03) without
   consuming the trailing OK_Packet, which then corrupted the next read.
   This was latent because 0x03 was never reached. It now yields back to
   the handshake loop so the OK is consumed by the existing 0x00 branch.

fixes launchbadge#4244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

caching_sha2_password fast-auth path is broken — every connection pays RSA cost it was designed to avoid

1 participant