From Kicksecure
(Redirected from Qubes/AppArmor)
Jump to navigation Jump to search
AppArmor Icon

AppArmor profiles (Security Hardening) for Kicksecure and other Linux distributions.


According to [1]

AppArmor is a Mandatory Access Control framework. When enabled, AppArmor confines programs according to a set of rules that specify what files a given program can access. This proactive approach helps protect the system against both known and unknown vulnerabilities.

Kicksecure contributor has noted: [2]

Mandatory access control (MAC) systems give fine-grained control over what programs can access. This means that your browser won't have access to your entire home directory or similarly. The most used MAC systems are SELinux and AppArmor. SELinux is a lot more secure than AppArmor as it is more fine-grained. For example, it's inode-based rather than path-based, allows enforcing significantly stronger, can filter kernel and much more. Unfortunately, this comes at the cost of being much more difficult to use and harder to learn so AppArmor may be preferred by some.

AppArmor provides a number of advantages: [3]

  • It protects the operating system and applications from external or internal threats, including zero-day attacks.
  • "Good behavior" is enforced and it mitigates exploits via unknown application flaws.
  • AppArmor security policies define the system resources that individual applications can access, and with what privileges. For instance:
    • Network access.
    • Raw socket access.
    • Read, write or execute file permissions on specific paths.


Kicksecure comes with the following packages installed by default. [4] Therefore no manual user action is required.

  • apparmor-profiles
  • apparmor-profiles-extra
  • apparmor-profiles-kicksecure

Kicksecure means all Kicksecure platforms except Kicksecure inside Qubes. This includes Kicksecure KVM, Kicksecure VirtualBox and Kicksecure. [5]

If you are interested, click on Expand on the right.

AppArmor is enabled by default. No extra steps required.

View Installed AppArmor Profiles[edit]

Some AppArmor profiles for some default installed applications are enforced by default. Some are installed by default but not enforced by default.

To see which, run.

1. Run aa-status.

sudo aa-status

2. See the output of aa-status.

  • A) Profiles under profiles are in enforce mode. are enforced by default. A few profiles are being enforced for software that is not installed, but this does not have any adverse impacts.
  • B) Profiles under profiles are in complain mode. are not enforced.

Additional AppArmor profiles are available for testers. See below.

Enabling Additional AppArmor Profiles[edit]

  • A) Default profiles: As mentioned in the introduction, a number of AppArmor profiles are already enabled by default
  • B) Additional profiles: Can be enabled by following the instructions below.

Some profiles in the apparmor-profiles and apparmor-profiles-extra packages are not enforced by default because the Debian maintainers do not believe they are mature enough. [6]

apparmor-profiles provides various experimental AppArmor profiles. Do not expect these profiles to work out-of-the-box.

These profiles are not mature enough to be shipped in enforce mode by default on Debian. They are shipped in complain mode so that users can test them, choose which are desired, and help improve them upstream if needed.

Some even more experimental profiles are included in folder /usr/share/apparmor/extra-profiles.

Testers only! Warning: This is for testers-only!

1. Check which profiles are in complain mode (not actually providing protection) and which are in enforce mode (providing actual protection).


sudo aa-status

2. Locate the profile to enable.

To enable a profile which is currently in complain mode, locate it in folder /etc/apparmor.d.

ls /etc/apparmor.d

3. Enable the profile.

After locating the relevant profile, enable it. For example.

(The following example is already enforced by default if installed as per above.)

sudo aa-enforce /etc/apparmor.d/home.tor-browser.firefox

It might be inadvisable or unsuitable to enable all available AppArmor profiles.

4. Inspect other available AppArmor profiles.

The /usr/share/apparmor/extra-profiles folder has additional AppArmor profiles.

ls /usr/share/apparmor/extra-profiles

5. Copy relevant AppArmor profiles.

Testers only!

  • Option A) If any of these applications are in use, copy the profile over to folder /etc/apparmor.d.
    • Note: Replace bin.netstat with the actual AppArmor profile to enable.
    • Example: sudo cp /usr/share/apparmor/extra-profiles/bin.netstat /etc/apparmor.d
  • Option B) Copy all profiles. sudo cp /usr/share/apparmor/extra-profiles/* /etc/apparmor.d

6. View all available AppArmor profiles in the /etc/apparmor.d folder.


ls -la /etc/apparmor.d/*

Alternatively also any other tool such as a graphical file manager could be used.

7. Enable the additional profile(s).

  • Option A) Enable a profile.
    • Note: Replace bin.netstat with the actual AppArmor profile to enable.
    • Example: sudo aa-enforce /etc/apparmor.d/bin.netstat
  • Option B) Enable all profiles. sudo aa-enforce /etc/apparmor.d/*

Install Select AppArmor Profiles[edit]

Click on Expand on the right side.

Update your package lists.

sudo apt update


sudo apt install apparmor-profiles


sudo apt install apparmor-profiles-extra

Profile for Tor Browser. Useful in Kicksecure. [7]

sudo apt install apparmor-profile-torbrowser

Profile for the Mozilla Thunderbird E-Mail client. Useful in Kicksecure. (Soon to be renamed apparmor-profile-thunderbird.)

sudo apt install apparmor-profile-thunderbird

Profile Unloading[edit]

The name of the specific profile to unload must be known in advance; refer to the list above.

1. If it is necessary to disable an AppArmor profile, first list those which are available.

ls /etc/apparmor.d/


sudo aa-status

2. Once a profile is loaded in the kernel, it can be easily removed.

Note: Adjust path to the actual AppArmor profile.

sudo aa-disable /etc/apparmor.d/profile-name

This command expects the profile file to exist, so if it has been manually deleted or removed via apt purge, it can only be unloaded by rebooting.

3. Done.

The process of disabling the AppArmor profile has been completed.

4. Verification.

Optional. To confirm, use the aa-status command.

sudo aa-status

Common Operations[edit]

Maintain Tor Browser Functionality[edit]

Tor Browser upgrades frequently break its AppArmor profile (by Kicksecure developers) used to contain it. Even when AppArmor-related fixes are confirmed in the forums, most often updated, fixed packages are immediately made available to Kicksecure stable or even the developer version.

If Tor Browser is non-functional with the available AppArmor profile, follow these steps to rectify the problem.

1. Open a terminal in Kicksecure (kicksecure-17).

kicksecure-17Xfce Terminal

2. List the available AppArmor profiles.

ls /etc/apparmor.d/

3. Edit the Tor Browser AppArmor profile.

Note: change the name of the file to match whatever version is installed on the system.

sudoedit /etc/apparmor.d/home.tor-browser.firefox

4. Navigate to the Kicksecure Github resource for AppArmor.

The latest git commits can be found

Select Codeetc/apparmor.dhome.tor-browser.firefox

Select the Raw button on the right-hand side. [8]

Info It is recommended to check the profile does not contain any unexpected content. For greater security, utilize a different viewer and/or retrieve the profile using git and perform git commit gpg verification.

5. Replace the profile.

Cut and paste the profile text into the old Tor Browser profile which is open in nano.

6. Save and exit.

7. Enforce the new Tor Browser profile.

In the command below, change the name of the file to match whatever version is installed on the system.

In Kicksecure (kicksecure-17), run.

sudo aa-enforce /etc/apparmor.d/home.tor-browser.firefox

8. Shutdown Kicksecure (kicksecure-17).

9. Restart Kicksecure (kicksecure).

Launch Tor Browser. If everything has been applied correctly, Tor Browser will have full functionality. If the following AppArmor warning appears, it can be safely ignored.

Profile: /etc/apparmor.d/home.tor-browser.firefox Operation: open Name: /dev/ Denied: r Logfile: /var/log/kern.log For more information, please see:

10. Manually check AppArmor is correctly running and enforced.

In a terminal, run.

sudo aa-status

The output should show the Tor Browser profile is loaded and in enforce mode.

11. Done.

The process of updating the AppArmor profile has been completed.

Manually Updating Other Kicksecure AppArmor Profiles[edit]

The same method can be used to resolve other AppArmor problems impacting full functionality of applications in Kicksecure. For instance, the systemcheck AppArmor profile previously caused continuous "denied" messages in Kicksecure-Qubes. [9] Correcting this issue was quite simple: [10]

  1. Navigate to the raw, updated systemcheck
  2. Replace the existing content in /etc/apparmor.d/usr.bin.systemcheck with the updated github content, in both Templates kicksecure-17 and kicksecure-17.
  3. Shut down both Templates and any running instances of kicksecure and kicksecure.
  4. Restart kicksecure and kicksecure.

AppArmor Notifications[edit]

apparmor-info[edit] is a helper utility to simplify viewing AppArmor logs. It parses AppArmor logs, hides unnecessary information [11] and removes duplicates.

sudo apparmor-info --boot | grep DENIED

apparmor-notify[edit] is not installed by default. [12] By installing it, desktop notifications would appear concerning AppArmor denied messages, which are stored in file /var/log/kern.log.

To install:

Install package(s) apparmor-notify. Follow steps A to D.

A. Platform specific notice.

B. Update the package lists and upgrade the system The Web Archive Onion Version .

sudo apt update && sudo apt full-upgrade

C. Install the apparmor-notify package(s).

Using apt command line --no-install-recommends The Web Archive Onion Version is in most cases optional.

sudo apt install --no-install-recommends apparmor-notify

D. Platform specific notice.

E. Done.

The procedure of installing package(s) apparmor-notify is complete.

If apparmor-notify is manually installed, then on occasion an application may be functional but AppArmor "denied" messages constantly appear. Rather than updating the relevant AppArmor profile(s), it is possible to disable notifications instead.

In the offending Kicksecure (App)VM, launch Xfce Terminal and run.

sudo killall aa-notify

To revert this change, reboot the VM.

Manual Notifications Inspection[edit]

Use of apparmor-info is simpler.

1. Manually inspect relevant logs.

Open file /var/log/kern.log in an editor with root rights.


This box uses sudoedit for better security.

sudoedit /var/log/kern.log

Kicksecure for Qubes


sudoedit /var/log/kern.log

  • After applying this change, shutdown the Template.
  • All App Qubes based on the Template need to be restarted if they were already running.
  • This is a general procedure required for Qubes and unspecific to Kicksecure for Qubes.

Others and Alternatives

  • This is just an example. Other tools could achieve the same goal.
  • If this example does not work for you or if you are not using Kicksecure, please refer to this link.

sudoedit /var/log/kern.log

2. Show denied AppArmor messages of any age.


sudo cat /var/log/kern.log | grep DENIED

3. Optional: Keep watching the file as it is appended.

This is useful for reproducing AppArmor denied messages and testing amended profiles.

sudo tail -f /var/log/kern.log | grep --line-buffered DENIED

More Profiles[edit]

It is possible to utilize profiles by other vendors since AppArmor is unspecific to Kicksecure. This however is unsupported by Kicksecure developers due to time constraints. As a reminder, it is not necessary to install AppArmor profiles for any applications that are unlikely to be used (such as dovecot). Additional options include:

  1. Debian has packages that can be easily installed via the APT package
  2. Ubuntu also provides It is not easy to download these as a package to be installed in Debian. Further, the profiles may or may not differ from (or complement) profiles listed earlier.
  3. Advanced users can attempt to create additional, strict AppArmor profiles by executing: [2]

aa-genprof $path_to_program

Then open the program and use it as normal. AppArmor detects which files need to be accessed and adds them to the profile if you choose. This is insufficient for high quality profiles though; refer to the AppArmor for further details.

Fix Profiles[edit]

1. Put folder /etc/apparmor.d under git version control.

Git is a useful tool to record which files in a folder changed in what way.

Git setup for folder /etc/apparmor.d.

Install package(s) git auditd. Follow steps A to D.

A. Platform specific notice.

B. Update the package lists and upgrade the system The Web Archive Onion Version .

sudo apt update && sudo apt full-upgrade

C. Install the git auditd package(s).

Using apt command line --no-install-recommends The Web Archive Onion Version is in most cases optional.

sudo apt install --no-install-recommends git auditd

D. Platform specific notice.

E. Done.

The procedure of installing package(s) git auditd is complete.

Change directory to folder /etc/apparmor.d.

cd /etc/apparmor.d

Initialize git in that folder.

sudo git init

Git needs an e-mail address. That e-mail address doesn't need to actually exist. That e-mail address would appear in git commit change logs if that git repository was ever pushed to any remote. If only used locally, the default could be kept. Otherwise, the user may change to any e-mail address of their choice.

sudo git config ""

Git needs an name. That name address doesn't need to actually exist. That name would appear in git commit change logs if that git repository was ever pushed to any remote. If only used locally, the default Your Name could be kept. Otherwise, the user may change Your Name to any name of their choice.

sudo git config "Your Name"

Add all files in that folder to git.

sudo git add -A

Commit all files to git. [13]

sudo git commit -a -m .

2. Open your application/s which caused the Denied/Allowed messages.

3. Use aa-logprof to correct them. [14]

sudo aa-logprof

This is an example for fixing the AppArmor profile for Tor Browser.

Sample printout:

Reading log entries from /var/log/audit/audit.log.
Updating AppArmor profiles in /etc/apparmor.d.
Enforce-mode changes:

Profile:  /**/*-browser/Browser/firefox
Path:     /sys/bus/pci/devices/
New Mode: r
Severity: 4

 [1 - #include <abstractions/totem>]
  2 - /sys/bus/pci/devices/ r,
(A)llow / [(D)eny] / (I)gnore / (G)lob / Glob with (E)xtension / (N)ew / Audi(t) / Abo(r)t / (F)inish

Answer with A

Sample printout:

Adding #include <abstractions/totem> to profile.
Deleted 19 previous matching profile entries.

Profile:  /**/*-browser/Browser/firefox
Path:     /proc/1342/cgroup
New Mode: owner r
Severity: 6

 [1 - owner /proc/*/cgroup r,]
  2 - owner /proc/1342/cgroup r,
(A)llow / [(D)eny] / (I)gnore / (G)lob / Glob with (E)xtension / (N)ew / Audi(t) / (O)wner permissions off / Abo(r)t / (F)inish

Answer with A

Sample printout:

Adding owner /proc/*/cgroup r, to profile.

= Changed Local Profiles =

The following local profiles were changed. Would you like to save them?

 [1 - /**/*-browser/Browser/firefox]
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t

Answer with S

Sample printout:

Writing updated profile for /**/*-browser/Browser/firefox.


4. Re-run any applications that had any AppArmor issues

5. Repeat step 2 and 3 until there are no new AppArmor denied or allowed messages.

It should give you similar output if there is nothing left to resolve:

Reading log entries from /var/log/audit/audit.log.
Updating AppArmor profiles in /etc/apparmor.d.
Enforce-mode changes:

6. See which files were modified by aa-logprof.

From the same folder.

git status

git will show which files have been modified.

Sample printout:

On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   home.tor-browser.firefox

no changes added to commit (use "git add" and/or "git commit -a")

7. Open the modified file(s) with a text editor.

sudoedit /etc/apparmor.d/home.tor-browser.firefox

8. Submit fixes to developers, if applicable (general bug).

Ideally to github:




This box Expand All is mostly useful for wiki editors. Users can safely ignore it.

  2. 2.0 2.1
  5. Advanced users attempting to enable SE Linux instead would utilize the following parameters in this section: selinux=1 security=selinux
  7. Tor Browser is installed by tb-updater; the latter is a default Kicksecure application.
  8. Otherwise essential profile formatting might break or unwanted content (such as line numbers) might be copied inadvertently, leading to a non-functional profile.
  9. In Kicksecure 13.
  10. This issue was fixed in the Kicksecure 14 release.
  11. Jul 18 13:50:28 host kernel: [ 117.212029] audit: type=1400 audit(1626616228.947:23):

  13. Commits all files to git with commit message . for simplicity. Commit message could also be something else such as {{{sudo_maybe}}} git commit -a -m "initial commit".

Unfinished: This wiki is a work in progress. Please do not report broken links until this notice is removed, use Search Engines First and contribute improving this wiki.

We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!