AppArmor and SELinux container policies
Linux Security Modules (LSMs) can enforce mandatory access control in addition to ordinary ownership and mode bits. AppArmor commonly applies program profiles with path-oriented rules; SELinux commonly makes decisions using labels and a policy. The active security mechanism depends on the host.
Worked example
This is an offline lesson. Scenarios are fictional and Docker commands are unexecuted. Any optional execution requires an approved disposable VM, a reviewed preloaded image with verified digest, blocked external access and appropriate resource limits. No host-policy change, real credentials or live scan is required. Keep the exercise offline. Before any separately authorized runtime check, verify the effective daemon, builder, runner or deployment identity as applicable; use synthetic data, reviewed inputs and bounded resources. Record missing evidence as NOT RUN.
Synthetic incidentApplication UID: nonrootFile mode: apparently permits readOutcome: read deniedHypotheses: mount visibility; effective ownership; LSM policy; other runtime controlsEvidence needed: approved host policy status, relevant sanitized denial, mount targetDocker supplies a container profile named docker-default when AppArmor is supported and enabled in the applicable configuration. This is not a daemon profile. SELinux-enabled hosts have their own policy and label requirements; bind-mount label changes can affect host files and other services. Do not relabel broad paths as a shortcut. Ask an authorized administrator to check the enforcing state, relevant policy and denial evidence, then select an approved narrow fix. A policy in observation-only mode may record events without preventing them. Validate intended reads and writes plus expected denials after the correction. Do not alter host policy for this lesson. Record whether the relevant profile or policy is actually enforcing the selected workload. A logged event alone may be observational; a file access failure may have another cause. Compare policy evidence with mount visibility and discretionary permissions before proposing a narrowly scoped change.
Common mistake
Ordinary file mode bits do not override an enforcing mandatory access policy. Do not disable an LSM to repair an application.
Manual practice
Given the fictional incident, explain why the mode bits are insufficient evidence. Write a three-step diagnosis and one narrowly scoped recovery verification.
Worksheet: lab-fixtures/docker-container-security/07-mandatory-access-control/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
AppArmor and SELinux container policies — Knowledge check
Apply defensive container security reasoning in a fictional scenario.
What is an LSM policy additional to?
What does docker-default refer to on supported AppArmor hosts?
What should happen before a host-label change?