security: E2EE and transport correctness (issue #147)
All checks were successful
CI Code / Check spelling (pull_request) Successful in 14s
CI Code / Check coding style (pull_request) Successful in 25s
CI Code / Code Coverage (pull_request) Successful in 2m58s
CI Code / Linux (debian) (pull_request) Successful in 4m54s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m1s
CI Code / Linux (arch) (pull_request) Successful in 13m5s

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.
This commit is contained in:
2026-07-25 15:43:59 +03:00
parent 2be16df905
commit 214f860d2c
19 changed files with 262 additions and 23 deletions

View File

@@ -117,6 +117,7 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(connect_jid_requests_bookmarks),
PROF_FUNC_TEST(connect_bad_password),
PROF_FUNC_TEST(connect_shows_presence_updates),
PROF_FUNC_TEST(connect_warns_on_insecure_transport),
/* Ping tests - XEP-0199 XMPP Ping */
PROF_FUNC_TEST(ping_server),

View File

@@ -92,3 +92,15 @@ connect_shows_presence_updates(void **state)
);
assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\""));
}
void
connect_warns_on_insecure_transport(void **state)
{
/* the harness connects with "tls disable auth legacy": both downgrades must reach the console */
prof_connect();
prof_timeout(10);
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

@@ -3,3 +3,4 @@ void connect_jid_sends_presence_after_receiving_roster(void **state);
void connect_jid_requests_bookmarks(void **state);
void connect_bad_password(void **state);
void connect_shows_presence_updates(void **state);
void connect_warns_on_insecure_transport(void **state);

View File

@@ -977,6 +977,8 @@ 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"));

View File

@@ -1089,6 +1089,45 @@ release_is_new__tests__various(void** state)
assert_false(release_is_new("0.16.0", ""));
assert_false(release_is_new(NULL, "1.0.0"));
assert_false(release_is_new("1.0.0", NULL));
// the found version is untrusted network input: nothing but strictly N.N.N may parse
assert_false(release_is_new("0.16.0", " 1.0.0")); // leading whitespace
assert_false(release_is_new("0.16.0", "+1.0.0")); // explicit sign
assert_false(release_is_new("0.16.0", "-1.0.0")); // negative major
assert_false(release_is_new("0.16.0", "1.0.0-rc1")); // trailing garbage
assert_false(release_is_new("0.16.0", "1.0.0\n")); // trailing newline
assert_false(release_is_new("0.16.0", "1..0")); // empty component
assert_false(release_is_new("0.16.0", "0x10.0.0")); // hex is not accepted
assert_false(release_is_new("0.16.0", "99999999999.0.0")); // out of int range, must not wrap
assert_false(release_is_new("0.16.0", "1.0.0 malicious"));
// Boundary: the largest still-parsable component is accepted
assert_true(release_is_new("0.16.0", "2147483647.0.0"));
}
void
get_random_string__generates_valid_ids(void** state)
{
const gchar* alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (size_t len = 1; len <= 40; len++) {
gchar* id = get_random_string(len);
assert_non_null(id);
assert_int_equal(len, strlen(id));
for (size_t i = 0; i < len; i++) {
assert_non_null(strchr(alphabet, id[i]));
}
g_free(id);
}
// a collision here would mean a dead random source
gchar* a = get_random_string(20);
gchar* b = get_random_string(20);
assert_non_null(a);
assert_non_null(b);
assert_string_not_equal(a, b);
g_free(a);
g_free(b);
}
void

View File

@@ -64,5 +64,6 @@ void valid_tls_policy_option__is__correct_for_various_inputs(void** state);
void get_mentions__tests__various(void** state);
void release_is_new__tests__various(void** state);
void str_xml_sanitize__strips_illegal_characters(void** state);
void get_random_string__generates_valid_ids(void** state);
#endif

View File

@@ -687,6 +687,7 @@ main(int argc, char* argv[])
cmocka_unit_test(get_mentions__tests__various),
cmocka_unit_test(release_is_new__tests__various),
cmocka_unit_test(str_xml_sanitize__strips_illegal_characters),
cmocka_unit_test(get_random_string__generates_valid_ids),
cmocka_unit_test_setup_teardown(plugins_get_command_names__returns__no_commands,
load_preferences,