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

SecureJoin: encrypt {vc,vg}-request message #5182

Open
link2xt opened this issue Jan 14, 2024 · 5 comments
Open

SecureJoin: encrypt {vc,vg}-request message #5182

link2xt opened this issue Jan 14, 2024 · 5 comments

Comments

@link2xt
Copy link
Collaborator

link2xt commented Jan 14, 2024

Currently if Bob scans a SecureJoin QR code and has no Alice's key corresponding to the encoded fingerprint, he sends Alice an unencrypted vc-request with INVITENUMBER to request the key from Alice. This is the only unencrypted message in SecureJoin protocol that requires special handling by chatmail filter that otherwise does not allow unencrypted messages (the other exception is MDNs, but with #5175 merged it can be removed).

A way to fix this would be to include the same keydata as we include in Autocrypt header in the QR code if it is small enough. Then if Bob does not currently have an Autocrypt key for Alice, he can use this keydata from the QR code. For backwards compatibility we should still keep the fingerprint.

I have tested with ed25519 keys, QR code can be generated with qrencode. It is more dense than our typical QR codes, so scanning may be more difficult and we may need to (re)move the avatar that we currently overlay on top of the QR code. qrencode-encoded image with added &keydata= in the end works with the current Delta Chat, keydata is properly ignored.

Including keydata in the QR code could simplify expiring QR codes (#5126) as only AUTH token will expire and INVITENUMBER is not used at all, so Bob can still scan the QR-code later and send the first message encrypted, while Alice does not need to worry about someone using old INVITENUMBER to request the key and monitor Alice's online presence.

As a first step I suggest adding a feature flag settable via config table to start including keydata if it is small enough. The limit should be large enough to include all keys generated by Delta Chat but not too large so QR code remains readable and not extremely dense or impossible to generate if huge keys are used. With this feature flag we can already make automated tests and start rolling out releases that can read this keydata and use it to skip vc-request.

As a second step we can enable this feature flag so clients actually start generating this QR codes. There is no need to wait for too long as feature is backwards-compatible, one release apart is enough.

Once enough clients support this, we can change chatmail to stop accepting any non-encrypted mails at all.

There might be security implications of accepting the Autocrypt key from a QR code claiming that it is a key for some email address without ever receiving a message with this email address. It seems relatively safe if we have no existing Autocrypt key for the contact, but otherwise I think we should not overwrite Autocrypt key currently in use. We should probably also postpone moving the key to verified slot until we receive any encrypted (+signed) message from Alice, if possible this key should not be saved anywhere at all and only used to send vc-request-with-auth. We are immediately encrypting AUTH token to this key as the next step, but if attacker controls the QR code then attacker also knows AUTH token encoded in this QR code.

@link2xt
Copy link
Collaborator Author

link2xt commented Jan 14, 2024

Marking as discussion as it is a draft so nobody jumps into implementing this right now until there is more agreement on this.

@Hocuri
Copy link
Collaborator

Hocuri commented Jan 14, 2024

When I tried QR codes containing the pub key half a year ago with @hpk42, I actually didn't manage to scan the QR code with my phone camera. To be fair, my phone camera was not that good, and I actually often had problems scanning QR codes (not only related to Delta Chat). Still, this is a problem to consider.

Apart from that, having the pub key in the QR code would save us quite some problems, to summarize:

All in all, while I was against this idea half a year ago, I'm +/-0 right now

@link2xt
Copy link
Collaborator Author

link2xt commented Jan 15, 2024

Maybe there should be an UI fallback like "can't scan the QR code?" link below it which toggles the key out and explains the limitations.

@hpk42
Copy link
Contributor

hpk42 commented Jan 15, 2024 via email

@link2xt
Copy link
Collaborator Author

link2xt commented Jun 11, 2024

Including the whole OpenPGP key will not work for v6/crypto-refresh, because we will eventually need to transmit two keys (v4 and v6) and larger PQC keys. Instead of trying to put OpenPGP key into the QR code we can instead share a passphrase and encrypt the first message with this passphrase, placing session key into SKESK (symmetric-key encrypted session key packet). Symmetric encryption is simpler and is not affected by potential PQ upgrades in the future. The only problem is then how Alice finds which passphase was used when she receives Bob's message: we may still have to include invite token into the plaintext header to allow for the QR code lookup.

@link2xt link2xt changed the title SecureJoin: include keydata in QR code SecureJoin: encrypt {vc,vg}-request message Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants