The limits of name-based mediation

where path rules break for security researchers for application developers

A file rule is matched against a name the kernel builds at the moment of the check and not against the file. Covers bind mounts as second names and the root a name is counted from and renames of directories. Also what happens after the open - renames and policy reloads and inherited descriptors - and files with no name and O_PATH. Most cases were run on a real kernel.

On the map: security

▶ Watch this deck — 9 scenes, ~7 min

Worth seeing first

Part of journeys

01 A rule names a path, not a file

NAMES, NOT FILES profile demo /usr/bin/demo { /etc/demo/public r, } no rule for /etc/demo/secret demo /etc/demo/public /etc/demo/secret the kernel builds a name at each check nothing stored on the file 1 can the secret get another name? 2 can a name change after the check? 3 what if there is no name? 4 which operations never ask? most answers in this deck were run on a real kernel
The profile demo allows reading /etc/demo/public and has no rule for /etc/demo/secret. demo opens both: one is allowed, one denied. The kernel builds a name at each check, and four questions follow: more names, names that change, no name, operations that do not ask.

A file rule is matched against a path that the kernel builds from the mount and directory entry at the moment of the check. The file carries no AppArmor label for file rules, so anything that changes the path changes the answer.

Demo's profile has one file rule: it may read the public file in /etc/demo. The secret file next to it has no rule, so opening it is denied. That looks like a promise about a file. It's a promise about a name. Each time it checks an access, the kernel builds the file's path, right then, and matches that string against the rules. Nothing is stored on the file. So this deck asks four questions. Can the secret get another name? Can a name change after the check? What if there's no name? And which operations don't ask? Most answers were run on a real kernel.

Details and sources

Details

  • A file rule (/etc/demo/public r,) is matched against a string. For every file hook the kernel builds that string from the pair of mount and directory entry it was handed, then walks the profile's file table with it.
  • Nothing about AppArmor's file rules is stored on the inode. Two ways to reach one file give two strings, and each is matched on its own.
  • The string depends on three things: the directory entry used (hard links), the mount it was reached through and the task's mount namespace (bind mounts, containers), and the time of the check (renames).
  • A name longer than the path buffer is refused with info="Failed name lookup - name too long".
  • The examples in this deck use /etc/demo/public (rule: r) and /etc/demo/secret (no rule), both owned by root, and a task running as root, so ordinary owner and mode checks never stand in the way.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

for AppArmor developers for security researchers

Code

02 Another name for the same file

1 · ANOTHER NAME symlink followed first: the target's name is matched hard link a second name: the link check decides who may make one bind mount a second name that file rules cannot tell apart # an unconfined root shell, in demo's mount namespace $ mount --bind /etc/demo/secret /etc/demo/public demo open("/etc/demo/public") the secret file matched as /etc/demo/public: ok read 12 bytes: "secret data" no audit record demo itself needs capability sys_admin and a mount rule to do this whoever builds its mount namespace does not
Three ways a file gets another name. A symlink is resolved to its target. A hard link is a second name. A bind mount puts the secret file at the path /etc/demo/public: demo opens that path, the rule matches and it reads the secret data, with no audit record.

A bind mount gives a file a second path, and a file rule for that path applies to it. Observed: with /etc/demo/secret bind-mounted on /etc/demo/public, the confined program reads the secret through the rule for the public file.

Start with more names. A symlink doesn't give a file a new name for AppArmor: the kernel follows it and matches the target. A hard link does, and the link check decides who may make one. The third way is a bind mount. In this run, a root shell outside the profile bind-mounts the secret over the public file's path, and then starts demo. Demo opens the public path, the rule matches, and it reads the secret data. No denial, no log line. Demo itself can't do this without the sys_admin capability and a mount rule. But whoever sets up its mount namespace can.

Details and sources

Details

  • Symlinks: the kernel resolves them before the hook runs, so the target's path is matched. See Symlinks.
  • Hard links: a second directory entry, so a second name. Creating one from a confined task goes through the link check. See Hard links.
  • Bind mounts: the name is built by walking up from the file through the mount it was reached by, so the bind mount's path is the name. The rule for /etc/demo/public then covers whatever is mounted there.
  • The run: unshare -m sh -c 'mount --bind /etc/demo/secret /etc/demo/public && aa-exec -p demo-t -- ./t open /etc/demo/public' printed open O_RDONLY: ok (3) and read: ok, read 12 bytes: "secret data". The audit log had no record for it.
  • Who can bind mount: the mount system call needs CAP_SYS_ADMIN over the mount namespace. A confined task also needs capability sys_admin, and a mount rule in its profile. An unconfined task is not asked by AppArmor. Container runtimes and service managers arrange mounts before the confined program starts.
  • A deny rule names a path as well. A file under a denied path is reachable under any other name it has.
  • Known discrepancy: a bind mount made with the newer file-descriptor mount calls is not checked as a bind. See What is not mediated, scene "Mounts through the new API".
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

for AppArmor developers for security researchers

Code

03 Counted from which root?

1 · COUNTED FROM WHICH ROOT? demo chroot("/srv/jail") open("/etc/demo/public") demo has capability sys_chroot the jail was set up beforehand default: the name starts at the root of the mount namespace apparmor="DENIED" operation="open" profile="demo" name="/srv/jail/etc/demo/public" requested_mask="r" denied_mask="r" no rule: denied profile demo flags=(chroot_relative): the name starts at demo's own root matched as /etc/demo/public read 10 bytes: "jail copy" the rule now means a file demo chose containers: a profile matches paths as the task's mount namespace shows them a file reached through a mount outside that namespace has no name: scene 6
demo changes root into /srv/jail and opens /etc/demo/public. By default the kernel matches /srv/jail/etc/demo/public and denies. With flags=(chroot_relative) it matches /etc/demo/public and demo reads the copy inside the jail.

By default the matched name starts at the root of the task's mount namespace, so a chroot does not shorten it. With flags=(chroot_relative) it starts at the task's root. Observed both ways with the same rule and the same open.

A name has to start somewhere. By default it starts at the root of the mount namespace demo runs in, not at demo's own root directory. Here demo, with the sys_chroot capability, changes root into a prepared jail and opens the public path. The kernel matches the full path through the jail: no rule, denied. Now add the flag chroot_relative. The name is counted from demo's root, the short path matches, and demo reads the jail's copy. So with that flag, a program that can chroot decides which file a rule means. Containers need the same care: a profile sees paths as the task's mount namespace shows them.

Details and sources

Details

  • Default (namespace_relative): the name is the path from the root of the current mount namespace. After chroot("/srv/jail"), open("/etc/demo/public") is matched as /srv/jail/etc/demo/public.
  • flags=(chroot_relative): the name is the path from the task's root directory. The same open is matched as /etc/demo/public.
  • The run, profile with /etc/demo/public r, and capability sys_chroot,: without the flag open inside the chroot: FAILED errno=13 (Permission denied) and the audit record apparmor="DENIED" operation="open" class="file" profile="demo-t" name="/srv/jail/etc/demo/public" comm="t" requested_mask="r" denied_mask="r" fsuid=0 ouid=0. With the flag: open inside the chroot: ok (3), read: ok, read 10 bytes: "jail copy".
  • The jail in the run (/srv/jail, holding its own /etc/demo/public with the text "jail copy") was made beforehand by the unconfined setup script (findings/security/observed/run.sh); the profile gives demo no write access there. A program that can also write a directory tree and holds sys_chroot can build such a jail itself.
  • Why the default is the safer one: a program that may chroot and may write some directory can build etc/demo/public there. With chroot_relative that file carries the name of the system's file.
  • chroot needs CAP_SYS_CHROOT, which a confined task has only with capability sys_chroot,. AppArmor has no separate rule for the chroot call itself.
  • Mount namespaces: the name is relative to the namespace the task is in. A profile written for the host layout and applied inside a container is matched against the container's paths. pivot_root moves that root and has its own rule class.
  • A policy namespace (:ns:) is a different thing: it separates sets of profiles, not file trees. See Policy namespaces.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

Read more

for AppArmor developers for security researchers

Code

04 A rename moves files between rules

2 · RENAME /srv/demo/a/ rw, /srv/demo/c/ rw, /srv/demo/c/** r, no rule for files inside a /srv/demo/a/secret-notes open: denied rename("/srv/demo/a", "/srv/demo/c") old name /srv/demo/a/ needs rw new name /srv/demo/c/ needs w two checks: ok /srv/demo/c/secret-notes open: ok, read "notes" the same file, never asked about w on a directory name = permission to move everything in it under another rule rename has no subset test, unlike link
demo may write the directory names /srv/demo/a/ and /srv/demo/c/ and read everything under c. The file a/secret-notes is denied. demo renames a to c: two checks, both pass. The same file is now c/secret-notes and is read.

A rename is checked on the old and the new name of the thing renamed: rw on the old, w on the new. Renaming a directory changes the name of every file below it without a check on any of them. Observed.

Names change. A rename asks AppArmor two questions: may you take the old name away, and may you create the new one. For a directory, those are the only questions. Here demo may write the directory names a and c, and read everything under c. The notes file in a has no rule: denied. Then demo renames a to c. Two checks, both pass. Now the same file sits under c, and demo reads it. Nothing asked about the files inside. So write permission on a directory name is permission to move everything in it under another rule. And unlike a hard link, a rename has no subset test.

Details and sources

Details

  • Rename asks for read, write and delete on the old name (rw in profile letters) and write and create on the new name (w). RENAME_EXCHANGE asks both ways round.
  • A directory's name ends in a slash for matching: /srv/demo/a/. A rule such as /srv/** rw, covers every directory name below /srv and therefore allows moving any of them.
  • The run. Rules: /srv/demo/a/ rw,, /srv/demo/c/ rw,, /srv/demo/c/** r,. open /srv/demo/a/secret-notes: FAILED errno=13. rename /srv/demo/a /srv/demo/c: ok. open /srv/demo/c/secret-notes: ok, read 6 bytes: "notes". The audit log holds only the first denial.
  • When the new name has no rule the rename is refused: apparmor="DENIED" operation="rename_dest" class="file" profile="demo-t" name="/srv/demo/b2/" comm="t" requested_mask="wc" denied_mask="wc" (first run).
  • The same holds for one file: rw on the old name and w on the new moves it from under one rule to under another.
  • Hard links get a subset test (what the new name grants must be allowed on the old); renames do not. See Hard links.
  • For a profile author: do not grant w on directory names that sit above data other rules protect by name.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

for AppArmor developers for security researchers

Code

05 Checked at open, used later

2 · CHECKED AT OPEN open: checked the name is matched once read, write: descriptor no new name unless the label changes or more is asked run 1: another process renames it /srv/demo/b/moving -> /srv/demo/hidden (no rule) read from the same fd: ok, "moving" open the new path: Permission denied run 2: the profile is reloaded without /etc/demo/public r, $ apparmor_parser -r demo read from the same fd: ok, "public data" open the same path again: Permission denied "No revocation at this time" comment in the kernel source to take a file away from a running program: restart it
A timeline. demo opens a file and the name is checked. Then either the file is renamed to a path with no rule, or the profile is reloaded without the rule. In both runs the open descriptor keeps reading and only a new open is denied.

The name is matched at open. Later reads and writes on the descriptor are not matched again when the open already covered them. Observed: an open descriptor keeps working after the file is renamed to a denied path, and after the profile is replaced without the rule.

Now the window between check and use. The name is matched when demo opens the file. After that, reads and writes go through the descriptor, and the kernel doesn't build the name again unless demo's label changes or it asks for more than the open covered. Two runs. Another process renames the open file to a path demo may not read: demo keeps reading, and only a new open is denied. Then the administrator reloads the profile without the rule: the open descriptor still reads, and a new open is denied. The source says it plainly: no revocation at this time. To take a file away, restart the program.

Details and sources

Details

  • At open, AppArmor matches the name and remembers on the open file which permissions were asked for and under which label.
  • read, write, mmap, locking and receiving a descriptor ask again, but the question is answered from that memory when nothing more is requested and the task's label is the one remembered. Only otherwise is a name built, at that later moment, and matched.
  • Run 1: the task opened /srv/demo/b/moving (allowed by /srv/demo/b/** r,); mv /srv/demo/b/moving /srv/demo/hidden by another process; then read from the same fd after the wait: ok, read 7 bytes: "moving", fd 3 is /srv/demo/hidden, open the new path: FAILED errno=13.
  • Run 2: the task opened /etc/demo/public; apparmor_parser -r loaded the same profile without that rule; then read from the same fd after the wait: ok, read 12 bytes: "public data", open the same path again: FAILED errno=13, with apparmor="DENIED" operation="open" ... name="/etc/demo/public".
  • A file deleted while open behaves the same: the descriptor keeps reading and /proc/self/fd/3 shows /srv/demo/b/gone (deleted).
  • For administrators: tightening a profile and reloading it changes what running programs can open from now on. It does not close what they already hold.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

for AppArmor developers for security researchers

Code

06 Descriptors that arrive already open

2 · DESCRIPTORS THAT ARRIVE OPEN profile opener may read the secret exec, fd 3 open demo fd 3: closed read: Bad file descriptor apparmor="DENIED" operation="file_inherit" profile="demo" name="/etc/demo/secret" requested_mask="r" denied_mask="r" unconfined shell exec 3</etc/demo/secret exec, fd 3 open demo fd 3: kept, not checked read 12 bytes: "secret data" no audit record this is how redirected input and output keep working a profile does not limit what an unconfined parent hands over
Two ways demo gets a descriptor it did not open. Across an exec from another profile, the kernel checks the descriptor against demo and closes it. From an unconfined parent, the check is skipped and demo reads the secret file.

At an exec that changes the profile, inherited descriptors are checked against the new profile; a denied one is replaced by a null file or closed (closed in the run). A descriptor opened by an unconfined task is exempt: the confined program can use it whatever its rules say. Both observed.

A descriptor can also arrive already open. At exec, when the profile changes, the kernel checks every inherited descriptor against the new profile. In this run a program under another profile opens the secret and then executes demo. Demo finds the descriptor closed, and the log says file_inherit, denied. But there's one exception. If the file was opened by an unconfined task, the check is skipped. Here an unconfined shell opens the secret on descriptor three and starts demo. Demo reads the secret, and nothing is logged. That's how redirected input and output keep working. It also means the profile doesn't limit what an unconfined parent hands over.

Details and sources

Details

  • At an exec that changes the label, every open descriptor is checked for the new label with the operation name file_inherit. A descriptor that fails is replaced by the null device or closed.
  • The same check runs when a descriptor is received over a unix socket (file_receive) and on each later use.
  • The exception is delegation: when the label stored in the open file is unconfined, the check ends with success before any name is built. The kernel comment calls it "file delegation from unconfined tasks".
  • Run 1 (confined to confined). Profile opener has /etc/demo/secret r, and an exec rule Px -> demo-t. The program opened the secret, then executed itself into demo-t: readlink /proc/self/fd/N: FAILED errno=2, read from the inherited fd: FAILED errno=9 (Bad file descriptor), and apparmor="DENIED" operation="file_inherit" class="file" profile="demo-t" name="/etc/demo/secret" comm="t" requested_mask="r" denied_mask="r".
  • Run 2 (unconfined to confined). sh -c 'exec 3</etc/demo/secret; exec aa-exec -p demo-t -- ./t fdread 3' printed fd 3 is /etc/demo/secret and read from the inherited fd: ok, read 12 bytes: "secret data". No audit record.
  • Consequences: a shell, a service manager or a wrapper that starts a confined program decides which descriptors it starts with. Open sensitive files with O_CLOEXEC, and start confined services from a launcher that holds nothing they should not get.
  • An exec that keeps the same profile (ix) checks nothing: the label did not change.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

for AppArmor developers for security researchers

Code

  • apparmor_bprm_committing_creds calls aa_inherit_files unless the label is unchanged or the new one is unconfined: lsm.c:957-973; aa_inherit_files file.c:721-754.
  • __file_is_delegated is unconfined(obj_label): file.c:577-580; used in the fast path of aa_file_perm file.c:655-661.

07 When a file has no name

3 · NO NAME demo holds a descriptor of the directory /mnt/d then: umount -l /mnt/d detached mount: file f openat(dirfd, "f"): the path no longer reaches the root apparmor="DENIED" operation="open" info="Failed name lookup - disconnected path" error=-13 profile="demo" name="f" requested_mask="r" denied_mask="r" no leading slash deleted files: same idea flags=(attach_disconnected) and the rule /f r, matched as /f: allowed read: "from the detached mount" the real /f: another file one rule, two files attach_disconnected.path=/outside keeps them apart
demo holds a descriptor of a directory whose mount is then detached. Opening a file through it gives a path that does not reach the root: denied with Failed name lookup, disconnected path and name f. With attach_disconnected the name becomes /f and a rule for /f matches, although another /f exists.

A path that does not reach the namespace root is denied with info="Failed name lookup - disconnected path". attach_disconnected prefixes a slash, so rules for the real root also match the disconnected file. Both observed.

Sometimes the kernel can't build a name. Demo holds a directory descriptor, the mount under it is detached, and demo opens a file through the descriptor. The path no longer reaches the root. By default that's a denial, and the log says failed name lookup, disconnected path, with a name that has no leading slash. The usual fix is the flag attach_disconnected. It puts a slash in front and matches. In this run, the file from the detached mount then opens through a rule for /f, while a different /f exists. One rule, two files. The path form of the flag keeps them apart.

Details and sources

Details

  • A path is disconnected when walking up from the file does not arrive at the root of the task's mount namespace: the mount was lazily unmounted, or the file comes from another mount namespace through a passed descriptor, or it lives on a kernel-internal mount.
  • Default: the access is denied. The audit record carries info="Failed name lookup - disconnected path" and a name= without a leading slash.
  • Run 1: the task held a descriptor of /mnt/d (a tmpfs), umount -l /mnt/d followed, then openat(dirfd, "f"): FAILED errno=13, and apparmor="DENIED" operation="open" class="file" info="Failed name lookup - disconnected path" error=-13 profile="demo-t" name="f" comm="t" requested_mask="r" denied_mask="r".
  • Run 2: the same with flags=(attach_disconnected) and the rule /f r,: openat(dirfd, file) after the wait: ok (4), read: ok, read 24 bytes: "from the detached mount", fd 4 is /f. A different file, /f with the text "the real /f", exists in the namespace.
  • A POSIX message queue is such a file too: mq_open("/demo-queue") was denied as operation="open" class="file" info="Failed name lookup - disconnected path" ... name="demo-queue".
  • Deleted files: a new check on an unlinked file fails with info="Failed name lookup - deleted entry" unless mediate_deleted or delegate_deleted is in effect; one of them normally is. A descriptor that is already open keeps working (previous scene).
  • attach_disconnected.path=/outside puts disconnected files under their own prefix, so rules can name them separately. See The other profile flags.
  • Known discrepancy: any path flag in a profile changes the handling of deleted files. See the scene "Aliasing, and a default that goes missing" in The other profile flags.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

Read more

for AppArmor developers for security researchers

Code

08 O_PATH: a handle without a check

4 · O_PATH demo fd = open("/etc/demo/secret", O_PATH) ok: AppArmor is not asked the kernel returns before the file-open hook fstat(fd) size=12 uid=0 mode=600 ok, also under an explicit deny rule open("/proc/self/fd/3", O_RDONLY) Permission denied a normal open, matched against the file's name at that moment O_PATH does not leak contents it shows that a file exists, and pins the file while its name changes sec-unmediated: what else never asks
demo opens the secret file with O_PATH: no AppArmor check. fstat through the handle works. Reopening the handle through /proc/self/fd for reading is a normal open and is denied. The same happens for a file with an explicit deny rule.

open(..., O_PATH) reaches no AppArmor check. fstat on the handle succeeds; re-opening it through /proc/self/fd/N is checked like any open and denied. Observed for a file with no rule and for a file with a deny rule.

One kind of open skips the check. With O_PATH, a program gets a handle on a file without reading or writing it. The kernel returns before it asks AppArmor. Demo can do that to the secret, even under a deny rule, and stat it through the handle. What it can't do is turn the handle into data. Reopening it through /proc/self/fd is a normal open, matched against the file's name at that moment, and denied. So O_PATH doesn't leak contents. It shows that a file exists, and pins it while its name changes. The deck on what is not mediated lists the rest.

Details and sources

Details

  • An O_PATH open gives a descriptor that names a location. It cannot be read or written. The kernel finishes such an open before it calls the security hook for opening files.
  • What can be done with the handle: fstat (allowed under every profile, see What is not mediated); openat(fd, "name", ...) and a re-open through /proc/self/fd/N, which are ordinary opens and are checked under the object's current name; fchdir, which has no AppArmor check; linkat and execveat with AT_EMPTY_PATH, which reach the link and exec checks.
  • The run, on /etc/demo/secret (no rule): open O_PATH: ok (3), fstat on the O_PATH fd: ok (0), size=12 uid=0 mode=600, fd 3 is /etc/demo/secret, re-open through /proc/self/fd/N O_RDONLY: FAILED errno=13 (Permission denied). The same lines for /etc/demo/denied, which has deny /etc/demo/denied rwkl,.
  • The handle follows the object across a rename. A later open through it is matched against the name the object has then.
  • The shipped who profile records the same thing from a system-call trace: an openat with O_PATH and a newfstatat, and the note that these calls are not mediated, so the profile has no rule for them.
  • When a trace shows an O_PATH open that the log never mentions, nothing is missing from the profile.
  • Observed on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root. The run used the profile demo-t and the test program t from findings/security/observed/; the slide writes demo for both. The kernel code cited is mainline at the commit the map describes; the guest kernel is one release older and behaved as that code reads.

Read more

for AppArmor developers for security researchers

Code

09 Where to go from here

ROADS a rule is a promise about a name more names · names that change · no name · no question sec-unmediated operations that never ask syn-flags-other every path flag prac-symlinks links resolved away prac-hardlinks links that are names syn-mount who may bind mount also: adm-denials (name= and info=) · k-match (building the name) · namespaces attachment · prac-privileged · sec-threat-model
The limits of name-based mediation in the centre, with roads to sec-unmediated, prac-symlinks, prac-hardlinks, syn-flags-other and syn-mount, and a row naming adm-denials, k-match, namespaces, attachment, prac-privileged and sec-threat-model.

Next: sec-unmediated, prac-symlinks, prac-hardlinks, syn-flags-other, syn-mount, adm-denials, k-match.

So a file rule is a promise about names, kept at the moment of each check. Three habits follow. Keep mount rules and the sys_admin capability away from programs that don't mount, and don't grant write on directory names above data you protect by name. Treat attach_disconnected and chroot_relative as flags that widen a profile. And after you tighten a profile, restart the program. From here, the deck on what is not mediated lists the operations that never ask at all. The symlink and hard link decks cover the two kinds of link, and the flags deck has every path flag.

Details and sources

Details

  • A file rule is matched against a name built at the moment of each check. This deck showed where that differs from a promise about a file: a bind mount (a second name), the root the name is counted from, a directory rename, the time between open and use, descriptors that arrive open, files with no name, and O_PATH.
  • Three habits for a profile author: no mount rule and no capability sys_admin unless the program mounts, and no w on directory names above data protected by name; treat attach_disconnected and chroot_relative as widening flags; restart the program after removing a rule.

What each deck answers:

Read more

Basis of the statements on this page: "observed" means run on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser 5.0.2), as root, with the profiles and the test program kept in findings/security/observed/. "Code" means read from the kernel source at the commit the map describes and not run. The guest kernel is a distribution kernel one release older than that source; every observation agrees with the code cited in the scenes.

Where the name comes from

InputEffect on the nameBasis
the directory entry usedeach hard link is its own namecode; see Hard links
symlinks on the wayresolved before the check; the target's name is matchedcode; see Symlinks
the mount the file was reached througha bind mount's path is the nameobserved
the task's mount namespacethe name starts at that namespace's rootobserved (chroot case), code
flags=(chroot_relative)the name starts at the task's root directoryobserved
a directorythe name ends in /observed (name="/etc/demo/private/")
the moment of the checka rename before the check changes the nameobserved

Observed cases

All with a profile that has /etc/demo/public r, and no rule for /etc/demo/secret, unless a row says otherwise.

CaseWhat was doneResult
bind mountmount --bind /etc/demo/secret /etc/demo/public by an unconfined shell, then the confined open of /etc/demo/publicreads "secret data"; no audit record
chrootchroot("/srv/jail"), open /etc/demo/publicdenied, name="/srv/jail/etc/demo/public"
chroot with chroot_relativethe sameallowed; reads the jail's copy
directory renamerules /srv/demo/a/ rw, /srv/demo/c/ rw, /srv/demo/c/** r,; rename a to ca/secret-notes denied before, c/secret-notes read after
rename to a name with no rulerename a to b2denied, operation="rename_dest" name="/srv/demo/b2/" requested_mask="wc"
open file renamedanother process moves the open file to a path with no rulethe descriptor keeps reading; a new open is denied
profile replacedapparmor_parser -r with the rule removed, file openthe descriptor keeps reading; a new open is denied
file deleted while openrm by another processthe descriptor keeps reading
descriptor from an unconfined parentexec 3</etc/demo/secret then aa-execthe confined program reads the secret; no audit record
descriptor across a profile-changing execopened under profile opener, exec into demo-tdescriptor closed; operation="file_inherit" denied
disconnected pathdirectory descriptor, umount -l, openatdenied, info="Failed name lookup - disconnected path" name="f"
disconnected with attach_disconnectedthe same, rule /f r,allowed as /f
O_PATHopen and fstat of the secretboth succeed; re-open through /proc/self/fd/N denied

Messages in the log

info=Meaning
Failed name lookup - disconnected paththe path does not reach the root of the mount namespace and the profile has no attach_disconnected
Failed name lookup - deleted entrythe file is unlinked and neither mediate_deleted nor delegate_deleted is in effect
Failed name lookup - name too longthe path does not fit the buffer

operation="file_inherit" is the check of a descriptor carried across an exec; operation="rename_src" and operation="rename_dest" are the two halves of a rename.

Checklist for a profile

  • No mount rule and no capability sys_admin unless the program mounts. A confined program without them cannot create a second name by mounting.
  • No w on directory names above data that other rules protect by name: /srv/** rw, allows moving /srv/private/.
  • Rules for directories the program owns, together with ordinary ownership and modes, which follow the file and not the name.
  • attach_disconnected and chroot_relative widen a profile. Prefer attach_disconnected.path=.
  • A deny rule protects a path, not a file.
  • Programs started by an unconfined parent get that parent's open descriptors without a check. Use O_CLOEXEC and a launcher that holds nothing sensitive.
  • After removing a rule, restart the program. A reload does not close open files.

for AppArmor developers for security researchers

Code map

WhatWhere
building the named_namespace_path, aa_path_name in linux:security/apparmor/path.c:88-222
disconnected pathsdisconnect in linux:security/apparmor/path.c:48-72
the path hookslinux:security/apparmor/lsm.c:222-463
open and the per-file contextapparmor_file_open, apparmor_file_alloc_security in linux:security/apparmor/lsm.c:465-519
revalidationaa_file_perm, __file_path_perm in linux:security/apparmor/file.c:490-675
inherited descriptorsaa_inherit_files in linux:security/apparmor/file.c:721-754
O_PATHdo_dentry_open in linux:fs/open.c:951-977

Roads from here

ATTACHMENT, NAMESPACES, STACKING

PROFILE HEAD

RULE CLASSES

  • Mount rules — the rule a confined program needs before it can bind mount

IN PRACTICE · security-sensitive programs

SECURITY · threat model and limits

RUNNING THE PARSER

IN THE KERNEL