freedomofpress / dangerzone

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs
https://dangerzone.rocks/
GNU Affero General Public License v3.0
3.75k stars 172 forks source link

Qubes: Checking if it has the RPC Policy and Services prior to Starting Conversion #623

Open apyrgio opened 1 year ago

apyrgio commented 1 year ago

The Qubes package of Dangerzone (https://github.com/freedomofpress/dangerzone/issues/431) currently ships with some RPC services that are necessary for running Dangerzone. In order to let a qube use these services, the admin needs to create some policy files in dom0. If they haven't done so, Dangerzone will crash.

Ideally, we'd want Dangerzone to catch such errors before startup. In broad terms, we want Dangerzone to query if it has the capabillity and the permission to use an RPC service. What follows is a summary of a discussion we had with @rocodes on this very subject.

Capabilities

  1. RPC services are stored under the /etc/qubes-rpc directory. Assuming that the current qube has the same services as the target qube, then checking the local /etc/qubes-rpc directory is a valid way to query if it can run an RPC service.
    • Note that this assumption can break if we choose to install the dz.Convert RPC service solely in the disposable template.
  2. Qubes has a Features mechanism, that can be used to advertise a specific feature or RPC service: https://dev.qubes-os.org/projects/core-admin/en/latest/qubes-features.html

Permissions

  1. The canonical way to check if a qube has permission to perform an action is to use the Policy Admin API: https://www.qubes-os.org/doc/admin-api/#policy-admin-api
rocodes commented 1 year ago

Thanks for filing @apyrgio :) A couple notes:

I didn't understand the whole context of your question when we chatted earlier, but now that you lay it out like this, it sounds like there are 2 questions:

So in this sense it's not exactly that you need a supported feature in the vm, it's kind of the opposite (you basically know you have what you need in the VM because dz is installed and wants to run, and now you're wondering if you have what you need in dom0, which is the policy file).

A couple options:

rocodes commented 1 year ago

Lastly, there are lots of flavours/variants of the above (so for example, you could write a custom qubes-features extension that, if the dangerzone RPM is installed and the dz vm sends a features-request to dom0, dom0 checks the policy files and adds them if they're missing.) However, this also falls into the "install an rpm on dom0" category so I didn't mention it.

Similarly, there are probably a few ways to do this with qvm-features and friends (such as vm-config) -- they're all part of the same "family" of ideas, whether you use a service, feature, or vm-config.

Hope this is helpful :)

apyrgio commented 1 year ago

Thanks for the amendments Ro. From what I understand, you're introducing one more dimension in this problem, whether the qube can trust the capabilities that another qube presents. Truth is, as you pointed out later on, in our case we have a single qube that needs to decide that for itself, which simplifies things a bit. Still, this dimension may prove important during the SecureDrop integration phase.

capabilities of vms/qubes can be queried either by dom0 or by an adminvm

I stand corrected. I'll edit my original post, thanks!

you basically know you have what you need in the VM because dz is installed and wants to run, and now you're wondering if you have what you need in dom0, which is the policy file

Exactly, but it doesn't hurt having a general idea of how to query about qube capabilities. just in case it helps in the SecureDrop integration phase.

A similar kind of funny example is https://github.com/freedomofpress/securedrop-client/pull/1552, yours would be slightly closer to the intended usage.

Nice, I didn't know we had a way to pass service flags this way :slightly_smiling_face:

So from dom0 you would have the user set the RPC policies then run qvm-service --enable $dz-dvm dangerzone.

That's great! And the fact that we can run this at the template level, where we install Dangerzone, is also amazing.

deeplow commented 1 year ago

Thanks for staring this discussion and for your inputs @rocodes. I rephrased the title a little to make it a bit more actionable and concrete as it took me some time to realize what the purpose of this issue was.

I think addressing this is necessarily part of a bigger discussion in https://github.com/freedomofpress/dangerzone/issues/530 over how the multi-VM architecture of Dangerzone will be.

To do this in an automated way it seems clear that we'll need some higher privileged vantage point to be able to tell that the dangerzone disposable qube has the right qrexec services (capabilities in your terminology if I understood correctly) and that dom0 has the right policy files (permissions).

The big question is where this vantage point should be located? AdminVM or dom0? That's the big question of #530.

rocodes commented 12 months ago

@deeplow totally agree. I am kind of biased towards an adminvm, and towards seeing if we can eventually transition sdw to an adminvm too, because if the whole pattern of multi-vm Qubes applications becomes "now we have to install an RPM in dom0", that feels counter to the way Qubes is designed. But there is definitely more discussion needed - and thanks for pointing out your Multi VM architecture issue :)

@apyrgio I'm not sure that you want service flags in the template, in fact you might specifically not want that (because you never want to execute programs from your template, so you might want a setup where only the exact appvm/dispvm that can run the programs you want has the service enabled, and it's disabled/disallowed everywhere else). But perhaps I am misunderstanding you (and also, I think this is a detail that can be figured out after some of the bigger questions).