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

Add support for XEP-0454 OMEMO Media sharing #1182

Closed
genofire opened this issue Sep 8, 2018 · 29 comments
Closed

Add support for XEP-0454 OMEMO Media sharing #1182

genofire opened this issue Sep 8, 2018 · 29 comments

Comments

@genofire
Copy link
Contributor

genofire commented Sep 8, 2018

screenshot from 2018-09-08 13-18-16

@jcbrand
Copy link
Member

jcbrand commented Sep 10, 2018

It's not clear to me what the problem is here... is this due to an OOB URL not being encrypted?

https://xmpp.org/extensions/xep-0066.html#x-oob

@genofire
Copy link
Contributor Author

I do not know, if the url is encrypted also - the file/image is encrypted with omemo/aes:

You have to download the files by just replace aesgcm:// with https://.
Afterwards you have to decrypt the file.

Here is the implementation in gajim/python:
get crypto attribues (key, iv from urlpart after #): https://dev.gajim.org/gajim/gajim-plugins/blob/master/omemo/file_crypto.py#L124-139
decrypt with it: https://dev.gajim.org/gajim/gajim-plugins/blob/master/omemo/file_crypto.py#L243-252

Hope it helps a little bit.
Maybe u should just try it with a nother client like PixArt, Conversations or gajim itself.

@jcbrand
Copy link
Member

jcbrand commented Sep 10, 2018

Thanks for the info, I'll look into it.

@knoy
Copy link

knoy commented Feb 7, 2019

Without this OMEMO is really crippled to just text messages.

The OMEMO HTTP-upload is covered in https://xmpp.org/extensions/inbox/omemo-media-sharing.html :

An entity wishing to share an end-to-end encrypted file first generates a 32 byte random key and a 12 byte random IV. After successfully requesting a slot for HTTP upload the file can be encrypted with AES-256 in Galois/Counter Mode (GCM) on the fly while uploading it via HTTP. The authentication tag MUST be appended to the end of the file.

To share the file the entity converts the HTTPS URL, the key and the IV to an aesgcm:// URL. Both IV and key are converted to their hex representation of 24 characters and 64 characters respectively and concatenated for a total of 88 characters (44 bytes). The IV comes first followed by the key. The resulting string is put in the anchor part of the aesgcm URL.

@knoy
Copy link

knoy commented Feb 22, 2019

I think this may be a security issue... if the lock icon is set to "locked" and OMEMO encryption is enabled, then user goes to attach a file, the file is sent unencrypted.

Perhaps file attachments should be disabled during an OMEMO-encrypted chat (or at least heavily warned) until this is fixed ?

@xmarxthespot
Copy link

does omemo encrypt http upload images or not?

redsolution/xabber-android#799 (comment)

the xabber developer claims no.

@licaon-kter
Copy link
Contributor

licaon-kter commented Jan 4, 2020

@xmarxthespot the files are encrypted yes

https://conversations.im/omemo/

@licaon-kter
Copy link
Contributor

@xmarxthespot more exactly
https://xmpp.org/extensions/inbox/omemo-media-sharing.html

Yes not a XEP yet, but as Xabber devs know (and want for their own developed XEPs) implementations weight a lot, so when you have all the currently developed clients (Conversations, Dino, Gajim, Monal, ChatSecure, etc) use this schema to encrypt the files on the server (for years already) that Xabber dev post is kinda FUD.

@Echolon Echolon added the OMEMO label Apr 2, 2021
@jcbrand jcbrand changed the title OMEMO encrypt and decrypt HTTP-Upload Add support for XEP-0454 OMEMO Media sharing Jul 1, 2021
@jcbrand jcbrand closed this as completed in e675c85 Jul 1, 2021
@licaon-kter
Copy link
Contributor

licaon-kter commented Jul 1, 2021

A quick test and...

@jcbrand sent files don't feature a lock icon (!?)

@iNPUTmice received files by Conversations look like this (bubble colour as if unencrypted)
OU-_p2UQTDaWGgSoketko

Stanza from Firefox console:

<message from="converseuser@mydomain.tld/converse.js-24947815" to="conversations@mydomain.tld" type="chat" id="hash"><body>aesgcm://upload.mydomain.tld/hash/hash/filename.jpeg#key</body><active/><request/><origin-id id="hash"/></message>

@iNPUTmice
Copy link

iNPUTmice commented Jul 1, 2021 via email

@jcbrand jcbrand reopened this Jul 2, 2021
@jcbrand
Copy link
Member

jcbrand commented Jul 2, 2021

Thanks @licaon-kter

@iNPUTmice You're right, I assumed it's getting encrypted but didn't double check. I intend to still add tests to catch things like this. I shouldn't have closed this ticket so quickly.

jcbrand added a commit that referenced this issue Jul 2, 2021
by re-using `ChatBox.prototype.sendMessage`.

updates #1182
@jcbrand jcbrand closed this as completed Jul 2, 2021
@futurealecks
Copy link

Thanks for implementing this @jcbrand. I'm seeing successful OMEMO messages from Converse > Conversations however with Conversations > Converse it shows an inbound OMEMO message but instead of showing the media it has the full aesgcm link.

Debug console shows: "Could not decrypt file aesgm://"

I can provide more details, I just wanted to see if anyone else has seen this.

@licaon-kter
Copy link
Contributor

@futurealecks there's no preview yet ( #2554 ) but you should get the file and it should decrypt okay

@jcbrand
Copy link
Member

jcbrand commented Jul 23, 2021

@futurealecks Might be that the message wasn't encrypted for that device. Can you successfully decrypt other non-media OMEMO messages from the same user?

@futurealecks
Copy link

futurealecks commented Jul 23, 2021

It looks like my previous issue was a key issue and that has been resolved.

However, sending media from Conversations > Converse shows an encrypted message:

"Download file "filename.jpg"

It comes in as a link but nothing happens when you click the link. There is also no information in Debug. In Elements, I see:

image

It seems to be Downloading the file but it doesn't exist on the machine.

@licaon-kter
Copy link
Contributor

@futurealecks Did you see #2554 (comment) ? How is your CORS setup? Can you try without?

@futurealecks
Copy link

@licaon-kter, this is our CORS setup:

< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PUT
< Access-Control-Allow-Headers: Authorization, Content-Type
< Access-Control-Allow-Credentials: true

As for turning it off, I'm not sure what that would do. We are not seeing any errors related to permissions.

I would think if it was permissions it may look something like "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource".

@licaon-kter
Copy link
Contributor

What does the console say in debug mode when you click a link?

@futurealecks
Copy link

Strangely nothing. It's a link that you can however and click but it doesn't post a single log message to the console.

Not very helpful huh.

image

@licaon-kter
Copy link
Contributor

@afriedmanGlacier
Copy link
Contributor

afriedmanGlacier commented Jul 30, 2021

@licaon-kter I looked at this briefly with @futurealecks

Nothing happens in debug mode when we click a link. Absolutely nothing. We don't see anything in the debug log. The actual element that encompasses that "Download" text and blob is something like:

<converse-chat-message-body class="chat-msg__text " show_images="" embed_videos="" embed_audio="" text="aesgcm://domain.tld/joeboo/dn3yRtkgSCsjPYF9/21E683C2-843B-4EA6-BC34-C77CF63CE4FE.jpg#3b81d42e3cbd50e310fd005b4d73e904512bea1f728de549366746c1d762ae22dc8a2cfb706e2bb745a55771">...<a target="_blank" rel="noopener" href="blob:file:///4cc9725b-5973-42ee-b77c-754fad9a582a">...Download file "21E683C2-843B-4EA6-BC34-C77CF63CE4FE.jpg"</a>...</converse-chat-message-body>

@licaon-kter
Copy link
Contributor

licaon-kter commented Jul 30, 2021

But you see a lot of noisy debug info is the console in general?

The file can be downloaded just fine in other clients connected with this account?

@afriedmanGlacier
Copy link
Contributor

Yes and yes

@afriedmanGlacier
Copy link
Contributor

Looks like, at in the case we were testing, this is happening because it is not being considered an Image file. In plugins/omemo/utils, it's checking the url to determine the type. isImageURL comes back false because the aesgcm uri doesn't end with the image extension. So it defaults to an unknown file type and doesn't add the 'onClick' and 'onLoad'.

Is there an "image_urls_regex" for this, or should the link maybe be parsed (removing everything after the hash tag) to find the extension?

@licaon-kter
Copy link
Contributor

licaon-kter commented Aug 2, 2021

@afriedmanGlacier As linked above, see the same idea in #2554

But, in my case... the can be opened.

@afriedmanGlacier
Copy link
Contributor

afriedmanGlacier commented Aug 2, 2021

It turns out that this was because checkTLS in headless/utils/url was returning false. Locally, I added:
|| uri.protocol().toLowerCase() === 'aesgcm'
to test, and then it started showing inline and working as expected.

I don't think this affected the outcome, but the image I was testing ended in .JPG, so I also added a toLowerCase in the getAndDecryptFile function of plugins/omemo/utils or it wouldn't get the correct mimetype:
const mimetype = MIMETYPES_MAP[extension.toLowerCase()];

jcbrand added a commit that referenced this issue Aug 24, 2021
@jcbrand
Copy link
Member

jcbrand commented Aug 24, 2021

Thanks @afriedmanGlacier, I've made a commit with the change you described.

@lennylen
Copy link

lennylen commented Sep 15, 2021

Thanks @afriedmanGlacier, I've made a commit with the change you described.

Still experiencing this error.

Could not find any application or handler for aesgcm://chat.domain.com/upload/xxx/xxx.jpeg#xxxxxx

Debug log shows this:
conversejs-filled.svg:1 Failed to load resource: net::ERR_FILE_NOT_FOUND log.js:64 ERROR: TypeError: Cannot destructure property `__` of 'undefined' or 'null'. at Object.getErrorMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:53434:9) at Object.getMessageBody (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:53466:27) at child.findDuplicateFromMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:56190:35) at child.getDuplicateMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:56155:113) log @ log.js:64

@lennylen
Copy link

lennylen commented Sep 15, 2021

Thanks @afriedmanGlacier, I've made a commit with the change you described.

Still experiencing this error.

Could not find any application or handler for aesgcm://chat.domain.com/upload/xxx/xxx.jpeg#xxxxxx

Debug log shows this:
conversejs-filled.svg:1 Failed to load resource: net::ERR_FILE_NOT_FOUND log.js:64 ERROR: TypeError: Cannot destructure property `__` of 'undefined' or 'null'. at Object.getErrorMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:53434:9) at Object.getMessageBody (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:53466:27) at child.findDuplicateFromMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:56190:35) at child.getDuplicateMessage (/opt/Converse Desktop/resources/app.asar/node_modules/converse.js/dist/converse.js:56155:113) log @ log.js:64

My apologies, this is for converse Desktop which is using v6.0.1. Please ignore.

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

10 participants