Qubes-Community-Content/docs/common-tasks/opening-urls-in-vms.md

155 lines
8.4 KiB
Markdown
Raw Normal View History

2018-09-26 12:34:56 -04:00
How to open URLs/files in other VMs
2018-09-27 13:31:52 -04:00
===================================
2018-09-25 16:04:29 -04:00
2018-09-27 13:31:52 -04:00
This document describes how to open files/attachments/URLs in another VM, with or without user confirmation. This setup particularly suits "locked down" setups with restrictive firewalls like VMs dedicated to emails.
2018-09-27 04:04:45 -04:00
Naming convention:
- `srcVM` is the VM where the files/URLs are
- `dstVM` is the VM we want to open them in ; `dstVM` can be any VM type - a DispVM, a regular AppVM, a Whonix dvm, ...
2018-09-25 16:04:29 -04:00
2018-09-27 04:04:45 -04:00
Configuring dom0 RPC permissions
--------------------------------
2018-09-25 16:04:29 -04:00
2018-09-27 13:31:52 -04:00
There are different approaches to open files and URLs in other VMs but they all rely on the `qubes.OpenInVM` and `qubes.OpenURL` [RPC services](https://www.qubes-os.org/doc/qrexec3/#qubes-rpc-services), usually through the use of the `qvm-open-in-vm` and `qvm-open-in-dvm` shell scripts in `srcVM`.
2018-09-27 04:21:05 -04:00
2018-09-27 13:31:52 -04:00
Qubes RPC policies can be configured based on the service name and `srcVM` (+ optionally `dstVM`) to allow or deny the use of the service, or to ask user confirmation with a popup list of destination VMs. See the [official documentation](https://www.qubes-os.org/doc/rpc-policy/).
In the case that an `allow` policy is configured (ie. no user confirmation/popup dialog) *and* that different destination VMs are to be used - eg. depending on the URL/file (site's level of trust, protocol, file [MIME](https://en.wikipedia.org/wiki/Media_type) type, ... - it is up to `srcVM` to specify the right `dstVM`, with the help of a custom wrapper to the `qvm-open-in-vm` script, or a specific application add-on.
2018-09-25 16:04:29 -04:00
2018-09-27 04:04:45 -04:00
Configuring `srcVM`
-------------------
2018-09-27 05:45:58 -04:00
The subsections below list various approaches.
2018-09-27 13:31:52 -04:00
### Inter-VM copy/paste and file copy ###
2018-09-27 05:45:58 -04:00
2018-09-27 13:31:52 -04:00
This approach is obvious and is the simplest one:
2018-09-27 05:45:58 -04:00
2018-09-27 13:31:52 -04:00
- URLs: [copy/paste](https://www.qubes-os.org/doc/copy-paste/) the link in `dstVM`.
- Files: [copy](https://www.qubes-os.org/doc/copying-files/) the file to `dstVM` (provided that `qubes.Filecopy` RPC service's policy allows it - it does by default), and open it from there.
2018-09-27 04:21:05 -04:00
2018-09-25 16:04:29 -04:00
### Command-line ###
2018-09-27 05:45:58 -04:00
Another obvious and basic approach - but less convenient - is to open files or URLs in a terminal in `srcVM`:
2018-09-25 16:04:29 -04:00
~~~
qvm-open-in-vm dstVM http://example.com
qvm-open-in-vm dstVM word.doc
~~~
Or, if opening in random dispVMs:
~~~
qvm-open-in-dvm http://example.com
qvm-open-in-dvm word.doc
~~~
Note: `qvm-open-in-dvm` is actually a wrapper to `qvm-open-in-vm`.
2018-09-25 16:04:29 -04:00
### Per application setup ###
2018-09-27 13:31:52 -04:00
Most applications provide a way to select a given program to use for opening specific URL/file (MIME) types. We can use that feature to select the `/usr/bin/qvm-open-in-{vm,dvm}` scripts instead of the default programs.
2018-09-27 04:04:45 -04:00
2018-09-27 05:21:21 -04:00
The subsections below show how to configure popular applications.
2018-09-25 16:04:29 -04:00
#### Thunderbird ####
2018-09-27 13:31:52 -04:00
Opening attachements: "actions" must be defined for opening attachements; see [this document](http://kb.mozillazine.org/Actions_for_attachment_file_types), section "Download Actions" settings".
Opening URLs: changing the way http and https URLs are opened requires tweaking configuration options; see [this](http://kb.mozillazine.org/Changing_the_web_browser_invoked_by_Thunderbird) and [this](http://kb.mozillazine.org/Network.protocol-handler.expose-all) document for more information. Those changes can be made in Thunderbird's built-in config editor, or by adding the following lines to `$HOME/.thunderbird/user.js`:
2018-09-25 16:04:29 -04:00
~~~
user_pref("network.protocol-handler.warn-external.http", true);
user_pref("network.protocol-handler.warn-external.https", true);
user_pref("network.protocol-handler.expose-all", true);
~~~
2018-09-27 13:31:52 -04:00
Thunderbird will then ask which program to use the next time a link is opened. If `dstVM` is a standard (random) dispVM, choose `/usr/bin/qvm-open-in-dvm`. Otherwise you'll have to create a wrapper to `qvm-open-in-vm` since arguments cannot be passed to programs selected in Thunderbird's dialog gui. For instance, put the following text in `$HOME/bin/thunderbird-open-url`, make it executable, and select that program when asked which program to use:
2018-09-25 16:04:29 -04:00
~~~
#!/bin/sh
qvm-open-in-vm dstVM "$@"
~~~
2018-09-25 16:04:29 -04:00
#### Firefox, Chrome/Chromium ####
2018-09-27 13:31:52 -04:00
Those browsers have an option to define programs associated to a file (MIME) type. It is pretty straightforward to configure and is outside the scope of this document.
2018-09-27 04:04:45 -04:00
2018-09-27 13:31:52 -04:00
An alternative is to use Raffaele Florio's [qubes-url-redirector](https://github.com/raffaeleflorio/qubes-url-redirector) add-on, which provides a lot of flexibility when opening links without the hassle of having to write custom shell wrappers to `qvm-open-in-vm`. For instance links can be opened with a context menu and the add-on's default behavior can be configured, even with whitelist regexes.
2018-09-27 05:21:21 -04:00
2018-09-27 13:31:52 -04:00
Note: the qubes-url-redirector add-on will likely be included officialy in the next Qubes release (see [this](https://github.com/QubesOS/qubes-issues/issues/3152) issue). The addon may also support Thunderbird in the future.
2018-09-25 16:04:29 -04:00
#### Vi ####
2018-09-27 13:31:52 -04:00
Opening URLs: put the following in `$HOME/.vimrc`:
2018-09-25 16:04:29 -04:00
~~~
let g:netrw_browsex_viewer = 'qvm-open-in-vm dstVM'
~~~
2018-09-27 13:31:52 -04:00
Typing `gx` when the cursor is over an URL will then open it in `dstVM`.
2018-09-25 16:04:29 -04:00
2018-09-27 13:31:52 -04:00
### Application independent setup ###
2018-09-25 16:04:29 -04:00
2018-09-27 13:31:52 -04:00
Configuring *each* application provides a good amount of flexibility but it may not be the best approach when one wants to use the same action/program in *all* the applications in `srcVM`. In that case, provided that the applications adhere to the [freedesktop](https://en.wikipedia.org/wiki/Freedesktop.org) standard, defining a global action for a given URL/file (MIME) type is straightforward:
2018-09-25 16:04:29 -04:00
- put the following in `~/.local/share/applications/browser_vm.desktop`
~~~
[Desktop Entry]
Encoding=UTF-8
Name=BrowserVM
2018-09-27 04:04:45 -04:00
Exec=qvm-open-in-vm dstVM %u
2018-09-25 16:04:29 -04:00
Terminal=false
X-MultipleArgs=false
Type=Application
Categories=Network;WebBrowser;
MimeType=x-scheme-handler/unknown;x-scheme-handler/about;text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;
~~~
- set xdg's "default browser" to the .desktop entry you've just created with `xdg-settings set default-web-browser browser_vm.desktop`
The same can be done with any Mime type (see `man xdg-mime` and `xdg-settings`).
2018-09-27 13:31:52 -04:00
Again, `qvm-open-in-vm dstVM` can be replaced by a user written wrapper with custom logic for selecting a specific dstVM depending on the URL/file type, site level of trust, ...
2018-09-25 16:04:29 -04:00
2018-09-27 05:21:21 -04:00
**Caveat**: if dom0 default permissions are set to allow without user confirmation applications can leak data through URLs despite `srcVM`'s restrictive firewall (you may notice that an URL has been open in `dstVM` but it would be too late).
2018-09-25 16:04:29 -04:00
2018-09-27 04:04:45 -04:00
"Semi-permanent" named dispVMs
------------------------------
2018-09-25 16:04:29 -04:00
Opening things in dispVMs is the most secure approach, but the long starting time of dispVMs often gets in the way so users end up opening files/URLs in persistent VMs. An intermediate solution is to create a "semi-permanent" dispVM like so (replace `fedora-28-dvm` with the dvm template you want to use):
2018-09-25 16:04:29 -04:00
~~~
qvm-create -C DispVM -t fedora-28-dvm -l red dstVM
~~~
This VM works like a regular VM, with the difference that its private disk is wiped after it's powered off. However it doesn't "auto power off" like random dispVMs so it's up to the user to power off (and optionaly restart) the VM when he/she deems necessary.
2018-09-25 16:04:29 -04:00
2018-09-27 04:04:45 -04:00
Further considerations/caveats of using dispVMs
-----------------------------------------------
Obviously, using dispVMs as `dstVM` means that changes are lost when `dstVM` is powered off so the increased security of this setup makes saving deliberate changes harder.
2018-09-27 13:31:52 -04:00
- inter-VM copy/paste is probably the easiest way to synchronize text between `dstVM` and `srcVM` (or another dedicated secure VM like the oft-used 'vault' VM). Eg.:
- passwords: copy/paste from/to KeepassX (or one of its forks).
- bookmarks: copy/paste from/to a plain text file, or an html file (like most browsers can export/import), or a dedicated bookmark manager like [buku](https://github.com/jarun/Buku) (command line manager, available in Fedora 28 repo - `dnf install buku`).
- other content/changes will have to be copied, usually to `dstVM`'s templateVM. Care must be taken not to replicate compromised files: working with a freshly started `dstVM` and performing only the required update actions before synchronizing files with the templateVM is usually a good idea.
2018-09-25 16:04:29 -04:00
2018-09-27 13:31:52 -04:00
---
2018-09-27 13:31:52 -04:00
`Contributors`: @Aekez, @taradiddles
2018-09-27 04:04:45 -04:00
2018-09-27 13:31:52 -04:00
`Credits:` @raffaeleflorio, [Micah Lee](https://micahflee.com/2016/06/qubes-tip-opening-links-in-your-preferred-appvm/)