-
-
Notifications
You must be signed in to change notification settings - Fork 120
BREAKING: Remove Secure-Join-Fingerprint header from "vc-contact-confirm", "vg-member-added" messages. Remove "vc-contact-confirm-received", "vg-member-added-received" messages from Securejoin protocol. #4345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ use crate::aheader::EncryptPreference; | |
| use crate::chat::{self, Chat, ChatId, ChatIdBlocked}; | ||
| use crate::config::Config; | ||
| use crate::constants::Blocked; | ||
| use crate::contact::{Contact, ContactId, Origin, VerifiedStatus}; | ||
| use crate::contact::{Contact, ContactId, Origin}; | ||
| use crate::context::Context; | ||
| use crate::e2ee::ensure_secret_key_exists; | ||
| use crate::events::EventType; | ||
|
|
@@ -465,14 +465,9 @@ pub(crate) async fn handle_securejoin_handshake( | |
| info_chat_id(context, contact_id).await?, | ||
| ) | ||
| .await?; | ||
| send_alice_handshake_msg( | ||
| context, | ||
| contact_id, | ||
| "vc-contact-confirm", | ||
| Some(fingerprint), | ||
| ) | ||
| .await | ||
| .context("failed sending vc-contact-confirm message")?; | ||
| send_alice_handshake_msg(context, contact_id, "vc-contact-confirm", None) | ||
| .await | ||
| .context("failed sending vc-contact-confirm message")?; | ||
|
|
||
| inviter_progress!(context, contact_id, 1000); | ||
| } | ||
|
|
@@ -494,33 +489,8 @@ pub(crate) async fn handle_securejoin_handshake( | |
| } | ||
| } | ||
| "vg-member-added-received" | "vc-contact-confirm-received" => { | ||
| /*========================================================== | ||
| ==== Alice - the inviter side ==== | ||
| ==== Step 8 in "Out-of-band verified groups" protocol ==== | ||
| ==========================================================*/ | ||
|
|
||
| if let Ok(contact) = Contact::get_by_id(context, contact_id).await { | ||
| if contact.is_verified(context).await? == VerifiedStatus::Unverified { | ||
| warn!(context, "{} invalid.", step); | ||
| return Ok(HandshakeMessage::Ignore); | ||
| } | ||
| if join_vg { | ||
| let field_grpid = mime_message | ||
| .get_header(HeaderDef::SecureJoinGroup) | ||
| .map(|s| s.as_str()) | ||
| .unwrap_or_else(|| ""); | ||
| if let Err(err) = chat::get_chat_id_by_grpid(context, field_grpid).await { | ||
| warn!(context, "Failed to lookup chat_id from grpid: {}", err); | ||
| return Err( | ||
| err.context(format!("Chat for group {} not found", &field_grpid)) | ||
| ); | ||
| } | ||
| } | ||
| Ok(HandshakeMessage::Ignore) // "Done" deletes the message and breaks multi-device | ||
| } else { | ||
| warn!(context, "{} invalid.", step); | ||
| Ok(HandshakeMessage::Ignore) | ||
| } | ||
| // The peer isn't updated yet and still sends these messages. | ||
| Ok(HandshakeMessage::Ignore) | ||
| } | ||
| _ => { | ||
| warn!(context, "invalid step: {}", step); | ||
|
|
@@ -540,12 +510,6 @@ pub(crate) async fn handle_securejoin_handshake( | |
| /// The inviting device has marked a peer as verified on vg-request-with-auth/vc-request-with-auth | ||
| /// before sending vg-member-added/vc-contact-confirm - so, if we observe vg-member-added/vc-contact-confirm, | ||
| /// we can mark the peer as verified as well. | ||
| /// | ||
| /// - if we see the self-sent-message vg-member-added-received | ||
| /// we know that we're an joiner-observer. | ||
| /// the joining device has marked the peer as verified on vg-member-added/vc-contact-confirm | ||
| /// before sending vg-member-added-received - so, if we observe vg-member-added-received, | ||
| /// we can mark the peer as verified as well. | ||
| pub(crate) async fn observe_securejoin_on_other_device( | ||
| context: &Context, | ||
| mime_message: &MimeMessage, | ||
|
|
@@ -563,9 +527,7 @@ pub(crate) async fn observe_securejoin_on_other_device( | |
| "vg-request-with-auth" | ||
| | "vc-request-with-auth" | ||
| | "vg-member-added" | ||
| | "vc-contact-confirm" | ||
| | "vg-member-added-received" | ||
| | "vc-contact-confirm-received" => { | ||
| | "vc-contact-confirm" => { | ||
| if !encrypted_and_signed( | ||
| context, | ||
| mime_message, | ||
|
|
@@ -631,32 +593,6 @@ pub(crate) async fn observe_securejoin_on_other_device( | |
| } | ||
| peerstate.prefer_encrypt = EncryptPreference::Mutual; | ||
| peerstate.save_to_db(&context.sql).await.unwrap_or_default(); | ||
| } else if let Some(fingerprint) = | ||
| mime_message.get_header(HeaderDef::SecureJoinFingerprint) | ||
| { | ||
| // FIXME: Old versions of DC send this header instead of gossips. Remove this | ||
| // eventually. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hum
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let fingerprint = fingerprint.parse()?; | ||
| if mark_peer_as_verified( | ||
| context, | ||
| fingerprint, | ||
| Contact::load_from_db(context, contact_id) | ||
| .await? | ||
| .get_addr() | ||
| .to_owned(), | ||
| ) | ||
| .await | ||
| .is_err() | ||
| { | ||
| could_not_establish_secure_connection( | ||
| context, | ||
| contact_id, | ||
| info_chat_id(context, contact_id).await?, | ||
| format!("Fingerprint mismatch on observing {step}.").as_ref(), | ||
| ) | ||
| .await?; | ||
| return Ok(HandshakeMessage::Ignore); | ||
| } | ||
| } else { | ||
| could_not_establish_secure_connection( | ||
| context, | ||
|
|
@@ -960,7 +896,7 @@ mod tests { | |
| VerifiedStatus::Unverified | ||
| ); | ||
|
|
||
| // Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received | ||
| // Step 7: Bob receives vc-contact-confirm | ||
| bob.recv_msg(&sent).await; | ||
| assert_eq!( | ||
| contact_alice.is_verified(&bob.ctx).await.unwrap(), | ||
|
|
@@ -985,15 +921,6 @@ mod tests { | |
| let text = msg.get_text().unwrap(); | ||
| assert!(text.contains("alice@example.org verified")); | ||
| } | ||
|
|
||
| // Check Bob sent the final message | ||
| let sent = bob.pop_sent_msg().await; | ||
| let msg = alice.parse_msg(&sent).await; | ||
| assert!(msg.was_encrypted()); | ||
| assert_eq!( | ||
| msg.get_header(HeaderDef::SecureJoin).unwrap(), | ||
| "vc-contact-confirm-received" | ||
| ); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
|
|
@@ -1111,20 +1038,12 @@ mod tests { | |
| VerifiedStatus::Unverified | ||
| ); | ||
|
|
||
| // Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received | ||
| // Step 7: Bob receives vc-contact-confirm | ||
| bob.recv_msg(&sent).await; | ||
| assert_eq!( | ||
| contact_alice.is_verified(&bob.ctx).await?, | ||
| VerifiedStatus::BidirectVerified | ||
| ); | ||
|
|
||
| let sent = bob.pop_sent_msg().await; | ||
| let msg = alice.parse_msg(&sent).await; | ||
| assert!(msg.was_encrypted()); | ||
| assert_eq!( | ||
| msg.get_header(HeaderDef::SecureJoin).unwrap(), | ||
| "vc-contact-confirm-received" | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
|
|
@@ -1308,7 +1227,7 @@ mod tests { | |
| VerifiedStatus::Unverified | ||
| ); | ||
|
|
||
| // Step 7: Bob receives vg-member-added, sends vg-member-added-received | ||
| // Step 7: Bob receives vg-member-added | ||
| bob.recv_msg(&sent).await; | ||
| { | ||
| // Bob has Alice verified, message shows up in the group chat. | ||
|
|
@@ -1355,14 +1274,6 @@ mod tests { | |
| } | ||
| } | ||
|
|
||
| let sent = bob.pop_sent_msg().await; | ||
| let msg = alice.parse_msg(&sent).await; | ||
| assert!(msg.was_encrypted()); | ||
| assert_eq!( | ||
| msg.get_header(HeaderDef::SecureJoin).unwrap(), | ||
| "vg-member-added-received" | ||
| ); | ||
|
|
||
| let bob_chat = Chat::load_from_db(&bob.ctx, bob_chatid).await?; | ||
| assert!(bob_chat.is_protected()); | ||
| assert!(bob_chat.typ == Chattype::Group); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.