|
|
6611fc |
commit 26dcfb2d7176b78e70757aa5d01951a28ca217c7
|
|
|
6611fc |
Author: Alexey Melnikov <alexey.melnikov@isode.com>
|
|
|
6611fc |
Date: Fri Jul 5 16:37:59 2013 +0100
|
|
|
6611fc |
|
|
|
6611fc |
Treat SCRAM-SHA-1/DIGEST-MD5 as more secure than PLAIN when selecting the best client side SASL mechanism
|
|
|
6611fc |
|
|
|
6611fc |
Both SCRAM-SHA-1 & DIGEST-MD5 are lacking SASL_SEC_PASS_CREDENTIALS security
|
|
|
6611fc |
flag, which prevented them from being chosen over PLAIN when PLAIN is selected
|
|
|
6611fc |
as the best mechanism first. For example the problem can be observed when
|
|
|
6611fc |
the server advertises "PLAIN DIGEST-MD5 SCRAM-SHA-1" (PLAIN just has to be
|
|
|
6611fc |
returned before SCRAM/DIGEST.)
|
|
|
6611fc |
|
|
|
6611fc |
Cyrus SASL bug # 3793
|
|
|
6611fc |
|
|
|
6611fc |
diff --git a/lib/client.c b/lib/client.c
|
|
|
6611fc |
index 62dfb0b..31fe346 100644
|
|
|
6611fc |
--- a/lib/client.c
|
|
|
6611fc |
+++ b/lib/client.c
|
|
|
6611fc |
@@ -658,6 +658,20 @@ _sasl_cbinding_disp(sasl_client_params_t *cparams,
|
|
|
6611fc |
return SASL_OK;
|
|
|
6611fc |
}
|
|
|
6611fc |
|
|
|
6611fc |
+static int
|
|
|
6611fc |
+_sasl_are_current_security_flags_worse_then_best(unsigned best_security_flags,
|
|
|
6611fc |
+ unsigned current_security_flags)
|
|
|
6611fc |
+{
|
|
|
6611fc |
+ /* We don't qualify SASL_SEC_PASS_CREDENTIALS as "secure" flag */
|
|
|
6611fc |
+ best_security_flags &= ~SASL_SEC_PASS_CREDENTIALS;
|
|
|
6611fc |
+
|
|
|
6611fc |
+ if ((current_security_flags ^ best_security_flags) & best_security_flags) {
|
|
|
6611fc |
+ return 1;
|
|
|
6611fc |
+ } else {
|
|
|
6611fc |
+ return 0;
|
|
|
6611fc |
+ }
|
|
|
6611fc |
+}
|
|
|
6611fc |
+
|
|
|
6611fc |
/* select a mechanism for a connection
|
|
|
6611fc |
* mechlist -- mechanisms server has available (punctuation ignored)
|
|
|
6611fc |
* secret -- optional secret from previous session
|
|
|
6611fc |
@@ -823,8 +837,9 @@ int sasl_client_start(sasl_conn_t *conn,
|
|
|
6611fc |
*/
|
|
|
6611fc |
|
|
|
6611fc |
if (bestm &&
|
|
|
6611fc |
- ((m->m.plug->security_flags ^ bestm->m.plug->security_flags) &
|
|
|
6611fc |
- bestm->m.plug->security_flags)) {
|
|
|
6611fc |
+ _sasl_are_current_security_flags_worse_then_best(
|
|
|
6611fc |
+ bestm->m.plug->security_flags,
|
|
|
6611fc |
+ m->m.plug->security_flags)) {
|
|
|
6611fc |
break;
|
|
|
6611fc |
}
|
|
|
6611fc |
|