Sub topic 9
Finding AVC Denials in the Audit Log
Assume that you are comfortable with the Linux command line, sudo, service management, and ordinary file permissions. You also need a RHEL-family system with SELinux enabled and an auditd service collecting security events.
What an AVC denial means
An AVC, or Access Vector Cache, denial is an SELinux policy decision that refused an action. The normal Linux permission check may have allowed the action, but SELinux still denied it because the process domain was not permitted to access the target type.
For example, Apache may run in the httpd_t domain and try to read a file labeled default_t. The file's Unix owner and mode bits can be correct, but the SELinux policy can still reject the read.
A denial usually contains these important fields:
| Field | Meaning |
|---|---|
| `scontext` | Security context of the source process |
| `tcontext` | Security context of the target object |
| `tclass` | Kind of target, such as `file` or `tcp_socket` |
| `comm` | Command involved |
| `path` | File path, when the target is a file |
| `denied` | Operation that policy rejected |
The type component is often the most useful part. In system_u:system_r:httpd_t:s0, the type is httpd_t. In unconfined_u:object_r:httpd_sys_content_t:s0, the type is httpd_sys_content_t.
Search the audit log
The ausearch command searches audit records. Search for AVC messages from the recent period:
sudo ausearch -m avc -ts recentIf the service failed several hours ago, use a specific time range:
sudo ausearch -m avc -ts today
sudo ausearch -m avc -ts 10:00:00 -te 10:30:00A file denial may look conceptually like this:
avc: denied { read } for pid=1842 comm="httpd"
path="/srv/web/index.html"
scontext=system_u:system_r:httpd_t:s0
tcontext=unconfined_u:object_r:default_t:s0
tclass=fileRead this as: a process in httpd_t tried to read a file labeled default_t, and the policy denied the operation. This points toward a file-labeling problem. A custom path intended for web content would normally use a type such as httpd_sys_content_t.
The permissive=1 field means SELinux logged the action but allowed it. The field permissive=0 means the action was blocked.
Ask tools to interpret a denial
audit2why translates raw AVC records into a short explanation:
sudo ausearch -m avc -ts recent | audit2whyIt may identify a missing boolean, an incorrect label, or a policy rule that is absent. Treat its output as a diagnostic hint. Check the service's intended behavior and inspect the actual context before changing policy.
On systems with the setroubleshoot tools installed, sealert can provide additional explanations:
sudo sealert -a /var/log/audit/audit.logThe audit log is commonly /var/log/audit/audit.log. On some systems, related messages are also visible through the journal:
sudo journalctl -k | grep -i 'avc:.*denied'A practical investigation path
flowchart TD
A[Service operation fails] --> B[Reproduce the failure]
B --> C[Search recent AVC records]
C --> D[Read source and target contexts]
D --> E{Known label or boolean fix?}
E -->|Yes| F[Apply the narrow configuration fix]
E -->|No| G[Inspect policy and investigate further]
F --> H[Reproduce and verify]
G --> HVerify the fix
After changing a label, boolean, or port rule, reproduce the original operation. Search again for new denials and confirm that the service works without granting unrelated access:
sudo ausearch -m avc -ts recent
sudo journalctl -u httpd --since "10 minutes ago"A clean test should show no new denial for the operation you fixed. Older records may remain in the audit log, so distinguish new events from earlier failures.
Exercise
Apache cannot read /srv/web/index.html, and the denial shows scontext=httpd_t and tcontext=default_t. What should you investigate first?
Show answer
Investigate the file label. The path likely needs a persistent httpd_sys_content_t labeling rule followed by restorecon, rather than a custom policy module.