Lesson 1 of 9 · 24m
Mandatory Access Control Is Not Just More Permissions
Build the correct mental model: discretionary permissions decide what owners allow, while MAC policy decides what confined processes may ever do.
The worst SELinux advice on the internet is still setenforce 0. It survives because it appears to work: the application starts, the ticket closes, and the security boundary quietly disappears. The day-one lesson for a new hire is simpler: SELinux is not a stricter version of chmod. It is a separate policy layer that constrains what a process may do even when filesystem permissions say yes.
The two permission questions are different
Discretionary access control asks, "Does the object's owner grant this user access?" Mandatory access control asks, "Does policy allow this subject, in this security context, to perform this operation on that object?" Both must permit the action:
read file = allowed by DAC permissions?
+ allowed by MAC policy?
+ allowed by other LSMs, mount options, capabilities...This is why a root-owned process can still be denied. UID 0 does not repeal SELinux type enforcement. Conversely, a process can pass SELinux and still fail because mode bits, ACLs, immutable attributes, or a read-only mount deny it.
MAC protects the system from confused deputies
Most server compromises do not begin with an attacker logging in as root. They begin with a legitimate service doing something its operators never intended: nginx executing a shell, a web worker reading /etc/shadow, a backup agent writing outside its data root. The process is a deputy acting with ambient authority. SELinux constrains that deputy after compromise.
A useful mental picture:
attacker controls request data
|
v
bug in service -> attacker steers service process
|
v
MAC policy asks: may this service type touch that target type?If the answer is no, the exploit may still crash or corrupt the process, but it cannot casually pivot into unrelated system state.
SELinux is allowlist policy
Unlike traditional permissions, which are often described as broad access minus restrictions, SELinux starts from denial and adds specific allow rules. If policy has no rule permitting httpd_t to write user_home_t, the action is denied even if the file is mode 0777. That inversion surprises people because the failure looks impossible from a Unix-permissions-only worldview.
Permissive mode is diagnostic, not a control
permissive logs what would have been denied but allows the operation anyway. It is useful for a tightly time-boxed compatibility assessment. It is not a deployment strategy. The operational maturity ladder looks like this:
disabled no SELinux policy loaded; worst visibility
permissive policy evaluated and logged, but not enforced
enforcing policy evaluated, logged, and enforcedYour production target is enforcing. If a service needs an exception, make the exception narrow: a boolean, a file context correction, a local type transition, or a tightly scoped policy module.
Field notes
- Never conclude "SELinux is the problem" because
setenforce 0made a symptom vanish. You only proved MAC enforcement is part of the causal chain. - Root does not bypass SELinux; capabilities and UID are separate decision layers.
- MAC failures often appear as application-level permission errors, database connection failures, or unexplained empty files rather than a flashing SELinux error.
- When comparing systems, check
/etc/selinux/configandgetenforce; a machine can boot permissive even if somebody tested enforcing interactively.
Was this lesson helpful?