Skip to content

Commit b090994

Browse files
committed
Add comments about usage of TLS/SSL in connection establishment
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
1 parent 2ebbeb9 commit b090994

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

libmariadb/mariadb_lib.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,17 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
19511951

19521952
mysql->client_flag= client_flag;
19531953

1954+
/* Until run_plugin_auth has completed, the connection
1955+
* cannot have been secured with TLS/SSL.
1956+
*
1957+
* This means that any client which expects to use a
1958+
* TLS/SSL-secured connection SHOULD NOT trust any
1959+
* communication received from the server prior to this
1960+
* point as being genuine; nor should either the client
1961+
* or the server send any confidential information up
1962+
* to this point.
1963+
*/
1964+
19541965
if (run_plugin_auth(mysql, scramble_data, scramble_len,
19551966
scramble_plugin, db))
19561967
goto error;

plugins/auth/my_auth.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,19 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
321321
(mysql->client_flag & CLIENT_SSL))
322322
{
323323
/*
324-
Send mysql->client_flag, max_packet_size - unencrypted otherwise
325-
the server does not know we want to do SSL
324+
Send UNENCRYPTED "Login Request" packet with mysql->client_flag
325+
and max_packet_size, but no username; without this, the server
326+
does not know we want to switch to SSL/TLS
327+
328+
FIXME: Sending this packet is a very very VERY bad idea. It
329+
contains the client's preferred charset and flags in plaintext;
330+
this can be used for fingerprinting the client software version,
331+
and probable geographic location.
332+
333+
This offers a glaring opportunity for pervasive attackers to
334+
easily target, intercept, and exploit the client-server
335+
connection (e.g. "MITM all connections from known-vulnerable
336+
client versions originating from countries X, Y, and Z").
326337
*/
327338
if (ma_net_write(net, (unsigned char *)buff, (size_t) (end-buff)) || ma_net_flush(net))
328339
{
@@ -332,6 +343,9 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
332343
errno);
333344
goto error;
334345
}
346+
/* This is where the socket is actually converted from a plain
347+
* TCP/IP socket to a TLS/SSL-wrapped socket.
348+
*/
335349
if (ma_pvio_start_ssl(mysql->net.pvio))
336350
goto error;
337351
}

0 commit comments

Comments
 (0)