Compare commits

..

1 Commits

Author SHA1 Message Date
6dd1610e47 security: E2EE and transport correctness (issue #147)
Some checks failed
CI Code / Check spelling (pull_request) Successful in 13s
CI Code / Check coding style (pull_request) Successful in 23s
CI Code / Code Coverage (pull_request) Failing after 3m23s
CI Code / Linux (debian) (pull_request) Failing after 5m32s
CI Code / Linux (arch) (pull_request) Failing after 6m54s
CI Code / Linux (ubuntu) (pull_request) Failing after 8m20s
T04: promote security events to warnings — SASL auth failure, TLS
handshake failure, cert-failure details, see-other-host redirect;
DISABLE_TLS, TRUST_TLS and LEGACY_AUTH get a log warning plus a
console notice (REQ-LOG-01, REQ-LOG-02, REQ-AUTH-03)

T05: warn when a session ends up unencrypted without the user having
asked for it; refuse in-band registration on an unencrypted stream;
warn on each HTTP transfer with certificate verification disabled
(REQ-CRY-03, REQ-CFG-01)

T06: pin the update check to https with peer/host verification and no
redirects; strict N.N.N parser for the fetched version, which is
untrusted network input (REQ-VUL-02)

T09: no plaintext logging on failed MUC OMEMO sends; OTR opportunistic
first message passes allow_unencrypted_message(); get_random_string()
draws from a CSPRNG without modulo bias; guard the identity-key length
decrement against unsigned underflow (REQ-CRY-01, REQ-CRY-02,
REQ-CRY-07, REQ-MEM-05)

REQ-VUL-03 and REQ-CRY-09 are already satisfied on master and are
left unchanged.
2026-07-30 09:24:34 +03:00
3 changed files with 8 additions and 10 deletions

View File

@@ -217,15 +217,15 @@ _conn_apply_settings(const char* const jid, const char* const passwd, const char
if (flags & XMPP_CONN_FLAG_DISABLE_TLS) {
log_warning("[SECURITY] TLS is disabled for this connection: traffic and credentials are sent in the clear");
cons_show_warning("TLS is disabled, this connection is unencrypted.");
cons_show_error("Security warning: TLS is disabled, this connection is unencrypted.");
}
if (flags & XMPP_CONN_FLAG_TRUST_TLS) {
log_warning("[SECURITY] TLS certificate verification is disabled for this connection");
cons_show_warning("TLS certificates are not verified for this connection.");
cons_show_error("Security warning: TLS certificates are not verified for this connection.");
}
if (flags & XMPP_CONN_FLAG_LEGACY_AUTH) {
log_warning("[SECURITY] Legacy (XEP-0078) authentication enabled: the password is sent without SASL");
cons_show_warning("Legacy authentication is enabled for this connection.");
cons_show_error("Security warning: legacy authentication is enabled for this connection.");
}
if (xmpp_conn_set_flags(conn.xmpp_conn, flags)) {
@@ -381,7 +381,7 @@ _register_handle_proceedtls_default(xmpp_conn_t* xmpp_conn,
xmpp_conn_open_stream_default(xmpp_conn);
} else {
log_warning("[SECURITY] TLS handshake failed during registration, aborting");
cons_show_warning("TLS handshake failed, registration aborted.");
cons_show_error("Security warning: TLS handshake failed, registration aborted.");
/* failed tls spoils the connection, so disconnect */
xmpp_disconnect(xmpp_conn);
}
@@ -985,7 +985,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
// tls.policy=allow negotiates opportunistically, so an unrequested downgrade must not pass silently
if (!connection_is_secured() && !conn.tls_disabled_by_user) {
log_warning("[SECURITY] Logged in over an unencrypted connection to %s: the server offered no usable TLS", conn.domain);
cons_show_warning("This session is NOT encrypted, the server did not provide TLS. Use '/account set <account> tls force' to require it.");
cons_show_error("Security warning: this session is NOT encrypted, the server did not provide TLS. Use '/account set <account> tls force' to require it.");
}
session_login_success(connection_is_secured());
@@ -1055,7 +1055,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
if (stream_error && stream_error->stanza && _get_other_host(stream_error->stanza, &host, &port)) {
g_assert(port >= 0 && port <= UINT16_MAX);
log_warning("[SECURITY] Server redirected the connection (see-other-host) to \"%s\":%d", host, port);
cons_show_warning("The server redirected this connection to %s:%d.", host, port);
cons_show_error("Security notice: the server redirected this connection to %s:%d.", host, port);
session_reconnect(host, (unsigned short)port);
conn.conn_status = JABBER_RECONNECT;
return;

View File

@@ -100,7 +100,7 @@ connect_warns_on_insecure_transport(void **state)
prof_connect();
prof_timeout(10);
assert_true(prof_output_exact("Warning: TLS is disabled, this connection is unencrypted."));
assert_true(prof_output_exact("Warning: Legacy authentication is enabled for this connection."));
assert_true(prof_output_exact("Security warning: TLS is disabled, this connection is unencrypted."));
assert_true(prof_output_exact("Security warning: legacy authentication is enabled for this connection."));
prof_timeout_reset();
}

View File

@@ -977,8 +977,6 @@ migration_incremental_accumulation(void** state)
assert_true(prof_output_regex("Database backend switched to 'flatfile'\\."));
prof_input("/msg buddy1@localhost");
/* full repaint: incremental redraw may emit only partial line text */
prof_input("/redraw");
assert_true(prof_output_exact("incr-batch1-first"));
assert_true(prof_output_exact("incr-batch1-second"));
assert_true(prof_output_exact("incr-batch2-third"));