8000 Allow clear password over loopback connection. Fixes #1534 · mysql-net/MySqlConnector@9c242cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c242cc

Browse files
committed
Allow clear password over loopback connection. Fixes #1534
Assume that a localhost TCP connection isn't subject to a MITM attack and so it's OK to send a cleartext password. This allows the use of the Google Cloud SQL Auth Proxy, which runs on a local TCP port.
1 parent 4c2009f commit 9c242cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ private async Task<PayloadData> SwitchAuthenticationAsync(ConnectionSettings cs,
860860
return await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
861861

862862
case "mysql_clear_password":
863-
if (!m_isSecureConnection)
863+
if (!m_isSecureConnection && !m_isLoopbackConnection)
864864
{
865865
Log.NeedsSecureConnection(m_logger, Id, switchRequest.Name);
866866
throw new MySqlException(MySqlErrorCode.UnableToConnectToHost, $"Authentication method '{switchRequest.Name}' requires a secure connection.");
@@ -1302,6 +1302,7 @@ private async Task<bool> OpenTcpSocketAsync(ConnectionSettings cs, ILoadBalancer
13021302
m_socket.NoDelay = true;
13031303
m_stream = m_tcpClient.GetStream();
13041304
m_socket.SetKeepAlive(cs.Keepalive);
1305+
m_isLoopbackConnection = IPAddress.IsLoopback(ipAddress);
13051306
}
13061307
catch (ObjectDisposedException) when (cancellationToken.IsCancellationRequested)
13071308
{
@@ -2169,6 +2170,7 @@ protected override void OnStatementBegin(int index)
21692170
private IPayloadHandler? m_payloadHandler;
21702171
private CompressionMethod m_compressionMethod;
21712172
private bool m_isSecureConnection;
2173+
private bool m_isLoopbackConnection;
21722174
private bool m_supportsConnectionAttributes;
21732175
private bool m_supportsPipelining;
21742176
private CharacterSet m_characterSet;

0 commit comments

Comments
 (0)
0