APPARMOR_XATTRS(7)

โœจ APPARMOR_XATTRS โœจ

okay bestie, this is the apparmor_xattrs page from the AppArmor manual (section 7, we love a deep-cut) ๐Ÿ’…


๐Ÿ’– NAME ๐Ÿ’–

apparmor_xattrs โ€” AppArmor profile xattr(7) matching. yes we're matching on extended attributes now, it's giving very specific girl energy and we're obsessed ๐ŸŽ€


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so here's the tea, bestie: AppArmor profiles can conditionally match files based on the presence and value of extended attributes, on top of the file path. like, you don't just have to say "this is the file" โ€” you can say "this is the file AND it's got this vibe in its xattrs" โœจ

The following profile applies to any file under "/usr/bin" where the "security.apparmor" extended attribute has the value "trusted":

profile trusted /usr/bin/* xattrs=(security.apparmor="trusted") {
    # ...
}

Note that "security.apparmor" and "trusted" are arbitrary โ€” like, those are just the names in this example, and profiles can match based on the value of any attribute. you're not locked into those, iykyk ๐Ÿ’œ

The xattrs value may also contain a path regex:

profile trusted /usr/bin/* xattrs=(user.trust="tier/*") {

    # ...
}

The getfattr(1) and setfattr(1) tools can be used to view and manage xattr values:

$ setfattr -n 'security.apparmor' -v 'trusted' /usr/bin/example-tool
$ getfattr --absolute-names -d -m - /usr/bin/example-tool
# file: usr/bin/example-tool
security.apparmor="trusted"

look at her go ๐Ÿซถ


๐Ÿ† priority, aka main character ranking ๐Ÿ†

The priority of each profile is determined by the length of the path, then the number of xattrs specified. A more specific path is preferred over xattr matches:

# Highest priority, longest path.
profile example1 /usr/bin/example-tool {
    # ...
}

# Lower priority than the longer path, but higher priority than a rule
# with fewer xattr matches.
profile example2 /usr/** xattrs=(
    security.apparmor="trusted"
    user.domain="**"
) {
    # ...
}

# Lowest priority. Same path length as the second profile, but has
# fewer xattr matches.
profile example2 /usr/** {
    # ...
}

so basically: longest path wins first, and then if it's a tie, the one with more xattr matches takes it. slay. ๐Ÿ‘‘


๐Ÿงš the kernel feature check ๐Ÿงš

xattr matching requires the following kernel feature:

/sys/kernel/security/apparmor/features/domain/attach_conditions/xattr

like, no feature file, no xattr matching. that's the whole vibe check bestie ๐Ÿ˜ญ


๐Ÿ’€ KNOWN ISSUES ๐Ÿ’€

AppArmor profiles currently can't reliably match extended attributes with binary values such as security.evm and security.ima. ๐Ÿ’€

not us being unable to read those. it's giving "we tried." In the future AppArmor may gain the ability to match based on the presence of certain attributes while ignoring their values โ€” so like, "is it there?" without the "what does it say?" ๐ŸŒˆ

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

apparmor(8), apparmor_parser(8), apparmor.d(5), xattr(7), aa-autodep(1), clean(1), auditd(8), getfattr(1), setfattr(1), and <https://wiki.apparmor.net>.


mwah ๐Ÿ’‹ this was AppArmor 6.0.0~alpha1, dated 2026-10-05, and yeah it's an alpha so be nice to her. periodt. ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from