-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulnerable to CVE-2015-3152 when using TLS with mysql 5.5/5.6 client libs #98
Comments
Thank you for this report. I'll fix it (PR is welcome). But I'm waiting Oracle releases new MySQL Connector/C which support VC14 (for Python 3.5) |
I've had a quick unsuccessful attempt at a fix, however I'm not convinced the backported libmysqlclient changes are complete enough to solve this. Whilst I could be missing the obvious of course! Workarounds in the meantime (Edited to add some more options):
I'm still working on a Heroku-compatible version of (2), since lack of sudo means the libraries have to be installed to a non-standard location, and thus mean fiddling about with library/include path manipulation. |
You can use new libmysqlclient without sudo. And you can use PyMySQL instead. |
Hmm - the mysql version numbers in the MySQL Connector Python source had me misled - '50711' is actually 5.7 not 5.0.7. In addition, whilst my initial rummaging through the libmysqlclient 5.5/5.6 source had seen references to the backported mysql 5.7 options we need (like enforcing TLS) - only the command line client supports them (docs) and not the C API (docs). I'd naively presumed there would be parity between the two... sigh. As such:
Things that mysqlclient-python can do in the meantime:
|
Hmm sadly this workaround doesn't even help - since it turns out Connector/C 6.1.6 (the latest available) is based on the older mysql 5.7.5/5.7.6 which doesn't include the "default to enforced TLS" changes we're after. I've filed a bug against mysql requesting they create a newer release: |
Unlike HTTP, MySQL is commonly used in controlled network (LAN or VPN). So I won't do the (3). If this vulnerability is so important, linux distros must security upgrade |
There are nothing about this library can do for this issue. |
Since the comments above, Oracle have released new versions of libmysqlclient that add support to They posted this as an update to MySQL ticket 82383, however it's still marked as private even though I've asked several times for it to be opened up. They also didn't credit me for the reporting the issue either, sigh. Anyway - as such, I think there is now a way to implement this here? |
Oracle doesn't provide macro like "HAVE_MYSQL_OPT_SSL_MODE". You can pass it via |
If you can write proper I'm very busy in this year and I have no motivation for hacking on such thing. |
Makes sense - similarly I won't have the time to look into this further. We've since updated to MySQL 5.7 and moved on :-) |
tl;dr: mysql 5.5/5.6 client libraries have unfortunate defaults which means TLS connections can be silently man-in-the-middled - so if mysqlclient-python is used with them, is vulnerable to CVE-2015-3152.
With mysql client libraries < v5.7, if a CA certificate is specified, the client neither requires TLS/SSL, nor actually checks the CA certificate matches the hostname. This means that if the connection is MITMed and redirected to malicious mysql server instance that pretends to not support TLS, it proceeds anyway, silently leaking credentials (if using username/password rather than client cert/key).
For example when using:
And then running:
Expected:
Some kind of TLS error.
Actual:
...ie our credentials were just sent in plaintext.
This means anyone can MITM a connection to eg an Amazon RDS instance from a local dev's machine (or say Heroku, where we can't set up a VPC with the RDS instance) running mysql 5.5/5.6 client libraries, and the client will be none the wiser. Note this also affects the command line mysql client too (see: http://bugs.mysql.com/bug.php?id=79862).
Thankfully this has been fixed in mysql 5.7 (ie if a CA certificate is specified it defaults to enforcing TLS and that the cert matches the hostname; see here), however we can't easily use mysql 5.7 on Ubuntu 14.04 on Heroku/Travis/....
As for mysql 5.5/5.6, recent point releases (specifically 5.5.49 and 5.6.30) have added opt-in support for enforcing TLS/CA cert verification, however neither mysqlclient-python nor MySQLdb support enabling these.Edit: It turns out the backported libmysqlclient 5.5/5.6 fixes are insufficient to solve this after all - there's no way mysqlclient-python can be securely used with them...
Whilst recent point releases of MySQL 5.5/5.6's libmysqlclient (specifically 5.5.49 and 5.6.30) have added opt-in support for verifying the CA certificate (using
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
):(a) neither mysqlclient-python nor MySQLdb currently support enabling it (though there is a PR open against MySQLdb to add it: farcepest/MySQLdb1#100)
(b) even with this option enabled, if the remote server pretends to not support TLS, then the connection can be silently downgraded to non-TLS (the "enforce TLS" options from 5.7 were only backported for the command line mysql client and not the C API)
Oracle's own MySQL Python connector does support (a) (by passing
ssl_verify_cert=True
), however is still vulnerable to (b). I've filed an upstream MySQL bug requesting further libmysqlclient 5.5/5.6 backports of the 5.7 fixes.As such at the moment, there is no secure way to use mysqlclient-python, MySQLdb or MySQL Connector Python with libmysqlclient 5.5/5.6.
See also:
https://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
https://dev.mysql.com/doc/refman/5.6/en/mysql-options.html
http://www.ocert.org/advisories/ocert-2015-003.html
https://mariadb.org/information-on-the-ssl-connection-vulnerability-of-mysql-and-mariadb-2/
The text was updated successfully, but these errors were encountered: