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

Psi indicates outcoming OMEMO-encrypted messages as unencrypted #616

Open
yessiest opened this issue Feb 28, 2021 · 26 comments
Open

Psi indicates outcoming OMEMO-encrypted messages as unencrypted #616

yessiest opened this issue Feb 28, 2021 · 26 comments
Labels

Comments

@yessiest
Copy link

When an outcoming message is sent, Psi seems to be showing that it isn't encrypted, even if encryption is enabled.
Despite this, the message is received as if it was a proper OMEMO message, and xml dump shows that the message body contains <encrypted> tag, <payload> tag and <encryption> tag.

I'm using Psi+ 1.5.2021.01.02 on Windows 10.

unknown

XML log of the message (to/from stripped)

<message> 
  <active xmlns="http://jabber.org/protocol/chatstates"/>
  <request xmlns="urn:xmpp:receipts"/>
  <encrypted xmlns="eu.siacs.conversations.axolotl">
     <header sid="1887302399">
         <iv>5dt4+C/s8apCIGcf</iv>
         <key rid="636297163" prekey="true">Mwi8o4QHEiEFIhnsQa3OGxfjntMkXcoJYbzNsTUGx7q5IhHiEL5QzzIaIQUyeoC8XugZd
         2K6Zo6S/xHXTIJrn5m8I/F9HLKchcMVJSJiMwohBSpjAThq3LSkPFblq6LmYPYFk+iRznvMSz1bJMbZ0NEMEDAYACIwbX6wzJyinzlFc
         f7VlaSf3ggQfoXj+sd6tzM9tX7V7ReUnfw0G6YOO9bG4tsa13kidajWcm60Az0o/+X3gwcwAQ==</key>
         <key rid="900459693">MwohBVBEhJULwnGIwkrLaE/9RBDlEfMmHE/2CvHdo9rtVcVWEAEYACIwEaO0dlgcMHE4O56Q+oxO7e78nez
         Cp/rPPUD+v0K2Q07mw0skGkcE956xtIZe1ys3Wv3zkqxrsmY=</key>
         <key rid="547510437" prekey="true">MwgyEiEFFiMdsHG5qyRzL/Sj1RW4y0gCsjvrYKh75XSsINE/7wMaIQUyeoC8XugZd2K6Z
         o6S/xHXTIJrn5m8I/F9HLKchcMVJSJiMwohBQOW4IPxQD1wqiXEvWIHQg0dDUwyFP0OKdkG8vQh0dFPEDAYACIwaKQLsjFGm7WLtlutJ
         b7/+VmPdT+kvmC+6NShRAZ15E444Lqg0TaN/qdsF4c5iz2J6Z0G4+uq9y0o/+X3gwcwAQ==</key>
     </header>
     <payload>TqMtjQK63kYp</payload>
  </encrypted>
  <store xmlns="urn:xmpp:hints"/>
  <encryption namespace="eu.siacs.conversations.axolotl" xmlns="urn:xmpp:eme:0"/>
</message>
@yessiest yessiest added the bug label Feb 28, 2021
@tehnick
Copy link
Member

tehnick commented Feb 28, 2021

As I see OMEMO button on toolbar is enabled. Have you tried to disable and then to enable OMEMO encryption from your side? Does it change anything?

@yessiest
Copy link
Author

yessiest commented Feb 28, 2021

Tried it, didn't really work. The messages that were sent out with OMEMO disabled were unencrypted. Once I turned it back on, the problem started reoccuring. Messages were still getting encrypted and they were still being indicated as if they were not encrypted.

@Neustradamus
Copy link
Contributor

@yessiest: Thanks to confirm OMEMO problems, I have done several tickets etc. without solutions.
@tehnick has done some changes but it is not always perfect at this time.

@Ri0n
Copy link
Member

Ri0n commented May 3, 2021

Maybe misinterpretation of the chatlog when when incoming unencrypted message also triggers "encryption disabled".
In this case nothing wrong with outgoing message. If you don't receive anything but just send, everything will be encrypted

@tehnick
Copy link
Member

tehnick commented May 6, 2021

@Ri0n
No, in this issue is described problem with outgoing messages. But not with incoming ones.

@yessiest
Could you check this problem in my builds for MS Windows?
https://sourceforge.net/projects/psiplus/files/Windows/Personal-Builds/tehnick/
To switch program to usage of your system profile just rename of executables as described in README.txt from archive.

@Neustradamus
Copy link
Contributor

@yessiest: Have you looked with last @tehnick build?

@yessiest
Copy link
Author

yessiest commented Jul 22, 2021

So i have tested this with the latest build by @tehnick (v1.5.1524) under approximately the same conditions as before (Windows 10 x86_64, Psi+ as recipient, Profanity v0.10.0 as sender, OMEMO enabled and fingerprints were exchanged). This issue seems to have been fixed as far as I can tell - both incoming and outcoming OMEMO messages are marked as encrypted and "Encryption is disabled" messages no longer pop up.

@Neustradamus
Copy link
Contributor

It is possible to test with another accounts?

@yessiest
Copy link
Author

yessiest commented Jul 23, 2021

I have tested this on a different machine (Windows 7 x86_64) with two builds - one that I have mentioned in the head post and the v1.5.1524 one, both running portable. The issue has resurfaced on the v.1.5.1524 build - once again the outgoing messages are being marked as unencrypted, while Profanity receives them as OMEMO encrypted messages.

I have tested this again on the original hardware (Windows 10 x86_64), and the issue resurfaced there, too.

@Neustradamus
Copy link
Contributor

@kssytsrk: Can you look this ticket?

@kssytsrk
Copy link
Contributor

Can't reproduce on Psi+ 1.5.1551 (2021-08-16) / FreeBSD 13.0 and Profanity as sender. Might this be Windows-only?

@Neustradamus
Copy link
Contributor

@kssytsrk: Thanks for your reply.

Can you test with 2 new test accounts without OMEMO used before?

Please use Psi+ and Psi+.

You will find the problem...

@kssytsrk
Copy link
Contributor

Isn't this ticket specifically about

Psi+ as recipient and Profanity v0.10.0 as sender

?

@Neustradamus
Copy link
Contributor

No.

@Neustradamus
Copy link
Contributor

@yessiest: Do you confirm that the bug is always here with new Psi+ builds?

@yessiest
Copy link
Author

yessiest commented Sep 18, 2021

I have tested the newest version available on sourceforge.net, that is, version 1.5.1552, on a Windows 7 machine. I can confirm that the bug still persists. Worth noting is the fact that this time I have been using Psi+ on both ends, so it's not specifically "Psi+ as recipient and Profanity v0.10.0 as sender" issue.

I have managed to reproduce both the state where the issue didn't show up and the state where it reappeared. The issue becomes apparent only if the receiving device uses Psi+ and the sending device has multiple OMEMO keys for the receiver's account. Then this issue appears on the receiver's Psi+ client.

@nullobsi
Copy link

This bug seems very strange. I had come across it a lot when my server was running Prosody; far less often when using Ejabberd, and now it has come back again.

@Neustradamus
Copy link
Contributor

@Ri0n: You can confirm this bug, you have seen few days ago

@yessiest
Copy link
Author

yessiest commented Jun 25, 2023

Found where OMEMO fails. Tested with OTR, in iris/src/xmpp/xmpp-im/xmpp_tasks.cpp, there's this bit of code

void JT_Message::onGo()
{

    Stanza      s = m.toStanza(&(client()->stream()));
    QDomElement e = s.element(); // oldStyleNS(s.element());

    if (auto encryptionHandler = client()->encryptionHandler()) {
        Q_UNUSED(encryptionHandler->encryptMessageElement(e));
    }

    // See: XEP-0380: Explicit Message Encryption
    const bool wasEncrypted = !e.firstChildElement("encryption").isNull();
    m.setWasEncrypted(wasEncrypted);
    m.setEncryptionProtocol(encryptionProtocol(e));

    // if the element is null, then the encryption is happening asynchronously
    if (!e.isNull()) {
        send(e);
    }
    setSuccess();
}

This code sets the flag that tells whether the message was encrypted. It works fine with OTR because "e" is actually set and is not null. However, for OMEMO, e.isNull() returns true, and so wasEncrypted is probably also not present as an element of e.

So the gist of it is that if encryption is happening "asynchronously", there is no way to actually check that the message was encrypted and so it defaults to saying that message was never encrypted. Currently researching into potential ways of fixing this without being too intrusive, hopefully there is a solution.

@Neustradamus
Copy link
Contributor

@Ri0n, @Vitozz, @tehnick, @stigger: Have you seen the comment of @yessiest?

@stigger
Copy link
Member

stigger commented Jul 20, 2023

Now I have.

@yessiest You are right that the OTR and the OMEMO encryptions are handled differently. It's not consistently broken, though, you've said it yourself:

I have managed to reproduce both the state where the issue didn't show up and the state where it reappeared

The only thing left is to investigate what's happening differently between the working and the broken states. For my use-cases the messages are always indicated properly.

@Neustradamus
Copy link
Contributor

@yessiest: Have you seen the @stigger comment?

@yessiest
Copy link
Author

@Neustradamus yes I have. Unfortunately I have been unable to reproduce the issue lately, things kind of just work for the most part. I'm not quite sure whether anything has changed, and disappointingly enough, my initial judgement on this issue being tied to having multiple contact fingerprints seems to be invalid - i have just tested this, sent messages to various resources, with different keys, everything worked as expected.

@ghost
Copy link

ghost commented Nov 9, 2023

I discovered for myself that at least on my end, the issue is caused by untrusted OMEMO keys from other devices logged in. If I send a message from Psi+ to these other devices on my account, it'll build and add the device key to my trusted contacts list, which will no longer display the warning at all.
My clients tested is Psi+ v1.5.1653 and blabber.im v3.1.4.

@Neustradamus
Copy link
Contributor

@yessiest and others: Have you tested with latest Psi+ build?
The problem is always here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants