Skip to content

Commit 19b5126

Browse files
committed
fix: Don't verify contacts by others having an unknown verifier
If this happens, mark the contact as verified by an unknown contact instead. This avoids introducing incorrect reverse chains: if the verifier itself has an unknown verifier, it may be `contact_id` actually (directly or indirectly) on the other device.
1 parent 2993858 commit 19b5126

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/contact.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ pub(crate) async fn mark_contact_id_as_verified(
19641964
"Contact cannot be verified by self",
19651965
);
19661966
let update = verifier_id == Some(ContactId::SELF);
1967-
let verifier_id = verifier_id.unwrap_or(contact_id);
1967+
let mut verifier_id = verifier_id.unwrap_or(contact_id);
19681968
context
19691969
.sql
19701970
.transaction(|transaction| {
@@ -1992,6 +1992,12 @@ pub(crate) async fn mark_contact_id_as_verified(
19921992
verifier_id == contact_id || verifier_verifier_id != ContactId::UNDEFINED,
19931993
"Contact {contact_id} cannot be verified by unverified contact {verifier_id}",
19941994
);
1995+
if verifier_verifier_id == verifier_id {
1996+
// Avoid introducing incorrect reverse chains: if the verifier itself has an
1997+
// unknown verifier, it may be `contact_id` actually (directly or indirectly) on
1998+
// the other device.
1999+
verifier_id = contact_id;
2000+
}
19952001
}
19962002
transaction.execute(
19972003
"UPDATE contacts SET verifier=?1

0 commit comments

Comments
 (0)