Skip to content

Commit 11a6096

Browse files
committed
Disable weak authentication methods per default
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent 7c6e74b commit 11a6096

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/auth.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ static void _auth(xmpp_conn_t *conn)
833833

834834
/* SASL algorithm was tried, unset flag */
835835
conn->sasl_support &= ~scram_ctx->alg->mask;
836-
} else if (conn->sasl_support & SASL_MASK_DIGESTMD5) {
836+
} else if ((conn->sasl_support & SASL_MASK_DIGESTMD5) &&
837+
conn->weak_auth_enabled) {
837838
auth = _make_sasl_auth(conn, "DIGEST-MD5");
838839
if (!auth) {
839840
disconnect_mem_error(conn);
@@ -847,7 +848,8 @@ static void _auth(xmpp_conn_t *conn)
847848

848849
/* SASL DIGEST-MD5 was tried, unset flag */
849850
conn->sasl_support &= ~SASL_MASK_DIGESTMD5;
850-
} else if (conn->sasl_support & SASL_MASK_PLAIN) {
851+
} else if ((conn->sasl_support & SASL_MASK_PLAIN) &&
852+
conn->weak_auth_enabled) {
851853
auth = _make_sasl_auth(conn, "PLAIN");
852854
if (!auth) {
853855
disconnect_mem_error(conn);

src/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ struct _xmpp_conn_t {
232232
int sasl_support; /* if true, field is a bitfield of supported
233233
mechanisms */
234234
int auth_legacy_enabled;
235+
int weak_auth_enabled;
235236
int secured; /* set when stream is secured with TLS */
236237
xmpp_certfail_handler certfail_handler;
237238
xmpp_password_callback password_callback;

src/conn.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,8 @@ long xmpp_conn_get_flags(const xmpp_conn_t *conn)
11111111
XMPP_CONN_FLAG_LEGACY_SSL * conn->tls_legacy_ssl |
11121112
XMPP_CONN_FLAG_TRUST_TLS * conn->tls_trust |
11131113
XMPP_CONN_FLAG_DISABLE_SM * conn->sm_disable |
1114-
XMPP_CONN_FLAG_LEGACY_AUTH * conn->auth_legacy_enabled;
1114+
XMPP_CONN_FLAG_LEGACY_AUTH * conn->auth_legacy_enabled |
1115+
XMPP_CONN_FLAG_WEAK_AUTH * conn->weak_auth_enabled;
11151116

11161117
return flags;
11171118
}
@@ -1160,6 +1161,7 @@ int xmpp_conn_set_flags(xmpp_conn_t *conn, long flags)
11601161
conn->tls_trust = (flags & XMPP_CONN_FLAG_TRUST_TLS) ? 1 : 0;
11611162
conn->auth_legacy_enabled = (flags & XMPP_CONN_FLAG_LEGACY_AUTH) ? 1 : 0;
11621163
conn->sm_disable = (flags & XMPP_CONN_FLAG_DISABLE_SM) ? 1 : 0;
1164+
conn->weak_auth_enabled = (flags & XMPP_CONN_FLAG_WEAK_AUTH) ? 1 : 0;
11631165

11641166
return 0;
11651167
}

strophe.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ typedef struct _xmpp_sm_t xmpp_sm_state_t;
191191
* Disable Stream-Management XEP-0198.
192192
*/
193193
#define XMPP_CONN_FLAG_DISABLE_SM (1UL << 5)
194+
/** @def XMPP_CONN_FLAG_WEAK_AUTH
195+
* Allow weak authentication methods (DIGEST-MD5 and PLAIN).
196+
*/
197+
#define XMPP_CONN_FLAG_WEAK_AUTH (1UL << 6)
194198

195199
/* connect callback */
196200
typedef enum {

0 commit comments

Comments
 (0)