Skip to main content

SecuraWall.com

Email security and continuity

Explore

Troubleshooting · Linux and System Administration

SELinux AVC Denial Troubleshooting: Context, Booleans and Policy

An SELinux AVC denial says a process domain lacks policy permission for an operation on a target type. The `scontext`, `tcontext`, `tclass` and `{ permission }` fields identify who, what…

Technical review:

Architecture and operating model

An SELinux AVC denial says a process domain lacks policy permission for an operation on a target type. The `scontext`, `tcontext`, `tclass` and `{ permission }` fields identify who, what and which action. Disabling SELinux removes evidence and weakens mandatory access control across the host. Check conventional UNIX permissions first, then labels and policy.

`ausearch -m AVC,USER_AVC -ts recent -i` collects readable records. Correlate AVC, SYSCALL and PATH entries for one event; `comm` alone can identify the wrong process. `audit2why` can explain known Boolean or labeling causes. Do not install `audit2allow` output blindly, because every observed access may include attacker or error behavior.

Wrong file labels are common. If application data lives under a nonstandard `/srv` path, create a persistent mapping with `semanage fcontext`, then apply `restorecon`. A temporary `chcon` can disappear during relabeling. Use a documented Boolean when it accurately represents intended behavior. Write a minimal custom policy only for a real new access model.

Prefer a domain-specific permissive setting or controlled window over making the whole system permissive. Test the correction with the real workflow. Absence of a new AVC is insufficient; verify application behavior, ownership and network boundaries. Version custom `.te` source with rationale, owner and a removal review date.

  1. 1Application error and UNIX permission check
  2. 2auditd AVC, SYSCALL and PATH records
  3. 3Context, Boolean or minimal policy decision
  4. 4Functional test in enforcing mode
Test wrong labels, documented Booleans and actual requirements before turning an AVC log into an allow rule.

Design parameters

Source domain
Match scontext domain to the actual executable and systemd unit.
Target type
Check whether the tcontext file, port or process type matches the standard expected type.
Permission class
Match tclass and denied permission to the narrow required operation.
Persistent label
Test `semanage fcontext` and `restorecon` across restart and relabel.
Policy lifecycle
Give custom modules rationale, version, owner and periodic removal review.

Worked example

If `httpd_t` needs to write `/srv/app/uploads` labeled `default_t`, `chmod 777` does not repair the label. Persist the suitable writable web type, run `restorecon`, then verify with `matchpathcon` and a new request.

With 4,000 AVCs in ten minutes, isolate one request or PID. Broad `audit2allow` input can generate unrelated permissions. Reproduce the minimum workflow and inspect each resulting permission.

Example commands: replace lab values and confirm permissions and software versions before use.

ausearch -m AVC,USER_AVC,SELINUX_ERR -ts recent -i
ausearch -m AVC -ts recent --raw | audit2why
matchpathcon -V /srv/app/uploads
semanage fcontext -a -t httpd_sys_rw_content_t '/srv/app/uploads(/.*)?'
restorecon -Rv /srv/app/uploads
getenforce

Troubleshooting

ObservationLikely cause / distinctionVerification
No AVC record appearsauditd may be down, dontaudit may hide it, or SELinux may not be the cause.Check audit and journal, and use a short controlled `semodule -DB` test before restoring defaults.
restorecon changes the label backThe persistent fcontext regex or precedence may be wrong.Inspect `semanage fcontext -l` and verify with `matchpathcon -V`.
A custom module works but is broadBulk audit2allow input may include unrelated accesses.Review the TE source, reproduce minimally and compile only required allow rules.

Acceptance checks

  1. Verify UNIX owner, mode, ACL and application error first.
  2. Collect AVC, SYSCALL and PATH for the same event.
  3. Record scontext, tcontext, tclass and permission.
  4. Test persistent labels or a documented Boolean.
  5. Version a minimal custom policy only when required.
  6. Validate function and absence of new AVCs in enforcing mode.

Related concepts

File permissions and service identities

File access combines users/groups, permission bits, ACLs and security policies. Running an application as root can hide permission problems; prefer a justified, restricted service identity in production. Directory traversal permission differs from file-read permission. Sharing permissions do not necessarily override filesystem restrictions. Identify the account actually running the application, directory chain and ACLs when troubleshooting. Test narrowly required access rather than opening permissions globally.

Least privilege and separation of duties

Least privilege limits the permissions needed for a task to specific resources and time periods. Giving everyone the same administrator role complicates access reviews and investigations. Separate daily-use identities from privileged accounts, and restrict interactive use and unnecessary network access for service identities. An access matrix should show which operation an identity may perform on each resource. Test whether an application keeps working after a permission is removed: unnecessary privileges sometimes become visible only during controlled reduction.

Service lifecycle and dependencies

A running process does not prove that users receive correct service. Review startup order, network or database dependencies, environment variables, file access and health checks together. Restart loops can conceal the root cause. Compare exit codes, recent logs and resource limits, and identify whether systemd or container management triggered the restart. After a controlled restart, validate sessions, writes and dependent services.

Filesystem and storage layers

An application directory, mount point, logical volume and physical device belong to different layers. Inode exhaustion, read-only mounts and filesystem errors can stop writes even when space appears available. A snapshot often shares the same storage failure domain and is not an independent backup. Mount options and expansion methods depend on the filesystem. Verify mounts after reboot: writing to an unmounted directory can fill the wrong device.

Telemetry and time correlation

Telemetry combines logs, metrics and events that explain system behavior. A log describes an event, a metric shows behavior over time, and a distributed trace follows a request across components. Clock differences can make one event appear to occur at several times. Use synchronized clocks, reliable source identifiers and consistent time-zone handling. Alarm design should consider duration and user impact alongside thresholds. Monitor gaps in collection separately: absence of logs must not be interpreted as absence of incidents.

Policy lifecycle

A policy needs management as its scope changes, not just when it is enabled. Separate drafting, observation, pilot deployment, enforcement and periodic review. Every exception needs an owner, reason, scope and expiry date. A successful pilot can still cause production false positives if test data does not represent real user behavior. Identify affected users and applications before deploying with measurable acceptance criteria. A rollback path should identify who may reverse the change and under which conditions, rather than merely locating an interface button.

Primary documentation

Prepared by the Doz Teknoloji technical team using the primary references below. Calculations and lab scenarios state their assumptions; validate the applicable product version before rollout.

Knowledge Center

Enterprise IT Product Sales, Licensing and Deployment
Enterprise IT Project & Solution Scenarios
View all related content
Text on WhatsApp
Copied!