Bug #17208 | SSL: client does not verify server certificate | ||
---|---|---|---|
Submitted: | 7 Feb 2006 22:16 | Modified: | 13 May 2006 5:05 |
Reporter: | Jorj Bauer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.18, 5.1-bk | OS: | |
Assigned to: | Magnus Blåudd | CPU Architecture: | Any |
[7 Feb 2006 22:16]
Jorj Bauer
[7 Feb 2006 22:21]
Jorj Bauer
In case it's not clear, this is a showstopper. From a security standpoint is means SSL is unusable.
[8 Feb 2006 14:58]
Hartmut Holzgraefe
Could you please attache the patch as a file to this bug report? The word wrapping applied to the text field during transmission corrupted it :(
[9 Feb 2006 9:53]
Jorj Bauer
diff in original report
Attachment: ssl-client-cert-check-patch3.diff (text/x-patch), 6.61 KiB.
[9 Feb 2006 9:54]
Jorj Bauer
added patch as a file.
[18 Feb 2006 14:33]
Nick Drake
At least related, if not the cause: in libmysqld/sql_acl.cpp access is not denied if the issuer and/or subject of the certificate mismatch. Starting line 853 of said file, + indicates lines need to be added. DBUG_PRINT("info",("checkpoint 2")); /* If X509 issuer is specified, we check it... */ if (acl_user->x509_issuer) { DBUG_PRINT("info",("checkpoint 3")); char *ptr = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); DBUG_PRINT("info",("comparing issuers: '%s' and '%s'", acl_user->x509_issuer, ptr)); if (strcmp(acl_user->x509_issuer, ptr)) { if (global_system_variables.log_warnings) sql_print_information("X509 issuer mismatch: should be '%s' " "but is '%s'", acl_user->x509_issuer, ptr); free(ptr); + user_access=NO_ACCESS; break; } user_access= acl_user->access; free(ptr); } DBUG_PRINT("info",("checkpoint 4")); /* X509 subject is specified, we check it .. */ if (acl_user->x509_subject) { char *ptr= X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); DBUG_PRINT("info",("comparing subjects: '%s' and '%s'", acl_user->x509_subject, ptr)); if (strcmp(acl_user->x509_subject,ptr)) { if (global_system_variables.log_warnings) sql_print_information("X509 subject mismatch: '%s' vs '%s'", acl_user->x509_subject, ptr); + user_access=NO_ACCESS; } else user_access= acl_user->access; free(ptr); }
[3 Mar 2006 13:01]
Domas Mituzas
Verified at ChangeSet@1.2214, 2006-03-03 11:16:56+01:00 Thanks for submitting these patches, MITM prevention should really exist.
[10 Mar 2006 11:36]
Magnus Blåudd
Investigating how the "client" could be made more secure.
[10 Mar 2006 11:38]
Magnus Blåudd
Checked the code form "sql_acl.cc" above and it starts the function with setting "user_access= NO_ACCESS" as the default. And unless it find's any valid grant's NO_ACCESS is what the function will return. If you are experiencing any problem, please let me know how to repeat it.
[18 Apr 2006 15:59]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/5091
[18 Apr 2006 16:48]
Chad MILLER
This now checks the Common Name in the cert against the name of the host we intended to connect to, which is good. I'm worried that we don't care about the authority of the certificate, as anyone can author a certificate to claim to be anything. I'd feel better if we also had a failing test for using a cert with the same "localhost" CN/hostname, where the cert is generated by a CA we do not trust.
[19 Apr 2006 14:42]
Chad MILLER
I see no problem with this patch, per se. Magnus is going to begin to get the other half of the security mechanism in place tomorrow.
[9 May 2006 9:41]
Magnus Blåudd
The tests for connecting to server with invalid certs etc: http://lists.mysql.com/commits/5876
[10 May 2006 7:52]
Magnus Blåudd
Pushed to 5.0.22
[12 May 2006 11:45]
Magnus Blåudd
Pushed to 5.1.11
[12 May 2006 11:46]
Magnus Blåudd
5.1 is now updated with the latest yaSSL patches.
[13 May 2006 5:05]
Paul DuBois
Noted in 5.0.22, 5.1.11 changelogs. Added the <option>--ssl-verify-server-cert</option> option to MySQL client programs. This option causes the server's Common Name value in its certificate to be verified against the hostname used when connecting to the server, and the connection is rejected if there is a mismatch. Added <literal>OPT_SSL_VERIFY_SERVER_CERT</literal> option for the <literal>mysql_options()</literal> C API function to enable this verification. This feature can be used to prevent man-in-the-middle attacks. Verification is disabled by default. Also updates SSL option section and description for mysql_options().
[13 May 2006 5:13]
Paul DuBois
Correction: The mysql_options() option name is MYSQL_OPT_SSL_VERIFY_SERVER_CERT.