Repository navigation
Conversation
morrisonlevi
left a comment
There was a problem hiding this comment.
The code looks okay but... how would we test it to be sure?
4d5c8c9 to
c910401
Compare
|
Added a regression test (a |
2310856 to
d844a6d
Compare
|
@bukka I leave it up to you to decide on this. It's basically identical to my PR. I don't actually know if it fixes anything or just swaps one error message for another. |
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.
|
It does fix a heap over-read; the old test just never reached it, since without a public key the XOR doesn't run. With a key and a longer password, valgrind on the unpatched build reports an invalid read in |
d844a6d to
1ebfb1f
Compare
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.