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
- Symlinks: rules see through them — symlinks are resolved before the check
- Hard links and name-based rules — a hard link is a second name with its own rules
- The other profile flags — attach_disconnected and the other flags that change a file's name
Part of journeys
- File access in depth, step 12 of 12 · previous: Rule priority
- Hardening a privileged program, step 10 of 11 · previous: Reading a denial · next: What is not mediated
01 A rule names a path, not a file
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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
aa_path_nameandd_namespace_pathbuild the name: path.c:88-176, path.c:202-222.- File systems whose superblock has
SB_NOUSERare skipped before any name is built:path_mediated_fs, lib.h:146-149.
02 Another name for the same file
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/publicthen 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'printedopen O_RDONLY: ok (3)andread: ok, read 12 bytes: "secret data". The audit log had no record for it. - Who can bind mount: the
mountsystem call needsCAP_SYS_ADMINover the mount namespace. A confined task also needscapability sys_admin,and amountrule in its profile. An unconfined task is not asked by AppArmor. Container runtimes and service managers arrange mounts before the confined program starts. - A
denyrule 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
d_absolute_pathon the path that was handed to the hook: path.c:117-128.mount(2)for a confined task:apparmor_sb_mountlsm.c:707-742, bind mounts inaa_bind_mountmount.c:355-394.
03 Counted from which root?
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. Afterchroot("/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,andcapability sys_chroot,: without the flagopen inside the chroot: FAILED errno=13 (Permission denied)and the audit recordapparmor="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/publicwith the text "jail copy") was made beforehand by the unconfined setup script (findings/security/observed/run.sh); the profile givesdemono write access there. A program that can also write a directory tree and holdssys_chrootcan 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/publicthere. Withchroot_relativethat file carries the name of the system's file. chrootneedsCAP_SYS_CHROOT, which a confined task has only withcapability 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_rootmoves 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
- apparmor.d(5) Flags
- The other profile flags (the scene "Three questions before a rule is tried"), Policy namespaces
for AppArmor developers for security researchers
Code
PATH_CHROOT_RELselects__d_pathagainstcurrent->fsroot, otherwised_absolute_path: path.c:117-128. Flag bits: path.h:17-26.apparmor_sb_pivotroot: lsm.c:774-786.
04 A rename moves files between rules
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 (
rwin profile letters) and write and create on the new name (w).RENAME_EXCHANGEasks 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/srvand 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:
rwon the old name andwon 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
won 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
apparmor_path_rename: lsm.c:386-448; the masks at lsm.c:433-444.- The link check with its subset test, for comparison:
aa_path_linkfile.c:437-477.
05 Checked at open, used later
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/hiddenby another process; thenread 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 -rloaded the same profile without that rule; thenread from the same fd after the wait: ok, read 12 bytes: "public data",open the same path again: FAILED errno=13, withapparmor="DENIED" operation="open" ... name="/etc/demo/public". - A file deleted while open behaves the same: the descriptor keeps reading and
/proc/self/fd/3shows/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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
apparmor_file_openrecords the request in the file's context: lsm.c:465-507; the opener's label is stored byapparmor_file_alloc_securitylsm.c:509-519.aa_file_perm: the fast path at file.c:655-661, the slow path__file_path_permat file.c:490-544 with the comment "No revocation at this time" at file.c:504-507.
06 Descriptors that arrive already open
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
openerhas/etc/demo/secret r,and an exec rulePx -> demo-t. The program opened the secret, then executed itself intodemo-t:readlink /proc/self/fd/N: FAILED errno=2,read from the inherited fd: FAILED errno=9 (Bad file descriptor), andapparmor="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'printedfd 3 is /etc/demo/secretandread 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
apparmor_bprm_committing_credscallsaa_inherit_filesunless the label is unchanged or the new one is unconfined: lsm.c:957-973;aa_inherit_filesfile.c:721-754.__file_is_delegatedisunconfined(obj_label): file.c:577-580; used in the fast path ofaa_file_permfile.c:655-661.
07 When a file has no name
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 aname=without a leading slash. - Run 1: the task held a descriptor of
/mnt/d(a tmpfs),umount -l /mnt/dfollowed, thenopenat(dirfd, "f"):FAILED errno=13, andapparmor="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,/fwith the text "the real /f", exists in the namespace. - A POSIX message queue is such a file too:
mq_open("/demo-queue")was denied asoperation="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"unlessmediate_deletedordelegate_deletedis in effect; one of them normally is. A descriptor that is already open keeps working (previous scene). attach_disconnected.path=/outsideputs 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
- apparmor.d(5) Flags, apparmor.d(5) KNOWN BUGS
- The other profile flags, Profile attachment (the scene "A path the kernel cannot name")
for AppArmor developers for security researchers
Code
disconnect(): path.c:48-72; whereconnectedis cleared path.c:138-147; deleted entries path.c:158-164; theinfostrings path.c:209-216.
08 O_PATH: a handle without a check
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_PATHopen 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;linkatandexecveatwithAT_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 hasdeny /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
whoprofile records the same thing from a system-call trace: anopenatwithO_PATHand anewfstatat, and the note that these calls are not mediated, so the profile has no rule for them. - When a trace shows an
O_PATHopen 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_parser5.0.2), as root. The run used the profiledemo-tand the test programtfromfindings/security/observed/; the slide writesdemofor 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
- What is not mediated, Profiles for security-sensitive programs (the scene "Finding every operation: the log is not enough"), Symlinks
for AppArmor developers for security researchers
Code
do_dentry_openreturns forO_PATHat open.c:951-956, beforesecurity_file_openat open.c:977.vfs_getattrcallssecurity_inode_getattr: stat.c:258-267.- The comment in the
whoprofile: who:14-24.
09 Where to go from here
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
mountrule and nocapability sys_adminunless the program mounts, and nowon directory names above data protected by name; treatattach_disconnectedandchroot_relativeas widening flags; restart the program after removing a rule.
What each deck answers:
- What is not mediated: the operations no rule covers.
- Symlinks and Hard links: the two kinds of link.
- The other profile flags:
attach_disconnected,chroot_relative,mediate_deleted. - Mount rules: what a confined program needs before it can bind mount.
- Reading a denial: the
name=andinfo=fields. - Matching at run time: how the kernel builds and matches the name.
- Policy namespaces, Profile attachment, Profiles for security-sensitive programs, the threat model.
Read more
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
| Input | Effect on the name | Basis |
|---|---|---|
| the directory entry used | each hard link is its own name | code; see Hard links |
| symlinks on the way | resolved before the check; the target's name is matched | code; see Symlinks |
| the mount the file was reached through | a bind mount's path is the name | observed |
| the task's mount namespace | the name starts at that namespace's root | observed (chroot case), code |
flags=(chroot_relative) | the name starts at the task's root directory | observed |
| a directory | the name ends in / | observed (name="/etc/demo/private/") |
| the moment of the check | a rename before the check changes the name | observed |
Observed cases
All with a profile that has /etc/demo/public r, and no rule for /etc/demo/secret, unless a row says otherwise.
| Case | What was done | Result |
|---|---|---|
| bind mount | mount --bind /etc/demo/secret /etc/demo/public by an unconfined shell, then the confined open of /etc/demo/public | reads "secret data"; no audit record |
| chroot | chroot("/srv/jail"), open /etc/demo/public | denied, name="/srv/jail/etc/demo/public" |
chroot with chroot_relative | the same | allowed; reads the jail's copy |
| directory rename | rules /srv/demo/a/ rw, /srv/demo/c/ rw, /srv/demo/c/** r,; rename a to c | a/secret-notes denied before, c/secret-notes read after |
| rename to a name with no rule | rename a to b2 | denied, operation="rename_dest" name="/srv/demo/b2/" requested_mask="wc" |
| open file renamed | another process moves the open file to a path with no rule | the descriptor keeps reading; a new open is denied |
| profile replaced | apparmor_parser -r with the rule removed, file open | the descriptor keeps reading; a new open is denied |
| file deleted while open | rm by another process | the descriptor keeps reading |
| descriptor from an unconfined parent | exec 3</etc/demo/secret then aa-exec | the confined program reads the secret; no audit record |
| descriptor across a profile-changing exec | opened under profile opener, exec into demo-t | descriptor closed; operation="file_inherit" denied |
| disconnected path | directory descriptor, umount -l, openat | denied, info="Failed name lookup - disconnected path" name="f" |
disconnected with attach_disconnected | the same, rule /f r, | allowed as /f |
O_PATH | open and fstat of the secret | both succeed; re-open through /proc/self/fd/N denied |
Messages in the log
info= | Meaning |
|---|---|
Failed name lookup - disconnected path | the path does not reach the root of the mount namespace and the profile has no attach_disconnected |
Failed name lookup - deleted entry | the file is unlinked and neither mediate_deleted nor delegate_deleted is in effect |
Failed name lookup - name too long | the 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
mountrule and nocapability sys_adminunless the program mounts. A confined program without them cannot create a second name by mounting. - No
won 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_disconnectedandchroot_relativewiden a profile. Preferattach_disconnected.path=.- A
denyrule protects a path, not a file. - Programs started by an unconfined parent get that parent's open descriptors without a check. Use
O_CLOEXECand 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
| What | Where |
|---|---|
| building the name | d_namespace_path, aa_path_name in linux:security/apparmor/path.c:88-222 |
| disconnected paths | disconnect in linux:security/apparmor/path.c:48-72 |
| the path hooks | linux:security/apparmor/lsm.c:222-463 |
| open and the per-file context | apparmor_file_open, apparmor_file_alloc_security in linux:security/apparmor/lsm.c:465-519 |
| revalidation | aa_file_perm, __file_path_perm in linux:security/apparmor/file.c:490-675 |
| inherited descriptors | aa_inherit_files in linux:security/apparmor/file.c:721-754 |
O_PATH | do_dentry_open in linux:fs/open.c:951-977 |
Roads from here
ATTACHMENT, NAMESPACES, STACKING
- Policy namespaces — policy namespaces which are not mount namespaces
- Profile attachment — disconnected paths at exec
PROFILE HEAD
- The other profile flags — attach_disconnected and chroot_relative and mediate_deleted
RULE CLASSES
- Mount rules — the rule a confined program needs before it can bind mount
IN PRACTICE · security-sensitive programs
- Symlinks: rules see through them — the link that is resolved away
- Hard links and name-based rules — the link that is a second name and the subset test
- Profiles for security-sensitive programs — exact paths in profiles for privileged programs
SECURITY · threat model and limits
- What is not mediated — the operations that never ask AppArmor
- AppArmor's threat model (no slides yet) — what AppArmor is meant to stop
RUNNING THE PARSER
- Reading a denial — reading the name and info fields of a denial
IN THE KERNEL
- Matching at run time — how the kernel builds and matches the name