Skip to content

Commit fab383a

Browse files
committed
Use after free in authentication
1 parent a52c46e commit fab383a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

mysql-test/r/connect_debug.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set @old_dbug=@@global.debug_dbug;
2+
set global debug_dbug='+d,auth_disconnect';
3+
create user 'bad' identified by 'worse';
4+
set global debug_dbug=@old_dbug;
5+
drop user bad;

mysql-test/t/connect_debug.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
source include/have_debug.inc;
2+
set @old_dbug=@@global.debug_dbug;
3+
4+
#
5+
# use after free if need plugin change and auth aborted
6+
#
7+
set global debug_dbug='+d,auth_disconnect';
8+
create user 'bad' identified by 'worse';
9+
--error 1
10+
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse
11+
set global debug_dbug=@old_dbug;
12+
drop user bad;

sql-common/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,7 +2742,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf)
27422742
*buf= mysql->net.read_pos;
27432743

27442744
/* was it a request to change plugins ? */
2745-
if (**buf == 254)
2745+
if (pkt_len == packet_error || **buf == 254)
27462746
return (int)packet_error; /* if yes, this plugin shan't continue */
27472747

27482748
/*
@@ -2927,7 +2927,7 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
29272927

29282928
compile_time_assert(CR_OK == -1);
29292929
compile_time_assert(CR_ERROR == 0);
2930-
if (res > CR_OK && mysql->net.read_pos[0] != 254)
2930+
if (res > CR_OK && (mysql->net.last_errno || mysql->net.read_pos[0] != 254))
29312931
{
29322932
/*
29332933
the plugin returned an error. write it down in mysql,

sql/sql_acl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8217,6 +8217,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
82178217
const char *client_auth_plugin=
82188218
((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin;
82198219

8220+
DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); });
82208221
DBUG_ASSERT(client_auth_plugin);
82218222

82228223
/*

0 commit comments

Comments
 (0)