Just saw this discussion More practical security for Qubes (and more realistic threat model) - #42 by 51lieal @arkenoi so I would like to share some of my experience on harden qubes VM. Basically my opinion is qubes is fantastic about compartmentalization, but abandon in VM security completely is a bad idea. Even for a amateur user like me I can feel the VM security is quite terrible. It seems the developer’s idea is to use seperate VM for every activity, so it is irrelevant to secure each single VM. My belief is XEN is not holy grail, it is not invincible like SEL4, you cannot count everything on XEN. A good secured system consists of many layers of security mechanisms, like an iPhone you need to use a chain of exploits to perform a successful and persistent hack. After spend a lot of time I just found it is almost impossible for a normal user like me to properly harden a VM, and it require systematic work plus a lot of money to bring serious OS security model like Mac OSX to qubes VM. But I will still share some of my experience, hopefully this will help people who are also thinking about this problem.
Disclaimer: I am not a professional at all, there might be (big) mistakes in my list
All things I mentioned below only applied to debian family VMs because I do not use fedora.
1.Root
Qubes leaves a passwordless root which I think is the most controversial part. A door with any crappy lock is better than an unlocked door. With an unrestricted root every other security mechanism seems pretty much pointless
This tutorial gives a dom0 root prompt solution, but I am not a security researcher and cannot verify this security model. So I took another simpler way: cut the root access.
This will purge passwordless root access and all the root operation need to be invoked from dom0 with qvm-run VMName xterm -u root
This will remove SUID and hopefully make root escalation a little bit more difficult. Because we do all the root escalation in dom0 completely, there is no point giving normal user access to sudo/su.
Comment out everything in /etc/permission-hardening.d/25_default_whitelist_sudo.conf
so normal user will just get a permission denied when try to sudo.
We need to give permission back to mount with /usr/lib/security-misc/permission-hardening-undo /usr/bin/mount
, otherwise HVM usb qubes do not boot.
2.Kernel
Model Linux Kernel is monstrously complicated for a normal end user to seriously customize/audit/secure it. Also most harden options are sadly commercial solutions. Most open projects attempt to harden kernel are dead because no body is interested/no fund to hire enough people.
Whonix has a kernel harden project but it is not seriously tested/audited, and it is still in alpha stage pretty much like all other dead kernel harden projects. It has two version: VM and host, when I test it host version simply connot compile, and VM version seems working.
This kernel harden approach is pretty aggressive, it disabled a lot of things and accordingly it breaks most applications. It is far from ready and not recommended at all.
I took another approach which is lkrg. This project exists for a really long time and is developed by reputable developers, hopefully this can increase the ability for our buggy kernel to fend off exploits.
ht tps://www.qubes-os.org/doc/managing-vm-kernels/
First install in vm kernel and all other dependencies, and then you should install grub2-xen-pvh in dom0. This part is not mentioned in the previous document and I have spent a hell amount of time to figure out how to have pvgrub2-pvh
in my dom0 setting. Use uname -a in vm terminal, if you do not see qubes in kernel name everything worked.
Then follow this tutorial to install lkrg
Use dkms status
to make sure lkrg is loaded
Also if you do not use the stock kernel shipped by dom0, VMs cannot boot when you try to launch them with over 4GB ram with your customized kernel. Kernel equipped with lkrg also breaks firejail+chromium combo.
3.GUI
GUI is the most tricky and annoying part. Qubes VM are still using X11 which is notoriously insecure. It is not designed with security in mind and a huge escalation vector. Obviously there is no way for me to replace it by wayland, this requires a huge overhaul of all there qubes service software. The only thing I can do is to attempt to sandbox applications, so it cannot simply escalate through X11 and make all of my previous hardening attempt pointless. Current the solution I can find is to use the graphic server isolaion function of firejail. Firejail is not a very good sandbox, it has a huge codebase and has many CVE discovered in the past, but anyway it is better than a big exposed X11 server. There are three possible solutions that possibly work(yes possibly) under qubes.
First is firejail --X11=xorg firefox/chromium/etc… This is the solution that work out of the box, it puts programs in a untrusted domain of xorg. This disable the pasteboard function, and it breaks some programs like libreoffice because most programs just assume they are in a trusted xorg domain.
Second is firejail -X11=xpra The windows crashes several seconds no matter what you do, cannot figure this out
Third is firejail --X11=xephyr This will not crash, but it display things in a extremely weird resolution and I cannot figure out how to fix it
Also there are some document says you need to set up a separate network device with --net
option for programs otherwise they can escape through network socket. But I do not have enough knowledge to verify and tinker this thing
4.MAC
I seriously cannot understand why qubes do not enable MAC by default, MAC is the standard equipment for all modern desktop and mobile OS.
Also whonix has a fancy new toy called apparmor-profile-everything which intends to bring the way how mobile OS confines app to whonix, but it is still highly experimental and it breaks qubes VM.
5.Sandbox
I can feel there are still a huge amount of potential vulnerability in the OS, because security is a systematic work and it requires everything to be perfect otherwise everything is pointless. So I decide to sandbox all the applications to further increases the escalation difficulty of a potential hack.
Whonix also has a fancy toy called bubblewrap, but again it is not production ready. The only option we have right now is firejail. Again firejail is buggy, but debian only use the lts version of it, and plus we will apply some hardening options hopefully this increase the overall security instead of make things worse.
This document talked about how to use and harden firejail
Also some posts say firejail might increase fingerprint of torbrowser, but I do not have proper knowledge to verify that
6.Root of trust
Qubes OS has something called AEM, which is to be honest not quite user friendly and most important it is not compatible with TPM 2.0 . Most modern devices is only equipped with TPM 2.0, and obviously AEM do not work on my device. Also there is a solution called heads which is a serious secure boot solution, but again it only works on those ancient machines, and at the time I tested it it only worked out of box for x230. If qubes cannot boot from a ensure trusted state, all the glorious work like XEN, compartmentalization, and qrexec will be pretty much pointless. Currently I did some little tricks to determine if someone has tried to open the back cover of my computer, but qubes really need some strong secure boot mechanism that works out of box like MAC OSX.
This is everything I have done currently, and I think I have reached the limit of an end user. I will add more when I have time. A good secured OS requires some serious security engineering and design from the ground up. I have used Qubes OS for many years and saw how it grew up from an idea, and I have seen no reason it should not further increases its security.