- 1 Introduction
- 2 Installation
- 3 Common Operations
- 4 Support
- 5 Development
- 6 Footnotes
According to debian.org: 
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.
AppArmor provides a number of advantages: 
- 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.
It is recommended to use the Whonix ™ AppArmor [archive] profiles which are available for various programs that run in both Whonix-Gateway ™ and Whonix-Workstation ™, such as Tor, Tor Browser, Thunderbird and more. The profiles are easy to apply and provide a considerable security benefit.
Qubes Users Note
If you are interested, click on Expand on the right.
- Complete these instructions in dom0 for both
- After changes are made to the Whonix ™ templates, the
anon-whonix(AppVM) will inherit the AppArmor kernel settings.
anon-whonixTemplateBasedVMs do not need to be recreated to benefit from the new kernel parameters. 
- Verify AppArmor is active in both
anon-whonixafter changes are made.
Install all AppArmor Profiles
The easiest method is to install all available AppArmor profiles. This can result in a few profiles being enforced for software that is not installed, but this will not have any adverse impacts.
sudo apt-get install apparmor-profiles apparmor-profiles-extra apparmor-profiles-kicksecure
Some profiles in the
apparmor-profiles-extra packages are not enforced by default because the Debian maintainers do not believe they are mature enough.  You can manually enforce all profiles by running.
sudo aa-enforce /etc/apparmor.d/*
More AppArmor profiles can be found in
/usr/share/apparmor/extra-profiles/ although these profiles are experimental and may not work.
Install Select AppArmor Profiles
Click on Expand on the right side.
sudo apt-get install apparmor-profile-torbrowser
Profile for the HexChat client. Useful in Whonix-Workstation ™.
sudo apt-get install apparmor-profile-xchat
sudo apt-get install apparmor-profile-icedove
Profile for VirtualBox. This is useful on the host, but instructions are not available for this procedure. It is also useful if running VirtualBox inside VirtualBox.
sudo apt-get install apparmor-profile-virtualbox
The name of the specific profile to unload must be known in advance; refer to the list above.
If it is necessary to disable an AppArmor profile, first list those which are available.
Once a profile is loaded in the kernel, it can be easily removed.
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-get purge, it can only be unloaded by rebooting.
Maintain Tor Browser Functionality
Tor Browser upgrades frequently break the Whonix ™ AppArmor profile used to contain it. Even when AppArmor-related fixes are confirmed in Phabricator, most often the packages are not made available to Whonix ™ stable or even the developer version. This means manual profile fixes are often required until the next Whonix ™ version is released.
If Tor Browser is non-functional with the available AppArmor profile, follow these steps to rectify the problem.
Correcting Other Whonix ™ AppArmor Profiles
The same method can be used to resolve other AppArmor problems impacting full functionality of applications in Whonix ™. For instance, the
whonixcheck AppArmor profile previously caused continuous "denied" messages in Qubes-Whonix ™.  Correcting this issue was quite simple: 
- Navigate to the raw, updated whonixcheck profile [archive].
- Replace the existing content in /etc/apparmor.d/usr.bin.whonixcheck with the updated github content, in both TemplateVMs
- Shut down both TemplateVMs and any running instances of
Inspecting and Disabling AppArmor Notifications
apparmor-notify [archive] is no longer installed by default. This means desktop notifications will not appear concerning AppArmor denied messages, which are stored in
/var/log/audit/audit.log.   
To inspect relevant logs, run.
/var/log/audit/audit.log in an editor with root rights.
(Qubes-Whonix ™: In TemplateVM)
To show denied AppArmor messages of any age, run.
sudo cat /var/log/audit/audit.log | grep -i DENIED
It is possible to 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/audit/audit.log | grep --line-buffered DENIED
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 Whonix ™ (App)VM, launch Xfce Terminal and run.
sudo killall aa-notify
To revert this change, reboot the VM.
It is possible to utilize profiles by other vendors, but this is unsupported by Whonix ™ developers. 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:
- Debian has packages that can be easily installed via the APT package manager [archive].
- Ubuntu also provides profiles [archive]. 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.
- https://wiki.debian.org/AppArmor [archive]
- http://wiki.apparmor.net/index.php/Main_Page [archive]
- Non-Qubes-Whonix ™ means all Whonix ™ platforms except Qubes-Whonix ™. This includes Whonix ™ KVM, Whonix ™ VirtualBox and Whonix ™ Physical Isolation.
- Since Qubes R3.0, TemplateBasedVMs inherit the kernelopts setting of their TemplateVM [archive].
- Hit the up arrow key twice; it is unnecessary to type the command again.
- https://packages.debian.org/buster/apparmor-profiles [archive]
- Tor Browser is installed by tb-updater; the latter is a default Whonix ™ application.
- Otherwise essential profile formatting might break or unwanted content (such as line numbers) might be copied inadvertently, leading to a non-functional profile.
- In Whonix ™ 13.
- This issue was fixed in the Whonix ™ 14 release.
- To install it, run:
sudo apt-get update && sudo apt-get install apparmor-notify.
- https://forums.whonix.org/t/whonix-14-debian-stretch-apparmor-related-changes/3563 [archive]
- The Debian default location is
This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation.
Copyright (C) 2012 - 2019 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee [archive] of the Open Invention Network [archive]. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)