AppArmor for Complete System - Including init, PID1, Systemd, Everything! - Full System MAC policy

Apparmor profiles are usually activated after package upgrades but you cannot load profiles while being confined by apparmor. As everything is being confined in this scenario, it is not possible to load apparmor profiles at runtime. It requires a reboot.

Further, the policy explicitly denies access to the mac_admin and mac_override capabilities so even if apparmor itself didn’t prevent loading new profiles, you still won’t have enough privileges.

Not when confined with a full system policy. When trying to do this while confined under the policy, I get this error

ERROR: /sbin/apparmor_parser: Unable to replace "profile".  Permission denied; attempted to load a profile while confined?
1 Like

I can make a compromise. /opt can be read-write for the user’s own programs while /usr/bin and other will be read-only.

1 Like

Question: What about software installation to home folder?
(Related to noexec - (re-)mount home [and other?] with noexec (and nosuid [among other useful mount options]) for better security?)

1 Like

Currently only the Tor Browser is executable but I can make anything in the home directory executable if you want.

Also, if the user wants to access something that’s restricted (execute something else in /home for example), then they can just add what they want to a “local” file.

1 Like

https://github.com/Whonix/whonixcheck/pull/14

1 Like

Merged. To not block your progress. But I wonder why it’s needed? A simple echo requires that? Writing to tty0 may be ok but reading required too? This may be related to other whonixcheck hardening wrt to output (of kernel messages) for non-root/non-sudo users as discused in Kernel Hardening - security-misc - #213 by madaidan.

1 Like

I’m not sure why it’s needed. Nor why it’s only needed when using a full system policy.

1 Like

Here are the newer profiles:

init-systemd - Debian paste error

apt-get - Debian paste error

the dangerous-files abstraction - Debian paste error

It would be great if anyone could test. Especially on platforms I can’t test on like Qubes.

1 Like

Could you please create a new package for this? That makes it easier to test. Once I have it installed in Qubes I might find some issues and just fix in git if I figure out how.


Qubes might be a great fit for this anyhow.In Qubes TemplateBasedVMs the root image is non-persistent.

Software installation to the root image in TemplateBasedVMs can be useful but isn’t a too important use case. Apparmor everything would be an additional layer to prevent VM breakout.

However when booting a TemplateVM (“different boot mode”, not really) software installation should be possible. The existing Qubes design makes it easy to compartmentalize installation/update of software vs actually running the software. Happens in different VMs if the user adheres to standard Qubes principles.

1 Like

madaidan via Whonix Forum:

Something generic like “Full System AppArmor Policy”.

apparmor-profile-everything?

full might be more correct but everything more catchy.

apparmor-profile-init?

1 Like

I don’t know how to create Debian packages so I won’t be able to yet.

Setting it up isn’t hard. Just follow the instructions in the page linked in the original post and add the init-systemd, apt-get and dangerous-files abstraction to /etc/apparmor.d.

Verify it works by running ps auxZ. You’ll see all processes are confined except kernel processes (the ones in square brackets).

I’m not sure which one to use. Both are fine.

That might make people think it’s only the init process rather than the entire system.

1 Like

Empty package created.

GitHub - Kicksecure/apparmor-profile-everything: AppArmor for everything. APT, systemd, init, all systemd units, all applications. Mandatory Access Control. Security Hardening.

Could you add please the files there?

1 Like

Perfect. I’ll create a pull request in a minute.

1 Like
1 Like

Could you please add the license header?

1 Like

Oops. I forgot again.

1 Like

/var/lib/dpkg/info/** rwpix,

Write access to dpkg, maintainer, postinst scripts?

Some folders are not addressed yet such as /etc/dpkg/dpkg.cfg.d and others listed in this post: AppArmor for Complete System - Including init, PID1, Systemd, Everything! - Full System MAC policy - #17 by Patrick?

1 Like

I added the licensing.

Write access is given anyway with the /var/{,lib,log}/** rw, rule.

Feel free to add them to the dangerous-files abstraction.

Btw, some rules in that abstraction break some apt upgrades e.g. deny /**/initramfs-tools/** w, breaks adding new files to that directory during upgrades so it’s commented out in the apt profile.

1 Like

etc/initramfs-tools/hooks/apparmor can I rename to apparmor-profile-everything? Reason: the name “apparmor” might be used by some other package (apparmor?) in the future and thereby break things. apparmor-profile-everything is more unique and very very unlikely being used by anyone else in future.

1 Like

Sure, that’s a good idea.

I doubt many packages would be using initramfs hooks for apparmor though.

You should also rename etc/initramfs-tools/scripts/init-bottom/apparmor

1 Like