qubes-issues icon indicating copy to clipboard operation
qubes-issues copied to clipboard

Rewrite Thunderbird Qubes extension as a MailExtension

Open DemiMarie opened this issue 4 years ago • 51 comments

Qubes OS version Qubes release 4.0 (R4.0)

Affected component(s) or functionality thunderbird-qubes

Brief summary The Qubes integration with Thunderbird uses a legacy extension that will break in Thunderbird 78.

To Reproduce vim /usr/lib64/mozilla/extensions/*/[email protected]/manifest.json

Expected behavior No legacy key

Actual behavior A legacy key is present.

Screenshots N/A

Additional context I am not sure if this is possible, given the need to override core functionality of Thunderbird. We should probably discuss this with Mozilla. Mozilla accepts feature requests for extension APIs, and provides a method (experiments) for implementing workarounds in the meantime. This will be disabled eventually, but not for years.

Solutions you've tried N/A

Relevant documentation you've consulted https://developer.thunderbird.net/add-ons/about-add-ons

Related, non-duplicate issues none

DemiMarie avatar May 28 '20 07:05 DemiMarie

It's on the roadmap. It's plan for ~September. Especially related to the MOSS fund.

fepitre avatar May 28 '20 07:05 fepitre

Darn! Thunderbird 78 will come out before then, so thunderbird-qubes will be broken.

(I understand that the resources to do it sooner aren't there.)

DemiMarie avatar May 28 '20 08:05 DemiMarie

Darn! Thunderbird 78 will come out before then, so thunderbird-qubes will be broken. (I understand that the resources to do it sooner aren't there.)

will they stop supporting earlier versions with the release of tb78?

0spinboson avatar May 28 '20 09:05 0spinboson

@0spinboson Yes, if i understand correctly.

DemiMarie avatar May 30 '20 17:05 DemiMarie

@fepitre will we be working with Mozilla to get any new extension APIs needed merged?

DemiMarie avatar May 30 '20 17:05 DemiMarie

Maybe monkey-patching via Mozilla AutoConfig - like https://github.com/girst/LegacyFox - could bridge the gap until the MailExtension rewrite?

rustybird avatar May 30 '20 19:05 rustybird

Edit: My apologies, I was discussing split-gpg compatibility, I have created a new ticket for that.

mfc avatar Jun 03 '20 14:06 mfc

Thunderbird 78.3.1 has now been released in the Fedora stable repo, so users on v68 will be automatically updated.

Geblaat avatar Oct 06 '20 16:10 Geblaat

Thunderbird 78.3.1 has now been released in the Fedora stable repo, so users on v68 will be automatically updated.

Landed here after my fedora 32 vm updated today and I got Thunderbird 78 and am no longer able to open attachments in DispVMs. :(

Perhaps a message/announcement to one of the qubes lists is warranted to tell people? This could be considered a security issue (security guard was there and is now gone).

The new PGP system works great with split-gpg however, no issues there.

abeluck avatar Oct 08 '20 07:10 abeluck

Perhaps a message/announcement to one of the qubes lists is warranted to tell people?

Sure, I'll send a message to the mailing lists, but unfortunately all I can say is that it's a known issue and link here.

This could be considered a security issue (security guard was there and is now gone).

I don't see how. The Qubes extension is purely for convenience. It’s not required to do anything. You can do everything that the extension does manually. For example, to open an email attachment in a DisposableVM:

  1. Save the attachment in your email VM.
  2. Start a DisposableVM.
  3. In your email VM, qvm-copy the attachment to the DisposableVM.
  4. In the DisposableVM, open the attachment.

The extension makes this a lot more convenient by automating the process, but it doesn't do anything that you can't do yourself.

Discussion: https://qubes-os.discourse.group/t/thunderbird-qubes-attachments/865/

andrewdavidwong avatar Oct 08 '20 07:10 andrewdavidwong

Actually, an even easier version:

  1. Save the attachment in your email VM.
  2. Right-click on the attachment and select "View in DisposableVM."

andrewdavidwong avatar Oct 08 '20 07:10 andrewdavidwong

That is of course also possible. I myself had the extension set to open in DispVM by default, so I only need to click the attachment from within Thunderbird. Luckily I knew Thunderbird had updated, otherwise I would have continued doing so and accidentally opened the attachment inside my mail appvm. Thanks for adding a message to the mailing list, at least now users are warned.

Geblaat avatar Oct 08 '20 18:10 Geblaat

Guess the suggested manual procedure is inconvenient enough so that people will not do it.

So in the end, we'll have less security until someone makes the thunderbird extension work again.

ThomasWaldmann avatar Oct 20 '20 21:10 ThomasWaldmann

Users of Debian 10 are affected by this problem as well.

Yes, it is a more painful to follow manual steps.

And @andrewdavidwong is missing one step above: deleted the attachment from the email VM

nereocystis avatar Oct 23 '20 16:10 nereocystis

And @andrewdavidwong is missing one step above: deleted the attachment from the email VM

I considered adding that but decided against it because:

  1. It's not required to view the file in a DisposableVM.
  2. It's obvious. Users already know that they can delete files they no longer want.

andrewdavidwong avatar Oct 24 '20 10:10 andrewdavidwong

I just upgraded Thunderbird and found the following workaround for the missing plguin (in fact I consider this more than just a workaround because it avoids many cases of inadvertend mis-use of the Mail-VM):

Edit: This workaround contained some mistakes. I fixed them here and posted the approach to the Qubes forum as well (https://qubes-os.discourse.group/t/guide-hardening-your-thunderbird-mail-vm-and-working-around-the-still-missing-qubes-attachments-plugin/1432). If something doesn't work for you, feel free to join the discussion over there (as it's not directly related to the Thunderbird extension itself I suppose we shouldn't flood this issue with more postings about workarounds).

In a Terminal of your mail VM execute the following:

  • sudo cp /usr/share/applications/mimeapps.list /home/user/.config/mimeapps.list
  • sudo sed -i "s/=.*/=open_in_dispvm.desktop;/g" /home/user/.config/mimeapps.list

These two commands set an application "open_in_dispvm" as the default value for all mime-types that the system knows about. Now create this application and make it execute anything in a VM of your choice:

  • nano /home/user/.local/share/applications/open_in_dispvm.desktop

Enter the following:

Encoding=UTF-8
Name=Open_in_DispVM
Exec=qvm-open-in-vm <VM_OF_YOUR_CHOICE> %u
Terminal=false
X-MultipleArgs=false
Type=Application

Instead of <VM_OF_YOUR_CHOICE>, specify the name of an existing VM. Now, whenever you click on an application it should call "qvm-open-in-vm" instead of opening it inside of the Mail VM. You could also call qvm-open-in-dvm instead.

Personally, I combine it with a modified RPC-policy in dom0:

  • In a dom0 terminal, do sudo nano /etc/qubes-rpc/policy/qubes.OpenInVM. Replace whatever might be there with <NAME_OF_YOUR_MAIL_VM> $anyvm ask.

That way, every time I try to open anything in the mail VM Qubes does not just use the <VM_OF_YOUR_CHOICE> that I specified in the .desktop-file, but asks me in which VM I want to open it and I can easily redirect everything as I wish:

  • something I want to print goes to my print VM
  • a hyperlink could be opened in a new dispVM
  • or I could choose to open it in an already existing VM
  • ...

shaaati avatar Nov 10 '20 13:11 shaaati

2\. obvious

Yes, deleting the file obvious, but it is one more step to the process, which makes it less likely to be done.

Of course, leaving the file around is not a security risk, but what is a security risk is deciding that there are too many steps for safety, and then just opening the file in the thunderbird VM. That is what makes this less safe.

nereocystis avatar Nov 10 '20 17:11 nereocystis

Changes in TB78+ requires basically rewriting the extension from scratch. Here are some hints about the new API, including similar extension: https://developer.thunderbird.net/add-ons/updating/tb78 https://github.com/HiraokaHyperTools/OpenAttachmentByExtension/pull/2/files

marmarek avatar Nov 23 '20 18:11 marmarek

Looks like we will need to use an experiment for this, as we need to both run external commands (which obviously is only possible from a privileged context) and to override a core part of the Thunderbird UI.

DemiMarie avatar Nov 23 '20 19:11 DemiMarie

Yes

marmarek avatar Nov 23 '20 19:11 marmarek

I am going to get in contact with the Thunderbird developers and try and come up with a plan.

DemiMarie avatar Nov 23 '20 19:11 DemiMarie

@marmarek The API provided by the oabe experiment is sufficient, but it has no chance of being upstreamed, as it allows the extension to execute arbitrary commands. This contradicts one of the major goals of WebExtensions, which is to remove extensions from the trusted computing base.

The sanctioned way for a WebExtension to interact with native code is Native Messaging. Native Messaging requires a host process, which we would need to implement ourselves. Additionally, I am not sure how well an API that changed the default handler for downloads would be received at Mozilla.

Another option is to change the OS file associations ourselves, so that every file opens in a DispVM by default. This is actually a more general approach, since it affects not only Thunderbird but also Nautilus, xdg-open, and any other program that respects file associations.

DemiMarie avatar Nov 25 '20 21:11 DemiMarie

Another option is to change the OS file associations ourselves, so that every file opens in a DispVM by default.

In case of dedicated qube for mails that should be fine, but I'm afraid it doesn't work for less strict compartmentalization, like generic "work" qube, where you may want to open some files locally.

What are the practical downsides of shipping an extension with oabe experiment included?

marmarek avatar Nov 25 '20 21:11 marmarek

None per se, but we will need to rewrite the extension at some point in the future.

DemiMarie avatar Nov 25 '20 21:11 DemiMarie

Part of this will require some HTML/CSS for the user interface, @andrewdavidwong can you help when @DemiMarie provide details what exactly is needed?

marmarek avatar Dec 18 '20 02:12 marmarek

Part of this will require some HTML/CSS for the user interface, @andrewdavidwong can you help when @DemiMarie provide details what exactly is needed?

Yes, I'd be happy to help!

andrewdavidwong avatar Dec 18 '20 02:12 andrewdavidwong

@marmarek @andrewdavidwong I just got some good news from the Thunderbird team: they will be extending the context menu API to include the attachment menu. That makes implementing this much easier.

DemiMarie avatar Dec 19 '20 18:12 DemiMarie

This won’t happen for another month or so, minimum. Is it worth waiting until then?

DemiMarie avatar Dec 21 '20 15:12 DemiMarie

The current plan is to replace the Thunderbird extension with a more general system that works for other applications as well. @marmarek can this be closed as “won’t fix”?

DemiMarie avatar Jan 21 '21 00:01 DemiMarie

We still want at some point an extension adding actions like "save to another qube".

marmarek avatar Jan 21 '21 00:01 marmarek