An lxc container does not have a display/audio of its own, so it must somehow use the host display/audio. A typical linux solution would be either of
- share host X resources directly across the container boundary
- use X forwarding over an ssh reverse pipe
The problem with either of those solutions is that something evil on the container
might take control via X to view windows or capture key strokes, etc. X was not designed with that kind of security in mind.
Another solution would be to use what might be called a masquerade X server, which is not really an X server but presents an pseudo X interface and a pseudo X screen to the client software on the container, while passing some X work off to the real X server behind it. The psuedo X screen is displayed as a single X window on the host actual X desktop.
One such masquerade X server is the software Xephyr in the xserver-xephyr
which was actually developed for X developers debugging.
I wrote a simple javascript program to create (from a vanilla ubuntu lxc image) an lxd/lxc container populated with firefox, openvpn, Xephyr , and pulseaudio. Target host is also Ubuntu. VPN forwards all the ip traffic to a VPS.
https://github.com/craigphicks/browser-on-lxc-vpn-xephyr
https://www.npmjs.com/package/browser-on-lxc-vpn-xephyr
Ultimately, when considering vulnerability from Specter et. al., even a container offers no guarantee - a separate physical CPU is required to achieve theoretical perfect defense. (The actual degree of threat is arguable - no wild exploits have been reported a year on). As a solution it would be easy enough to put a container on another machine.
That might protect the host machine (or might not - I make no promise). However, usually the browser is used for entering lots of sensitive information - passwords and OTPs. SIP and social distancing is the best security but it's not a great lifestyle.