r/AlpineLinux • u/yoyo-blue-70 • Jun 15 '26
Browser sandboxing: flatpak vs bubblewrap vs VM + X11 Forwarding vs VM + vsock waypipe vs VM + spice / qxl
Hi,
I have been playing with the various ways we can sandbox web browsers.
Those are the options I see
- Flatpak
- Raw Bubblewrap
- Podman
- VM + X11 Forwarding
- VM + vsock + waypipe
- VM + spice / QXL
I currently use chromium under Flatpak but have also played with with raw bubblewrap which get quite complex quickly and can be a hit or miss.
Also I see that Flatpak is getting more and more dependent on systemd so it might not be a long term solution for us Alpine users?
I haven't looked into what are the trade-offs doing it with podman.
I am now looking into running a full VM dedicated to the web browser. In terms of perfs it might be viable since Alpine is so lightweight (even on the Intel N100 I am currently using). The approach would be similar to QubeOS I guess.
VM + X11 Forwarding via SSH works but the perf are a bit disappointing. I haven't tried going into optimizing it since Xorg might be less and less supported at the driver level, etc.
VM + vsock + waypipe is interesting.
From what I understand virtual sockets would offer the best performance to connect to the VM by enabling Virtio VSOCK for the VM and then running `socat VSOCK-LISTEN:1234,reuseaddr,fork TCP:localhost:1234` in the guest (since Alpine do not have the systemd socket activation thing builtin).
The communication works.
I am now trying to make waypipe works with vsock (https://gitlab.freedesktop.org/mstoeckl/waypipe/-/blob/v0.11.0/waypipe.scd?ref_type=tags#L260) but no success so far since I guess I need to run a headless compositor first.
I am wondering what the performance will be and maybe I won't be able to fully leverage the capabilities of graphical acceleration (OpenGL, vulkan, decoding, etc.) in the browser. I do not fully understand how wayland/waypipe works.
I also thought that exposing the memory of the vm directly in the host might be possible and have waypipe use it directly might be in theory possible but haven't dig deeper.
VM + spice/qxl
Also leveraging spice and running chromium in a kiosk compositor like cage might actually offer the best performance ? I haven't tried yet.
My questions are:
What are your thoughts on this?
If you tried the VM approach, what offered the best performance at the end?
Thanks !
3
u/4SubZero20 Jun 15 '26 edited Jun 15 '26
So it seems like you want to sandbox your browsing experience?
Why not just try a docker container with a browser? https://hub.docker.com/r/linuxserver/firefox
There are multiple containers each with a different browser to choose.
It might be far easier running this than setting up an entire VM and far easier on resources?
All you would need to do is, in your desktop browser, go to http://localhost:[port] (3001 as per docs) and you'll each the container browser. Browse from there.
It's essentially a browser-in-browser experience.
So some additional security/privacy, you can also hook-up the browser container to a
gluetuncontainer and have a permanent VPN going.Edit: A drawback of this approach is that you could lose hardware acceleration for your browser. I tried this recently, and even though I passed through my gpu (and the container-browser did see/recognise it), the browser just didn't do the gpu/hardware acceleration, so I was stuck using cpu. (Haven't tried solving it again yet)
3
u/Eirafall Jun 15 '26
Last I checked using Chromium based browsers packaged as a flatpak is considered a sandboxing degradation. Something to do with how they are packaged breaks the sandboxing built into Chromium. As a result the security focused distro SecureBlue installs its Chromium fork Trivalent as non flatpak, which is a notable choice since the immutable Silverblue distros primarily depend on Flatpaks. I believe Firefox has a similar situation.
2
u/yoyo-blue-70 Jun 17 '26
One option I haven't thought about is using LXC containers. I am quite unfamiliar with LXC but it is in many way more simple than the whole docker/podman/oci thing.
This might end up quite similar to FreeBSD users running their web browsers in a jail. At the end it might be a good performance/complexity/security tradeoff.
There are a few people explaining how to do GUI apps https://osamuaoki.github.io/en/2023/11/14/lxc-4/
2
u/Brave_Confidence_278 Jun 15 '26
flatpak, bubblewrap and podman are all more or less the same (namespaces and cgroups). VMs have a stronger isolation, but are less comfortable to use IMO. If you really want isolation, I personally would stick to flatpak for now because it's use case is exactly this. I am sure someone will fork it if systemd becomes a problem
one thing to keep in mind: browsers already natively use namespaces and cgroups to isolate, so you would just add another layer of the same kind of isolation on it
2
u/Qigong1019 Jun 18 '26 edited Jun 18 '26
I use podman, although I still need to attack my containers. Here are my reasons for distrobox/podman :
All my dev and browsing is done like this. You can have different browser containers for different purposes. A risky/sloppy browse, a separate Chrome & GOffice thing, email container, a social network container, etc. I can't think of a more handy way to do this. I think docker is too detailed, and podman is daemonless.