SELinux, AppArmor, and seccomp are core Linux security mechanisms used to restrict process capabilities and protect the system kernel from exploitation.
Quick Comparison
| Feature | SELinux | AppArmor | Seccomp |
|---|---|---|---|
| Primary Focus | Resource access (labels) | Resource access (paths) | System calls (syscalls) |
| Control Type | Mandatory Access Control (MAC) | Mandatory Access Control (MAC) | Syscall Filtering |
| Ease of Use | Complex (steep learning curve) | Easier (path-based rules) | Low-level (best with defaults) |
| Default OS | RHEL, Fedora, CentOS, Android | Ubuntu, Debian, SUSE | Most modern distributions |
1. SELinux (Security-Enhanced Linux)
Originally developed by the NSA, SELinux uses labels to define security contexts for every process and file.
- Mechanism: It assigns a label (user:role:type:level) to subjects (processes) and objects (files/ports).
- Mode of Operation: It defaults to “Deny All.” Access is only granted if a specific policy allows a process type to interact with an object type.
- Strength: Highly granular and secure; it can even restrict the
rootuser.
2. AppArmor (Application Armor)
AppArmor is an alternative MAC system that focuses on file paths rather than labels, making it generally easier to configure for specific applications.
- Mechanism: It uses profiles stored in
/etc/apparmor.d/to restrict which directories or network resources a specific executable can access. - Modes:
- Enforce: Actively blocks and logs unauthorized actions.
- Complain: Only logs violations without blocking them (useful for testing).
- Strength: User-friendly and path-based, making it common in cloud-native and container environments.
3. Seccomp (Secure Computing Mode)
Unlike the others, seccomp does not care about files or labels; it restricts the system calls (syscalls) a process can make to the Linux kernel.
- Mechanism: It acts as a sandbox that “filters” requests. For example, a process might be allowed to
readorwritebut blocked from usingmountorptrace. - Implementation: Typically used via a JSON profile (like in Docker) that whitelists safe syscalls and blocks dangerous ones.
- Strength: Reduces the kernel’s “attack surface” by ensuring that even if an app is compromised, it cannot execute low-level kernel exploits.
Use in Kubernetes & Containers
In modern Kubernetes security, these tools are often used together to provide Defense in Depth:
- seccomp ensures the container can only talk to the kernel in safe ways.
- AppArmor/SELinux ensures the container can only touch specific files or network ports.
- Tools like the Security Profiles Operator are used to manage and distribute these profiles across large clusters