Skip to content

fix: Ignore SecureJoin messages from blocked contacts (#8295)#8326

Open
iequidoo wants to merge 2 commits into
mainfrom
iequidoo/ignore-sj-msgs-from-blocked
Open

fix: Ignore SecureJoin messages from blocked contacts (#8295)#8326
iequidoo wants to merge 2 commits into
mainfrom
iequidoo/ignore-sj-msgs-from-blocked

Conversation

@iequidoo

@iequidoo iequidoo commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator
  • Ignore "vc-request-with-auth" if the sender is blocked.
  • Ignore SecureJoin messages on an observing device if the joiner is blocked. Even if it's a
    "vc-contact-confirm" message, it might be issued by another device before the joiner was blocked
    on the observing device. Still, to avoid membership inconsistency on devices, don't ignore
    "vg-member-added".
  • Ignore "vc-request-pubkey" if the sender is blocked by address. We don't know sender's key yet, so we should handle the sender as an address contact at this point.

The sender can generate a new key and still join, but it's at least an extra work and also, in case of a group, other members will see that there's a new unknown member and be more careful.

Fix #8295

@iequidoo iequidoo marked this pull request as ready for review June 9, 2026 23:45
@iequidoo iequidoo requested review from Hocuri and adbenitez June 10, 2026 01:55
Comment thread src/chat/chat_tests.rs Outdated
Comment thread src/chat/chat_tests.rs Outdated
.await;
let alice1_bob_id = alice1.add_or_lookup_contact_id(bob).await;
assert_eq!(get_chat_contacts(alice1, alice1_chat_id).await?.len(), 2);
assert_eq!(get_chat_contacts(alice2, alice2_chat_id).await?.len(), 1);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's good that messages from self are ignored and this results in inconsistency. Bob will be added with the next message anyway.

"Ignore SecureJoin messages on an observing device if the joiner is blocked. Even if it's a "vc-contact-confirm" message, it might be issued by another device before the joiner was blocked on the observing device." sounds just like an accidental side effect of blocking messages in observe_securejoin_on_other_device. Makes sense for vc-request-with-auth, but if the other device has already added member to the group, i think it should not be ignored, just like "member added" should not be ignored.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, providing membership consistency makes sense, have fixed this.

@iequidoo iequidoo force-pushed the iequidoo/ignore-sj-msgs-from-blocked branch from 6176503 to 6af7d7a Compare June 12, 2026 06:29
Comment thread src/test_utils.rs
for inviter in inviters {
if let Some(sent) = inviter.pop_sent_msg_ex(rev_order, Duration::ZERO).await {
let inviter_addr = inviter.get_primary_self_addr().await.unwrap();
if sent.recipients.split(' ').any(|addr| addr == inviter_addr) {

@iequidoo iequidoo Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, without this condition test_blocked_bob_cant_create_11_chat_via_securejoin doesn't work:

========== Chats of alice2: ==========
Single#Chat#1001: Saved messages [KEY alice@example.org] Icon: 969142cb84015bc135767bc2370934a.png
--------------------------------------------------------------------------------
Msg#1003🔒: Me (Contact#Contact#Self): Secure-Join – Secure-Join  √
--------------------------------------------------------------------------------

The self-chat with this weird message is created from a vc-pubkey message which isn't self-sent normally. Maybe should be fixed because if the server copies sent messages to INBOX for some reason, this will happen. But not in this PR.

@iequidoo iequidoo marked this pull request as draft June 12, 2026 06:37
@iequidoo iequidoo force-pushed the iequidoo/ignore-sj-msgs-from-blocked branch from 6af7d7a to bdb9209 Compare June 12, 2026 19:26
@iequidoo iequidoo marked this pull request as ready for review June 12, 2026 19:27
Comment thread src/test_utils.rs Outdated
let inviter_addr = inviter.get_primary_self_addr().await.unwrap();
if sent.recipients.split(' ').any(|addr| addr == inviter_addr) {
for observer in inviters {
observer.recv_msg_opt(&sent).await;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now inviter receives the message that it just sent? This is why golden tests are changed?

This should be avoidable by comparing get_id() on the context to avoid sending to self.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Golden tests anyway need to be changed because now inviter devices receive each other messages, but i have added a comparison of the context IDs. Indeed, we normally don't download self-sent messages because of the logic in imap::prefetch_should_download()

Comment thread src/test_utils.rs

/// Executes SecureJoin initiated by `joiner`
/// scanning `qr` generated by one of the `inviters` devices.
/// `inviters` devices must have the same primary address.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why, what will happen if they don't?

If this is really needed, probably should be checked with an assertion.

@iequidoo iequidoo Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added an assertion. I just don't want to complicate the logic by comparing recipients against secondary addresses as well, to find out if a message should be received by a particular device

@adbenitez

Copy link
Copy Markdown
Collaborator
  • Ignore "vc-request-pubkey" if the sender is blocked by address. We don't know sender's key yet, so we should handle the sender as an address contact at this point.

I hope this doesn't mean that if you blocked an email address now the normal contact key associated will also be blocked, some people where blocking an "unencrypted gray-avatar address" of a DC user because some weird bug/manipulation from email provider that caused some messages of that user to arrive as "unencrypted" chat despite being a chatmail address

iequidoo added 2 commits June 12, 2026 20:25
… each other messages

Otherwise we're testing an abnormal scenario when `Config::BccSelf` ("multi-device") is disabled.
- Ignore "vc-request-with-auth" if the sender is blocked.
- Ignore SecureJoin messages on an observing device if the joiner is blocked. Even if it's a
  "vc-contact-confirm" message, it might be issued by another device before the joiner was blocked
  on the observing device. Still, to avoid membership inconsistency on devices, don't ignore
  "vg-member-added".
- Ignore "vc-request-pubkey" if the sender is blocked by address. We don't know sender's key yet, so
  we should handle the sender as an address contact at this point.

The sender can generate a new key and still join, but it's at least an extra work and also, in case
of a group, other members will see that there's a new unknown member and be more careful.
@iequidoo iequidoo force-pushed the iequidoo/ignore-sj-msgs-from-blocked branch from bdb9209 to 87b0e3a Compare June 12, 2026 23:26
@iequidoo

Copy link
Copy Markdown
Collaborator Author

I hope this doesn't mean that if you blocked an email address now the normal contact key associated will also be blocked, some people where blocking an "unencrypted gray-avatar address" of a DC user because some weird bug/manipulation from email provider that caused some messages of that user to arrive as "unencrypted" chat despite being a chatmail address

Only vc-request-pubkey will be ignored if the sender address is blocked because it's not signed by sender's key. Normal encrypted chat messages are handled as before.

@iequidoo iequidoo requested a review from link2xt June 12, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blocked contact can keep using invite links to groups and channels

3 participants