[php-src] PR #22262: bound auth plugin name read to packet size in mysqlnd

From: Date: Tue, 09 Jun 2026 10:51:28 +0000
Subject: [php-src] PR #22262: bound auth plugin name read to packet size in mysqlnd
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36352@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22262 Author: alhudz Repro: a malicious or compromised MySQL server sends a 0xFE AuthSwitchRequest whose plugin-name field has no \0 inside the packet body. Cause: the 0xFE branches of php_mysqlnd_auth_response_read, php_mysqlnd_chg_user_read and php_mysqlnd_cached_sha2_result_read read the name with an unbounded mnd_pestrdup((char *)p), then do p += strlen(name) + 1. cmd_buffer is a large reusable buffer, so when the name is not \0-terminated within the packet the copy walks past header.size into stale bytes and p overshoots the packet end. new_auth_protocol_data_len = header.size - (size_t)(p - buf) then underflows to a huge size_t, which is passed straight to mnd_emalloc() and memcpy(), reading out of bounds. Fix: bound the name to the remaining packet bytes with memchr + mnd_pestrndup so p can never pass header.size. This is the same guard php_mysqlnd_greet_read already uses for the auth plugin name and the OK-packet branch uses for its message.

« previous php.git-pulls (#36352) next »