Use it to confirm a program is actually confined.
Enforce Mode
In enforce mode an AppArmor profile blocks and logs any access its rules do not allow.
1. aa-status — profile under "enforce mode"?
2. aa-enforce /etc/apparmor.d/<profile>.
3. Restart the program.
4. Watch denials.
5. Fix with local rules if needed.
profile in enforce → disallowed access blocked and logged
For AppArmor → Enforce Mode, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Enforce Mode. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
loaded enforcing profile → process attachment → rule match → deny/allow → audit record → workload
Healthy evidence: target process is attached to an enforcing profile, expected denies block, expected allows work and audit records match the exact tests
Step 2 Verification and output interpretation Verify boundary
Verification chain. loaded enforcing profile → process attachment → rule match → deny/allow → audit record → workload
Step 3 Commands Verify boundary
aa-enforce /etc/apparmor.d/usr.sbin.nginx
aa-status | grep -A5 enforce
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: profile is complain/unconfined, wrong process path attaches elsewhere, denials are misattributed, or enforcement is disabled to restore service without fixing policy
Step 5 Common mistakes Narrow the fault
- Enforcing a new profile without a complain-mode trial.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Profiles in complain mode give no protection. After tuning, set enforce (aa-enforce) and watch for denials.
aa-status— loaded profiles and modesjournalctl -k | grep -i apparmor— denialsaa-complain / aa-enforce <profile>— change a profile's modeapparmor_parser -r <profile>— reload a profile
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Enforce mode is confirmed for the specific attached profile/process and operation, but it does not show coverage of unconfined processes or correctness of all allowed rules.
In depth
Enforce mode
In enforce mode, AppArmor applies a profile's rules: anything not allowed is denied and reported. The apparmor(7) manual page explains how profiles are loaded and switched:
apparmor_parserloads profiles into the kernel, andaa-enforcesets a profile to enforce mode.- A denial is logged with
apparmor="DENIED"and the operation, profile, file and requested permissions. - Profiles apply at execution, so a program must be restarted after its profile is first loaded.
Putting a profile into enforce mode
| Step | Command |
|---|---|
| 1. Run in complain mode first, and exercise the program | aa-complain /usr/sbin/myapp |
| 2. Review the log entries | journalctl -k -g 'apparmor="ALLOWED"' |
| 3. Update the profile from the logs | aa-logprof |
| 4. Switch to enforce | aa-enforce /usr/sbin/myapp |
| 5. Restart the service | systemctl restart myapp |
| 6. Watch for denials | journalctl -k -g 'apparmor="DENIED"' -f |
Reading a denial
| Field | Example | Meaning |
|---|---|---|
operation | open, exec, connect | What the program tried |
profile | /usr/sbin/nginx | The profile that denied it |
name | /srv/www/intranet/index.html | The object |
requested_mask / denied_mask | r | The permission requested and denied |
comm | nginx | The process name |
Fixing a denial
| Cause | Fix |
|---|---|
| A new legitimate path | A rule in /etc/apparmor.d/local/<profile>, then reload |
| A program that needs broad changes | Update the profile with aa-logprof |
| A sign of compromise | Investigate: the denial is the protection working |
host$ sudo aa-enforce /usr/sbin/nginx
Setting /usr/sbin/nginx to enforce mode.
host$ sudo journalctl -k -g 'apparmor="DENIED"' -n 1
apparmor="DENIED" operation="open" class="file" profile="/usr/sbin/nginx" name="/srv/www/intranet/index.html" pid=1203 comm="nginx" requested_mask="r" denied_mask="r" fsuid=33 ouid=0
host$ echo '/srv/www/** r,' | sudo tee -a /etc/apparmor.d/local/usr.sbin.nginx
host$ sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.nginx
host$ curl -s -o /dev/null -w "%{http_code}\n" http://localhost/intranet/
200
host$ sudo aa-status | grep -A1 "enforce mode" | head -2
Reading the fix
nginx was denied reading web content under /srv/www, a path its packaged profile doesn't cover. One line in the local override allows reading that tree. Reloading the profile applies it without a service restart, and the page loads.
Documented example, not captured output.
How it works at runtime
Enforce Mode is part of AppArmor → Enforce Mode. AppArmor Enforce Mode actively blocks operations denied by an attached profile while logging policy violations, so process attachment and the exact denial record must be correlated with workload behavior.
Topic-specific state model. AppArmor Enforce Mode actively blocks operations denied by an attached profile while logging policy violations, so process attachment and the exact denial record must be correlated with workload behavior.
Interpretation rule. - Enforce mode globally available ≠ every profile/process is enforcing.
- A logged DENIED event ≠ the denied operation is necessarily the application root cause.
Quick reference
Enforce mode blocks and logs anything outside the profile.
aa-enforce /etc/apparmor.d/usr.sbin.named
aa-status | sed -n '/enforce mode/,/complain mode/p'
journalctl -k --since -1h | grep 'apparmor="DENIED"'
A denial line contains operation, profile, name (path) and requested_mask — enough to add the missing rule. Reload after edits with apparmor_parser -r.
Limits and how it fails
Primary failure point. Enforce mode is confirmed for the specific attached profile/process and operation, but it does not show coverage of unconfined processes or correctness of all allowed rules.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Enforce Mode owns blocking policy behavior.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in AppArmor → Enforce Mode. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://gitlab.com/apparmor/apparmor/-/wikis/Documentation · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Enforce Mode operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Enforce Mode.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | AppArmor Enforce Mode actively blocks operations denied by an attached profile while logging policy violations, so process attachment and the exact denial record must be correlated with workload behavior. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | loaded enforcing profile → process attachment → rule match → deny/allow → audit record → workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Enforce mode is proven for the specific attached profile/process and operation; it does not prove coverage of unconfined processes or correctness of all allowed rules. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux security/trust evidence can establish this proof path: loaded enforcing profile → process attachment → rule match → deny/allow → audit record → workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. Enforce mode is proven for the specific attached profile/process and operation; it does not prove coverage of unconfined processes or correctness of all allowed rules. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
Enforce Mode · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Enforce Mode |
|---|---|
| Topic path | AppArmor → Enforce Mode |
| Runtime state | AppArmor Enforce Mode actively blocks operations denied by an attached profile while logging policy violations, so process attachment and the exact denial record must be correlated with workload behavior. |
| Fast checks | - Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Enforce Mode. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check. |
| Verification chain | loaded enforcing profile → process attachment → rule match → deny/allow → audit record → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Enforce mode is proven for the specific attached profile/process and operation; it does not prove coverage of unconfined processes or correctness of all allowed rules. Boundary chain: process credentials/namespace → path/mount lookup → DAC/ACL/LSM → filesystem metadata → block/device/backend → completion/read-back. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |