1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# dvm — disposable VM apps as native windows
`dvm` runs an application in a throwaway KVM virtual machine. The app's
windows show up in your Wayland session like any other app. It is the QubesOS
"disposable VM" idea on an ordinary Linux desktop, in a single Bash script.
```
dvm # Mullvad Browser in a fresh disposable VM
dvm firefox https://... # Firefox, opening a URL
dvm foot # a disposable terminal
dvm template # a terminal in the template (changes persist)
dvm update # upgrade the template, Mullvad Browser and extensions
dvm build # create the template (first time)
```
Each VM window's title starts with `[dispNNNN]`, so you can always tell which
windows belong to a VM. When you close the app, the VM powers off and its disk
is deleted.
## Requirements
- A Linux host with KVM and the `vhost_vsock` kernel module.
- A Wayland compositor. Any compositor works, because VM windows are ordinary
Wayland clients.
- `qemu-system-x86_64` with PipeWire audio (Arch: `qemu-desktop`, or
`qemu-base` + `qemu-audio-pipewire`), `passt`, `waypipe`, `xorriso`,
`curl`, `flock` (util-linux).
- Optional: `notify-send` for desktop notifications.
The guest is always Arch Linux (the official cloud image). The host can run
any distribution. If the host has `/var/cache/pacman/pkg`, the template build
reuses it.
## Install
```
make install # ~/.local/bin/dvm and app-menu entries
dvm build # download and provision the template (several minutes)
```
`make PREFIX=/usr/local install` installs it somewhere else, and
`make uninstall` removes it.
The app-menu entries are Disposable Mullvad Browser, Disposable Firefox,
Disposable Terminal and Update Disposable VM Template.
## How it works
- **Template**: the build downloads the Arch Linux cloud image, checks its
SHA-256, and provisions it once through cloud-init. It installs Firefox
(with uBlock Origin), Mullvad Browser, foot, waypipe, PipeWire and fonts,
and copies in the GTK themes from your `~/.local/share/themes`. The result
is `~/.local/share/dvm/template.qcow2`.
- **Disposable**: a copy-on-write qcow2 overlay on the template, stored in
`$XDG_RUNTIME_DIR`, which is RAM on most systems. Nothing the VM writes
reaches your disk, and the overlay is deleted when the VM exits.
- **Display**: `waypipe` on the host listens on a random vsock port. Inside
the guest, `dvm-app.service` runs `waypipe server -- <your command>` and
connects back to the host (vsock CID 2). There is no emulated screen: every
app window is a real Wayland window on your compositor. The command, the
port and your current GTK theme are passed to the guest as systemd
credentials through SMBIOS.
- **Network**: passt user-mode networking with `map-host-loopback=none`, so
the VM cannot reach services listening on the host's `127.0.0.1`. passt
opens connections from the host's own network stack, so VM traffic leaves
the same way as the host's traffic, including through a host VPN.
- **Sound**: virtio-sound to the host's PipeWire. It is playback only, so the
VM has no microphone unless you start it with `DVM_MIC=1`. The guest's
volume is fixed at 100%, which leaves the host mixer as the only volume
control.
- **Template safety**: running disposables hold a shared lock on the
template, and `dvm template` and `dvm update` need an exclusive one. This
means the backing image never changes under a running disposable.
### Mullvad Browser and extensions
Mullvad Browser is installed from the official tarball into
`/opt/mullvad-browser`. The guest script `dvm-refresh-browsers` checks that
the tarball is signed by the Tor Browser Developers key
(`EF6E 286D DA85 EA2A 4BA7 DE68 4E2C 6E87 9329 8290`) before installing it.
The browser runs in packaged-app mode, which keeps its profile in
`~/.mullvad-browser`. It runs on X11 (its default, so it looks like other
users' browsers) through waypipe's `--xwls` and xwayland-satellite.
Both browsers get their extensions from `EXTENSIONS=(vimium-c darkreader)` in
`dvm-refresh-browsers`, which lists addons.mozilla.org slugs. The XPIs are
stored in the template, and both browsers install them by policy in every new
profile. To change the list, edit it here in `dvm` before `dvm build`. On an
existing template, run `dvm template`, then
`sudoedit /usr/local/bin/dvm-refresh-browsers`, then
`sudo dvm-refresh-browsers`.
## Persistent settings
A disposable starts from the template's disk, home directory included. To
keep a setting (extension options, a proxy, browser preferences), change it
once in the template and then close the template:
```
dvm template mullvad-browser
```
Don't browse in the template. Every disposable inherits whatever the template
keeps. The build and `dvm update` start Mullvad Browser once, headless, in the
template, so first-run tabs open there and not in every disposable.
## What is and isn't isolated
The VM has its own kernel, filesystem and network stack. It cannot see your
home directory or the host's processes. It does talk Wayland to your
compositor through waypipe, which means:
- **The clipboard is shared**, as with any Wayland app, but only while a VM
window has focus. Qubes requires an explicit copy step; dvm does not.
- The guest can learn harmless facts about your display (monitor names,
scale, keyboard layout). It could also try to exploit the compositor or
waypipe, which is a larger attack surface than Qubes' minimal GUI protocol.
- Vsock ports are shared by the whole host, so one running VM can connect to
another VM's waypipe port. A disposable could therefore open windows
labelled as another one. This doesn't leak data, but you should know it.
- Inside the guest, the `user` account has passwordless `sudo`. The VM itself
is the security boundary.
dvm is not Qubes. Use it to keep risky browsing and untrusted files away from
your session and your data, not to resist a determined, targeted attacker.
## Configuration
| Variable | Default | Meaning |
|---|---|---|
| `DVM_MEM` | `4G` | VM memory |
| `DVM_CPUS` | `4` | VM CPUs |
| `DVM_DISK` | `20G` | template disk size (set at `dvm build`) |
| `DVM_DATA` | `~/.local/share/dvm` | template, cache and lock |
| `DVM_MIC` | `0` | `1` gives the VM a microphone |
| `DVM_NOTIFY` | `1` | `0` turns off notifications |
## Notifications
Each VM posts a desktop notification when it starts and replaces it when it
stops. The stop notice says how long the VM ran and whether its disk was
discarded or saved to the template.
## Troubleshooting
- `dvm build` stops with "provisioning failed": the guest's console log is
saved to `~/.local/share/dvm/build.log`. Run `dvm build` again to retry;
the downloaded base image is kept in `~/.local/share/dvm/cache/`.
- To rebuild from scratch, delete `~/.local/share/dvm/template.qcow2`.
- If a VM fails to start, `dvm` prints the last lines of its console.
## License
MIT. See [LICENSE](LICENSE).
|