Skip to content
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

Bidirectional verification #5089

Merged
merged 9 commits into from
Jan 10, 2024
Merged

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Dec 6, 2023

This PR separates the concepts of "forward verification" (moving the key into verified_key slot of the peerstate) and "backward verification" (getting an indication that contact has verified our key by receiving a Chat-Verified header, vc-contact-confirm message or vc-request-with-auth message).

Forward verification is now set when fingerprint is checked. Bob forward-verifies Alice when {vc,vg}-request-with-auth is received or immediately after scanning the QR code when taking a shortcut.

Bob sets backward verification when vc-contact-confirm is received or vg-member-added adding Bob by Alice is received. This is not supposed to be secure, tricking Bob into believing that Alice has correct verified key for Bob is not very interesting. Backward verification is also set when a message with a Chat-Verified header is received to opportunistically recover from the case when vc-contact-confirm/vg-member-added is lost, but in general Bob should just rescan if green checkmark did not appear.

Alice sets both forward and backward verification when {vc,vg}-request-with-auth is received.

Closes #1177
Closes #5062
Replaces #4914

@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch 2 times, most recently from 0be7d58 to 0b5801e Compare December 8, 2023 22:15
@link2xt link2xt changed the base branch from main to link2xt/show-padlock-on-empty-messages December 8, 2023 22:16
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 0b5801e to 5891fc5 Compare December 8, 2023 22:20
@link2xt link2xt force-pushed the link2xt/show-padlock-on-empty-messages branch from 8522b8c to c09e0e2 Compare December 8, 2023 23:32
Base automatically changed from link2xt/show-padlock-on-empty-messages to main December 8, 2023 23:43
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from ae510f7 to ba1c98c Compare December 8, 2023 23:44
@link2xt link2xt changed the title WIP: bidirectional verification Bidirectional verification Dec 9, 2023
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch 4 times, most recently from 2cb0335 to 562e59b Compare December 11, 2023 03:12
@link2xt link2xt changed the base branch from main to link2xt/rpc-import-export-self-keys December 11, 2023 03:14
@link2xt link2xt force-pushed the link2xt/rpc-import-export-self-keys branch from 851739e to b2207e8 Compare December 11, 2023 03:18
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 562e59b to 10be15a Compare December 11, 2023 03:19
@link2xt link2xt changed the base branch from link2xt/rpc-import-export-self-keys to link2xt/config-upsert December 11, 2023 03:26
@link2xt link2xt force-pushed the link2xt/config-upsert branch from f88326d to c7d9eeb Compare December 11, 2023 04:05
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 10be15a to b2849b7 Compare December 11, 2023 04:06
@link2xt link2xt force-pushed the link2xt/config-upsert branch from c7d9eeb to 462f29f Compare December 11, 2023 06:14
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from b2849b7 to 74874de Compare December 11, 2023 06:14
@link2xt link2xt force-pushed the link2xt/config-upsert branch from 462f29f to 721e6ee Compare December 11, 2023 06:44
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 74874de to da8b5ee Compare December 11, 2023 06:44
@link2xt link2xt force-pushed the link2xt/config-upsert branch from 721e6ee to bbff5e5 Compare December 11, 2023 19:41
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from da8b5ee to 38dd6f6 Compare December 11, 2023 19:41
@link2xt link2xt force-pushed the link2xt/config-upsert branch from bbff5e5 to 3107a36 Compare December 12, 2023 02:51
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 38dd6f6 to 42423ed Compare December 12, 2023 02:51
@link2xt link2xt force-pushed the link2xt/config-upsert branch from 3107a36 to d9621bc Compare December 12, 2023 20:04
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 42423ed to 0207ffb Compare December 12, 2023 20:04
@link2xt link2xt force-pushed the link2xt/config-upsert branch from d9621bc to a02463b Compare December 16, 2023 15:18
src/param.rs Show resolved Hide resolved
Base automatically changed from link2xt/securejoin-refactorings to main December 20, 2023 21:17
@Hocuri
Copy link
Collaborator

Hocuri commented Dec 22, 2023

link2xt: The main point of this PR is moving forward verification to the correct place where we check the fingerprint or AUTH code. Backward verification is added to avoid breaking existing behavior and marking the contact as verified before the protocol completes.

iequidoo: The PR overall is fine, i'm only about that part adding the backward verification to the peerstate and the db.

The point of this PR is to split up verification into forward verification (i.e. I verified my contact) and backward verification (i.e. I think that my contact verified me). Leaving away the backward verification now would introduce new bugs; sure, we don't know how bad these bugs would be in practice, but I don't really want to try it out. E.g. if I have no indication that a contact verified me, then I shouldn't just add them to a verified group. Sure, sometimes this information is stale, but in many cases it's not. And as discussed in #4932, it would be nice to let QR codes expire; in this case, it will be nice that Bob can do a one-sided verification if he already knows Alice's key.

TL;DR: I do think that we need backward verification, and this PR looks fine overall, even though I didn't have time for a detailed review.

@Hocuri Hocuri mentioned this pull request Dec 22, 2023
src/peerstate.rs Outdated Show resolved Hide resolved
src/receive_imf.rs Show resolved Hide resolved
src/mimefactory.rs Show resolved Hide resolved
@iequidoo
Copy link
Collaborator

The point of this PR is to split up verification into forward verification (i.e. I verified my contact) and backward verification (i.e. I think that my contact verified me). Leaving away the backward verification now would introduce new bugs; sure, we don't know how bad these bugs would be in practice, but I don't really want to try it out. E.g. if I have no indication that a contact verified me, then I shouldn't just add them to a verified group. Sure, sometimes this information is stale, but in many cases it's not.

I'd not call it "bugs", but "probability of unwanted behaviour". I just worry that the backward verification may be restrictive and sometimes stay on the way of secure communication. E.g. impossibility of adding a contact to some chat if we missed a verification message. E.g. not showing a green checkmark when we actually can trust the contact (this may stop the user from communicating with the contact). But if we're ok with all this, then the only question remains for me:

But if we have Alice's key verified via gossip, probably Alice has our key verified via gossip too, no? Doesn't it work this way now (so we can add gossip-verified Alice to protected chats)? And don't we restrict this too much with requiring the backward verification?

So, from now we need to wait for any message from gossip-verified Alice to be sure we're backward-verified. Before this, Alice will be shown to us w/o a green checkmark (while being in the same protected chat), so we even can't contact them safely (at least we would think so).

src/securejoin/bob.rs Outdated Show resolved Hide resolved
src/receive_imf.rs Show resolved Hide resolved
Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

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

Sorry, I'm still not fully done reviewing, but I'm almost through and don't think I will find anything else (what's left is verifying that the refactorings didn't introduce any accidental changes) - from my side, only #5089 (comment) ("This will break compatibility...") is actually a blocker, the others are more nice-to-haves.

src/securejoin.rs Outdated Show resolved Hide resolved
src/securejoin.rs Show resolved Hide resolved
@deltachat deltachat deleted a comment from Darahi Jan 2, 2024
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch 3 times, most recently from 9289de6 to c2df003 Compare January 9, 2024 02:21
@link2xt
Copy link
Collaborator Author

link2xt commented Jan 9, 2024

I have merged #5116 into this PR.
There is #5167 on top that I would also like to merge.

@link2xt
Copy link
Collaborator Author

link2xt commented Jan 9, 2024

This is really ready for review, would like to merge soon so we have time to test it before next release.

@iequidoo
Copy link
Collaborator

iequidoo commented Jan 9, 2024

The only question remaining for me -- if Alice adds Bob to a protected chat with Claire so that they become gossip-verified for Bob, what are we going to have as compared to the current behaviour? Can Bob safely communicate to Claire? I think that yes, but how the user should know that?

@link2xt
Copy link
Collaborator Author

link2xt commented Jan 9, 2024

The only question remaining for me -- if Alice adds Bob to a protected chat with Claire so that they become gossip-verified for Bob, what are we going to have as compared to the current behaviour? Can Bob safely communicate to Claire? I think that yes, but how the user should know that?

See mark_recipients_as_verified, we optimistically mark the contact as forward-and-backward verified assuming it received the gossip by calling peerstate.set_verified() and setting backward_verfified_key_id. This might be wrong if some contacts did not receive "member added" message, but not worse than before this change.

Mark 1:1 chat as verified as soon as Alice is forward-verified
so Bob can already start sending Chat-Verified headers.
This way Alice and Bob can scan each other's QR codes
and even if all Secure-Join headers are dropped from the network,
still get forward verifications via QR-code scans
and backward verifications via Chat-Verified messages in 1:1 chat.
The chat is not modified at least since
c6ea4e3
(PR #4998),
even the info message is not posted there.
It was named notify_peer_verified()
because it added info message,
but this is no longer true since
#4998
(commit c6ea4e3)
is merged.
@link2xt link2xt force-pushed the link2xt/peerstate-second-dir-verification branch from 21084c4 to 20065d3 Compare January 9, 2024 21:47
@link2xt link2xt merged commit 20065d3 into main Jan 10, 2024
38 checks passed
@link2xt link2xt deleted the link2xt/peerstate-second-dir-verification branch January 10, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants