Mandatory access denial — SELinux and AppArmor evidence
A mandatory access control denial can occur even when owner/group/mode and ACL checks permit an operation. Distinguish discretionary access denial, SELinux AVC and AppArmor profile events; each uses different policy concepts. Inspect the affected process, object, requested operation, policy mode and correlated audit event, with access authorization and redaction. For SELinux compare expected labeling and approved policy; for AppArmor review the active profile and path rules. Correct mislabeled files through the distribution's documented label management or request a narrowly scoped reviewed policy change for a legitimate operation. Do not disable enforcement, grant all permissions or generate broad allow rules from logs automatically. Verify the intended operation and that unrelated access is still rejected; restore the reviewed previous policy/label configuration if necessary. Prevent with deployment-specific policy tests and audit review. The fixture parses a synthetic AVC with source/target types and operation; it does not invoke a MAC engine or change policy. Example prerequisites: Linux, Bash, Python 3. Run as a non-root user in a private temporary working directory. Example scope: synthetic model. Expected output: synthetic AVC: demo_t write demo_data_t file denied. No system configuration changes.
Formal Syntax & Structure
getenforce; aa-status; authorized ausearch -m AVC,USER_AVC -ts recent; authorized kernel logsParameters & Attributes
| Name | Type | Description |
|---|---|---|
| AVC | diagnostic evidence | SELinux access-vector cache denial evidence. |
| scontext/tcontext | diagnostic evidence | Source and target security contexts. |
| profile | diagnostic evidence | AppArmor policy association; not a SELinux type. |
Return Value
Expected normalized laboratory result: synthetic AVC: demo_t write demo_data_t file denied. A passing fixture does not prove that a live incident has the same cause.
Working Example
python3 - <<'PY'import reline='type=AVC avc: denied { write } scontext=system_u:system_r:demo_t:s0 tcontext=system_u:object_r:demo_data_t:s0 tclass=file permissive=0'm=re.search(r'avc: denied \{ (\w+) \}',line); assert m and m.group(1)=='write'fields=dict(re.findall(r'(scontext|tcontext|tclass|permissive)=([^ ]+)',line))assert fields['scontext'].split(':')[2]=='demo_t' and fields['tcontext'].split(':')[2]=='demo_data_t'assert fields['tclass']=='file' and fields['permissive']=='0'print('synthetic AVC: demo_t write demo_data_t file denied')PY