Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable AppArmor by default #4088

Closed
adrelanos opened this issue Jul 16, 2018 · 15 comments · Fixed by QubesOS/qubes-core-admin#368
Closed

enable AppArmor by default #4088

adrelanos opened this issue Jul 16, 2018 · 15 comments · Fixed by QubesOS/qubes-core-admin#368
Labels
C: templates P: major Priority: major. Between "default" and "critical" in severity. release notes This issue should be mentioned in the release notes. security This issue pertains to the security of Qubes OS. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.
Milestone

Comments

@adrelanos
Copy link
Member

Technically, add apparmor=1 security=apparmor to kernelopts.

qvm-prefs -s vmname kernelopts "nopat apparmor=1 security=apparmor"

For Debian templates I don't foresee any issues. For Whonix templates I foresee even less issues. Other templates, no idea.

What is the plan regarding 'VM kernel by default'?
(I am not advocating either dom0 or VM kernel. Just asking.)

@adrelanos
Copy link
Member Author

In case this is a no or inconclusive I would back up to a separate ticket enable AppArmor by default for Qubes-Whonix.


For Whonix it's sane to enable AppArmor by default since we don't ship AppArmor profiles by default which have potential to break in bad ways. (Such as for Tor Browser which has its own updater so Tor Browser might rush ahead and do things which are not covered by apparmor-profile-torbrowser.) We only ship AppArmor profiles for packages which are upgraded through Debian apt package management which undergo testing before flowing into the stable repository (such as for Tor, sdwdate, ...).

AppArmor enabled by default in Non-Qubes-Whonix for many releases.

Package https://github.com/Whonix/grub-enable-apparmor only works when using VM kernel.

Related:

@marmarek
Copy link
Member

What is the plan regarding 'VM kernel by default'?

For now it is blocked by being incompatible with PVH :/

@andrewdavidwong andrewdavidwong added T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality. C: templates security This issue pertains to the security of Qubes OS. labels Jul 17, 2018
@andrewdavidwong andrewdavidwong added this to the Release 4.1 milestone Jul 17, 2018
@lunarthegrey
Copy link

AppArmor works good in my PVH VMs, been using it for a while now. I don't think it's installed by default in the Debian template if I can remember correctly.

@jpouellet
Copy link
Contributor

Is this now unblocked by QubesOS/qubes-linux-kernel@96b8fba?

/cc @HW42

@andrewdavidwong andrewdavidwong added the P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. label Jun 25, 2019
@adrelanos
Copy link
Member Author

Ignoring the news of QubesOS/qubes-linux-kernel@96b8fba - recently I added to Whonix wiki:

While Debian enabled AppArmor by default since Debian buster, Fedora does not. This matters since Qubes, which is Fedora based, by default uses dom0, not VM kernel. Therefore this is still required even though Whonix 15 is Debian buster based.

@tasket
Copy link

tasket commented Jul 17, 2019

@marmarek This issue should be changed to T:bug, at least with respect to debian-10 templates. The reason is that AppArmor is enabled by default in Debian 10.

FWIW, AppArmor works fine with current templates and the 4.19 kernels as long as apparmor=1 security=apparmor is added to the kernelopts pref. I think it should work OK with the stable 4.14 kernels as well.

@andrewdavidwong
Copy link
Member

This issue should be changed to T:bug, at least with respect to debian-10 templates. The reason is that AppArmor is enabled by default in Debian 10.

If there were separate issues for this for Debian and Fedora, then the Debian one could have the T: bug label. However, since they don't, I think we should leave this as-is with respect to the type. However, increasing the priority seems appropriate.

@andrewdavidwong andrewdavidwong added P: major Priority: major. Between "default" and "critical" in severity. and removed P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. labels Jul 18, 2019
@marmarek
Copy link
Member

marmarek commented Aug 1, 2019

This is yet another case where using in-vm kernel would make it much easier, as it would be the template controlling kernel command line. BTW with grub 2.04, it should be possible to use it with PVH mode too (previously only PV or HVM). There is grub2-xen-pvh package in current-testing already (to be installed in dom0).

For kernel provided from dom0, things are more complex. We need a mechanism for template/standalone qube advertise support for apparmor and then a mechanism to add relevant kernel options. Possibly also allowing user to override it (force-disable, force-enable).

Maybe we could implement it with qvm-features / qvm-service framework? It would go this way:

  1. qubes.PostInstall service in a template check for apparmor support (I'd go with checking if apparmor systemd service exists) and if so, report qvm-feature-request supported-service.apparmor=1
  2. Dom0 part (already exists) will see that feature request and set supported-service.apparmor=1 feature on the template.
  3. Another dom0 extension (to be written) will monitor supported-service.apparmor=1 feature - and when it's set for the first time, it will set also apparmor=1 feature.
  4. If apparmor=1 feature is present, apparmor=1 security=apparmor will be added to kernel command line (for the template and all qubes based on it).

The above (especially point 3) may be surprising for some. But it allows: a) enabling apparmor by default if supported, b) overriding that decision.
Alternatively, points 2 and 3 could be combined - template requesting apparmor=1 directly, not through intermediate supported-service.apparmor=1. This could be easier to follow, but it would be harder to distinguish template supporting apparmor from forcefully enabled apparmor on non-supporting template. And depending on design choices, user decision could be overridden(*).

Another concern is abusing supported-service.* feature. As documented on linked page, those are meant for supporting given qvm-service name. In case of apparmor, it wouldn't be the case. This is an argument for using apparmor=1 directly, or choosing yet another name.

(*) Should the template be able to say "I don't support apparmor anymore", for example if user uninstall relevant packages? Should kernel options be dropped then? On the other hand, should the user be able to disable apparmor even if template does support it?

@adrelanos @unman any opinions?

@tasket
Copy link

tasket commented Aug 1, 2019

I would have thought that doing a qvm-prefs kernelopts in the rpm postinstall for the template would satisfy the "enabled by default, but changeable" requirement.

The tricky part is finding debian 10 templates that already exist, but not by the original name. This is one of several cases where it would be helpful for Qubes dom0 to know the OS type, distro and version of a template or standalone vm.

@marmarek
Copy link
Member

marmarek commented Aug 1, 2019

rpm postinstall for the template

I definitely don't want a distribution-specific code in rpm %post. For multiple reasons:

The tricky part is finding debian 10 templates that already exist, but not by the original name.

My proposal cover this. Installing updated package within template will start advertising support for apparmor.

This is one of several cases where it would be helpful for Qubes dom0 to know the OS type, distro and version of a template or standalone vm.

I don't object this on the principle, but prefer to have as little distribution-specific code in dom0 as possible. Rather - set of features that template can advertise it supports. This way it's easier to create customized templates without dom0 modifications.

@adrelanos
Copy link
Member Author

I find all of this too complex and argued for "VM kernel all the way" in #5212 (comment).

If you like to keep dom0 kernel long term, I'll revisit your comment #4088 (comment), follow-up comments and then pick the least worst one.

@adrelanos
Copy link
Member Author

Is this also in R4.0?

Anything needed to do on the templates side, i.e. advertising apparmor feature for Debian, Fedora, Whonix or other templates?

//cc @herypt

@3hhh
Copy link

3hhh commented Oct 18, 2021

It's in 4.1 only and should be added to the changelog for that very reason.

I at least was quite suprised about apparmor being enabled after investigating why certain stuff didn't work in my VMs.

@marmarek marmarek added the release notes This issue should be mentioned in the release notes. label Oct 18, 2021
@herypt
Copy link

herypt commented Oct 29, 2021

@adrelanos Sorry for the late reply, it checks if apparmor.service is enabled in the template.

@Nurmagoz
Copy link

Nurmagoz commented Jul 7, 2023

Side note:

This ticket feature not applied to debian-minimal according to #8331.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: templates P: major Priority: major. Between "default" and "critical" in severity. release notes This issue should be mentioned in the release notes. security This issue pertains to the security of Qubes OS. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants