Skip to content

Guard against short server scramble in sha256_password auth#22356

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix-mysqlnd-sha256-scramble
Open

Guard against short server scramble in sha256_password auth#22356
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix-mysqlnd-sha256-scramble

Conversation

@iliaal

@iliaal iliaal commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

mysqlnd_sha256_auth_get_auth_data() XORs SCRAMBLE_LENGTH (20) bytes of the server-supplied scramble into the password without checking the scramble is at least that long, unlike the native and caching_sha2 plugins which reject a short scramble with CR_MALFORMED_PACKET. A server reporting a scramble shorter than 20 bytes shrinks the heap buffer the scramble is copied into, so the XOR reads past it. Add the same length guard the sibling plugins use.

mysqlnd_sha256_auth_get_auth_data() XORs SCRAMBLE_LENGTH bytes of the
server-supplied scramble into the password without checking the scramble
is at least that long, unlike the native and caching_sha2 plugins which
reject a short scramble with CR_MALFORMED_PACKET. A server reporting a
scramble shorter than 20 bytes shrinks the heap buffer the scramble is
copied into, so the XOR reads past it. Add the same length guard the
sibling plugins use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant