In my previous blog post I told you to use SSL/TLS to secure your MySQL network connections. So I followed my advice and did enable SSL. Great!
So first let's quickly verify that everything is working.
So you enabled SSL with
mysql_ssl_rsa_setup, used a OpenSSL based build or put
ssl-ca in the mysqld section of your /etc/my.cnf and now
show global variables like 'have_SSL'; returns 'YES'.
And you have configured the client with
show global status like 'Ssl_cipher'; indicates the session is indeed secured.
You could also dump traffic and it looks 'encrypted' (i.e. not readable)...
With SSL enabled everything should be safe isn't it?
The handshake which MySQL uses always starts unsecured and is upgraded to secured if both the client and server have the SSL flag set. This is very similar to STARTTLS as used in the SMTP protocol.
To attach this we need an active attack; we need to actually sit in between the client and the server and modify packets.
Then we modify the flags sent from the server to the client to have the SSL flag disabled. This is called SSL stripping.
Because the client thinks the server doesn't support SSL the connection is not upgraded and continues in clear text.
An example can be found in the
Once the SSL layer is stripped from the connection an attacker can see your queries and resultsets again as described before.
To protect against this attack:
- Set REQUIRE SSL on accounts which should never use unencrypted connections.
- On the client use
--ssl-mode=REQUIREDto force the use of SSL. This is available since 5.6.30 / 5.7 11.
- For older clients: Check the
Ssl_cipherstatus variable and exit if it is empty.