Course contentsShow
← Security
Lesson 1457 of 3,05229. Operating System Security - HardeningFree lesson

AppArmor: Path-Based MAC

Learn AppArmor's profile-based approach using filesystem paths instead of labels for access control.

AppArmor: Path-Based MAC

What you'll learn: How AppArmor enforces mandatory access control by matching file paths instead of security labels.

A Different Approach to MAC

While SELinux uses security labels attached to every file and process (contexts), AppArmor takes a simpler, path-based approach. Instead of labeling objects, AppArmor creates profiles that specify which filesystem paths a program can access and how. Think of it like giving someone directions using street addresses ("you can only enter buildings on 5th Avenue") rather than colored badges ("you can only enter blue-labeled buildings").

How Path-Based MAC Works

AppArmor profiles define rules based on absolute filesystem paths. When a confined process tries to access /etc/passwd, AppArmor checks the profile to see if that exact path (or a matching pattern like /etc/*) is allowed. The kernel intercepts the access attempt and consults the profile before permitting the operation.

This approach has advantages: profiles are often more human-readable, and you don't need to relabel your entire filesystem. The downside? If files move or are accessed via symlinks or hard links, path-based enforcement can be bypassed or become confusing.

Profile Structure

An AppArmor profile typically looks like:

/usr/bin/application {
  /etc/app/config.conf r,
  /var/log/app/*.log w,
  /usr/lib/app/** r,
}

This confines /usr/bin/application to read configuration, write logs, and read libraries—all specified by filesystem paths. The permissions (r for read, w for write) control what operations are allowed.

Path Patterns and Globbing

AppArmor supports wildcards: * matches within a directory level, ** matches recursively. This makes profiles flexible without listing every possible file.

Key Takeaway: AppArmor provides mandatory access control using filesystem paths and pattern matching in profiles, offering a simpler alternative to label-based MAC systems like SELinux, though with trade-offs in handling filesystem complexity.