Skip to content

Commit 5da6976

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 (which is needed for getting "verified by unknown contact" in the first place).
1 parent bd15d90 commit 5da6976

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/contact.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ pub(crate) async fn mark_contact_id_as_verified(
19621962
"Contact cannot be verified by self",
19631963
);
19641964
let update = verifier_id == Some(ContactId::SELF);
1965-
let verifier_id = verifier_id.unwrap_or(contact_id);
1965+
let mut verifier_id = verifier_id.unwrap_or(contact_id);
19661966
context
19671967
.sql
19681968
.transaction(|transaction| {
@@ -1990,6 +1990,13 @@ pub(crate) async fn mark_contact_id_as_verified(
19901990
verifier_id == contact_id || verifier_verifier_id != ContactId::UNDEFINED,
19911991
"Contact {contact_id} cannot be verified by unverified contact {verifier_id}",
19921992
);
1993+
if verifier_verifier_id == verifier_id {
1994+
// Avoid introducing incorrect reverse chains: if the verifier itself has an
1995+
// unknown verifier, it may be `contact_id` actually (directly or indirectly) on
1996+
// the other device (which is needed for getting "verified by unknown contact"
1997+
// in the first place).
1998+
verifier_id = contact_id;
1999+
}
19932000
}
19942001
transaction.execute(
19952002
"UPDATE contacts SET verifier=?1

0 commit comments

Comments
 (0)