brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: aa-complain lets an AppArmor profile log instead of block while you test security rules

Security
~/tips/tip-security-aa-complain-test-profile

sudo aa-complain /usr/sbin/nginx

Switches one AppArmor profile to logging mode, so you can see what it would block.

When a confined program suddenly fails, the quick fix people reach for is disabling AppArmor. Complain mode is the better middle ground: the profile stays loaded, but it only writes down what it would have stopped.

The tools come in a separate package on Ubuntu:

sudo apt install apparmor-utils
sudo aa-complain /usr/sbin/nginx
sudo aa-status | grep -A3 complain

You pass the program, and the tool finds its profile in /etc/apparmor.d/, where the name is the path with dots instead of slashes, so usr.sbin.nginx. Now run the thing that was failing and read the kernel log:

sudo journalctl -k | grep 'apparmor="ALLOWED"'

In complain mode the lines say ALLOWED where enforce mode would say DENIED, together with the operation, the path and the profile. That tells you exactly which rule to add. When the profile is fixed, switch it back:

sudo aa-enforce /usr/sbin/nginx

I’d never leave a profile in complain mode and forget it. It offers no protection at all in that state, apart from explicit deny rules, which the manual says are still enforced. Write yourself a reminder, or check aa-status after the work is done. Also note that snaps manage their own profiles, so changes to those get overwritten on the next refresh.

Further reading: aa-complain(8) manual page, Ubuntu Server docs: AppArmor

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link