Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

dmesg shows audit type=1400 apparmor DENIED lines and a service fails

Your error

audit: type=1400 audit(1571868402.378:24425): apparmor="DENIED" operation="open" profile="/usr/sbin/cups-browsed" name="/var/lib/libvirt/dnsmasq/"2 more lines it can show

Fix it fast

Most common cause, 1 of 3

A packaged profile does not allow a path your setup uses

Put the extra rule in the matching file under /etc/apparmor.d/local/, which package upgrades leave alone, then reload only that profile.

Fix
# /etc/apparmor.d/local/usr.sbin.myservice
/srv/myservice/ r,
/srv/myservice/** rwk,

sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.myservice
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

audit: type=1400 apparmor="DENIED" means an AppArmor profile blocked one action, and the line says which: profile= names the profile, operation= the action and name= the path. Add the path to the package's local override file and reload it, connect a snap interface for snap. profiles, or grant userns create for operation="userns_create" on Ubuntu 24.04.

  • Applies to Ubuntu 24.04 LTS (apparmor 4.0), Ubuntu 26.04 LTS (apparmor 5.0 beta), snapd interfaces
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the latest denials and read three fields on each line. A profile that is a program path, such as /usr/sbin/mysqld, points to cause 1. A profile starting with snap. points to cause 2. operation="userns_create" with profile="unconfined" points to cause 3.

Run this first
sudo dmesg | grep 'apparmor="DENIED"' | tail -n 20

Then find the line you see in this list and open its fix:

  1. 1A packaged profile does not allow a path your setup usesprofile= is a program path and name= is a folder you moved or added, such as a new data, log or socket directory
  2. 2A snap is blocked by its own sandboxprofile= starts with snap., for example snap.lxd.lxc
  3. 3Ubuntu restricts unprivileged user namespaces for unconfined programsoperation="userns_create", profile="unconfined" and info="User namespace creation restricted"; the comm= field names the program, such as steamwebhelper in the AppArmor wiki's sample

What does the error look like?

  • audit: type=1400 audit(1571868402.378:24425): apparmor="DENIED" operation="open" profile="/usr/sbin/cups-browsed" name="/var/lib/libvirt/dnsmasq/"
  • apparmor="DENIED" operation="sendmsg" profile="snap.lxd.lxc"
  • apparmor="DENIED" operation="userns_create" class="namespace" info="User namespace creation restricted" profile="unconfined"

Cause 1 of 3

A packaged profile does not allow a path your setup uses

You seeprofile= is a program path and name= is a folder you moved or added, such as a new data, log or socket directory

Check

An apparmor DENIED line with operation="open" and a path-style profile means the program's own profile has no rule for the file in name=. This often follows a custom data directory, a socket in a new place or files kept under /srv. The profile itself is a file in /etc/apparmor.d/ that mentions the program path, and packages that need local tweaks include a matching file from /etc/apparmor.d/local/.

Check
# use the program path from profile=
grep -rl "/usr/sbin/myservice" /etc/apparmor.d/ 2>/dev/null
grep -n "local/" /etc/apparmor.d/usr.sbin.myservice

Fix

Put the extra rule in the matching file under /etc/apparmor.d/local/, which package upgrades leave alone, then reload only that profile. Grant the narrowest access the denied_mask asks for.

Fix
# /etc/apparmor.d/local/usr.sbin.myservice
/srv/myservice/ r,
/srv/myservice/** rwk,

sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.myservice

Verify

Restart the service and repeat the action. No new DENIED line with that profile appears.

Verify
sudo dmesg | grep 'apparmor="DENIED"' | grep -c myservice

Confirmed by ubuntu.com

Did this fix it?

Cause 2 of 3

A snap is blocked by its own sandbox

You seeprofile= starts with snap., for example snap.lxd.lxc

Check

Ubuntu's AppArmor guide calls snap profiles special: they sit in /var/lib/snapd/apparmor/profiles, not in /etc/apparmor.d. What a snap may reach is decided by its interfaces instead, and some interfaces are not connected automatically at install time.

Check
snap connections lxd

Fix

Find the interface that covers the denied access, for example removable-media for files under /media or /mnt, and connect it. If no interface covers the path, move the files somewhere the snap can read, or use a non-snap package.

Fix
snap connections <snap>
sudo snap connect <snap>:removable-media

Verify

snap connections now shows a slot for that plug, and the action no longer logs a denial.

Verify
snap connections <snap> | grep removable-media

Confirmed by snapcraft.io

Did this fix it?

Cause 3 of 3

Ubuntu restricts unprivileged user namespaces for unconfined programs

You seeoperation="userns_create", profile="unconfined" and info="User namespace creation restricted"; the comm= field names the program, such as steamwebhelper in the AppArmor wiki's sample

Check

When the restriction is on, the AppArmor project explains that an unprivileged program without CAP_SYS_ADMIN may only create user namespaces if a profile confines it and allows them. The sysctl below prints 1 when the restriction is active.

Check
cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns

Fix

Give that one program a small profile with a userns rule instead of switching the restriction off for the whole machine, then load it.

Fix
# /etc/apparmor.d/opt.myapp
abi <abi/4.0>,
include <tunables/global>

profile myapp /opt/myapp/myapp flags=(unconfined) {
  allow userns create,
}

sudo apparmor_parser -r /etc/apparmor.d/opt.myapp

Verify

The program starts, and no userns_create denial appears for its comm= name.

Verify
sudo dmesg | grep userns_create | tail -n 3

Confirmed by gitlab.com

Did this fix it?

How do I stop it coming back?

  • Keep site-specific rules only in /etc/apparmor.d/local/ files and track them in configuration management.
  • Before moving a service's data or socket directory, check whether its AppArmor profile lists the old path.
  • Test a suspect profile with sudo aa-complain for a short time to confirm AppArmor is the cause, then put it back with aa-enforce.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.