Skip to content

Commit 4ccd7e5

Browse files
committed
Disable weak authentication methods per default
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent 47a4873 commit 4ccd7e5

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
@@ -827,7 +827,8 @@ static void _auth(xmpp_conn_t *conn)
827827

828828
/* SASL algorithm was tried, unset flag */
829829
conn->sasl_support &= ~scram_ctx->alg->mask;
830-
} else if (conn->sasl_support & SASL_MASK_DIGESTMD5) {
830+
} else if ((conn->sasl_support & SASL_MASK_DIGESTMD5) &&
831+
conn->weak_auth_enabled) {
831832
auth = _make_sasl_auth(conn, "DIGEST-MD5");
832833
if (!auth) {
833834
disconnect_mem_error(conn);
@@ -841,7 +842,8 @@ static void _auth(xmpp_conn_t *conn)
841842

842843
/* SASL DIGEST-MD5 was tried, unset flag */
843844
conn->sasl_support &= ~SASL_MASK_DIGESTMD5;
844-
} else if (conn->sasl_support & SASL_MASK_PLAIN) {
845+
} else if ((conn->sasl_support & SASL_MASK_PLAIN) &&
846+
conn->weak_auth_enabled) {
845847
auth = _make_sasl_auth(conn, "PLAIN");
846848
if (!auth) {
847849
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
@@ -1112,7 +1112,8 @@ long xmpp_conn_get_flags(const xmpp_conn_t *conn)
11121112
XMPP_CONN_FLAG_LEGACY_SSL * conn->tls_legacy_ssl |
11131113
XMPP_CONN_FLAG_TRUST_TLS * conn->tls_trust |
11141114
XMPP_CONN_FLAG_DISABLE_SM * conn->sm_disable |
1115-
XMPP_CONN_FLAG_LEGACY_AUTH * conn->auth_legacy_enabled;
1115+
XMPP_CONN_FLAG_LEGACY_AUTH * conn->auth_legacy_enabled |
1116+
XMPP_CONN_FLAG_WEAK_AUTH * conn->weak_auth_enabled;
11161117

11171118
return flags;
11181119
}
@@ -1161,6 +1162,7 @@ int xmpp_conn_set_flags(xmpp_conn_t *conn, long flags)
11611162
conn->tls_trust = (flags & XMPP_CONN_FLAG_TRUST_TLS) ? 1 : 0;
11621163
conn->auth_legacy_enabled = (flags & XMPP_CONN_FLAG_LEGACY_AUTH) ? 1 : 0;
11631164
conn->sm_disable = (flags & XMPP_CONN_FLAG_DISABLE_SM) ? 1 : 0;
1165+
conn->weak_auth_enabled = (flags & XMPP_CONN_FLAG_WEAK_AUTH) ? 1 : 0;
11641166

11651167
return 0;
11661168
}

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)