$ systemctl status apparmor
$ systemctl start apparmor
Install neccessary tools
$ apt install apparmor-utils
Default firefox profile shipped with Kali Linux
# This profile allows everything and only exists to give the
# application a name instead of having the label "unconfined"
abi <abi/4.0>,
include <tunables/global>
profile firefox /{usr/lib/firefox{,-esr,-beta,-devedition,-nightly},opt/firefox}/firefox{,-esr,-bin} flags=(unconfined) {
userns,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/firefox>
}
1. Generate a starting profile
Creates a profile in /etc/apparmor.d with the naming convention where the slashes (/) are converted to dots (.)
Generated on Kali Linux (Kali 6.12.25-1kali1 (2025-04-30))
usr.bin.firefox
abi <abi/4.0>,
include <tunables/global>
/usr/bin/firefox flags=(complain) {
include <abstractions/base>
include <abstractions/bash>
/usr/bin/dash ix,
/usr/bin/firefox r,
}
2. Optionally, load the profile using aa-genprof or aa-logprof
The aa-genprof tool uses aa-logprof under the hood to augment the profile
Generate a new profile according to logs from the specified log file
For /usr/bin/firefox, I used aa-autodep instead of aa-genprof to generate the starting profile. This is because there are too many file reads from firefox (as shown in the log file), thus aa-genprof displays too much output.
Used to compile the profile (understood by the kernel), and load it into the kernel
-r flag: To update the existing profile in the kernel
This flag is required if an AppArmor definition by the same name already exists in the kernel; used to replace the definition already in the kernel with the definition given on standard input.
5. View the status
$ aa-status
apparmor modules are loaded
XX profiles are loaded.
X profiles are in enforce mode.
...
/usr/bin/firefox
...
...
...
6. View the logs and manually update the profile
After loading the profile into the kernel, we can run the application (controlled by apparmor in enforce mode), and view the logs for any DENIED error messages:
The message tells us that firefox-esr is trying to write (w) to /proc/xxxx/xxxx, but got DENIED access. To fix this issue, we can add a rule to the profile:
/proc/** w,
For more information on file pattern matching, refer to the documentation on the File Globbing section:
7. Verify the apparmor configurations
...
Example
Given the configurations in place for firefox, we can now open up a window and check if the file restrictions are working.
...
8. Other useful commands
Refer to the documentation link at the start of this page