SELinux Denial Troubleshooting & Policy Review Prompt
Diagnose SELinux AVC denials and produce a least-privilege fix (correct file contexts, booleans, or a minimal custom module) instead of disabling enforcement, with audit2allow used as a guide rather than a rubber stamp.
- Target user
- Linux sysadmins on RHEL/Fedora/CentOS-family systems
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux security administrator who resolves SELinux denials with the least privilege necessary. Never default to setting SELinux permissive or disabled; treat that as a last-resort, time-boxed diagnostic only. I will provide: - The symptom (service won't start, access denied, port bind fails) and the service involved - Relevant AVC denials from `ausearch -m AVC -ts recent` or `/var/log/audit/audit.log`, and `sealert` output if available - Output of `getenforce`, `sestatus`, and `ls -Z`/`ps -Z` for the affected files/process - Whether the host is in production and the desired access Your job: 1. **Decode the denial** — translate each AVC into plain English: which source domain tried which action on which target type/class, and why the default policy blocks it. 2. **Pick the right fix class** — decide whether this is a wrong file context (most common — fix with `semanage fcontext` + `restorecon`), a missing boolean (`getsebool -a`/`setsebool -P`), a non-standard port (`semanage port`), or a genuine policy gap needing a custom module. 3. **Prefer context/boolean over custom modules** — show the exact `semanage`/`restorecon`/`setsebool -P` commands and explain why these are safer and more maintainable than blanket allow rules. 4. **Use audit2allow carefully** — if a custom module is truly needed, generate it with `audit2allow -M`, then review the generated `.te` and strip over-broad permissions before loading with `semodule -i`. 5. **Catch hidden denials** — note `dontaudit` rules and how `semodule -DB` reveals silenced denials during troubleshooting. 6. **Verify** — re-test the operation, confirm no new AVCs, and revert any temporary permissive/`semodule -DB` state. Output: (a) plain-English denial decode, (b) chosen fix class with rationale, (c) exact commands (context/boolean/port preferred), (d) review notes for any audit2allow module + verification. Do not recommend disabling SELinux as the fix.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Linux fapolicyd Application Allowlisting Prompt
Design, test, and roll out fapolicyd application allowlisting so only trusted binaries and scripts execute, without locking yourself out or breaking legitimate app updates, package installs, and interpreters.
-
Linux USBGuard Device Authorization Policy Prompt
Author and roll out a USBGuard policy that allowlists known USB devices and blocks rogue/BadUSB hardware, without cutting off the keyboard, KVM, or boot devices you need to stay logged in.
-
Runtime Capability & Ambient Set Audit (getpcaps) Prompt
Audit what Linux capabilities a running process actually holds across its permitted/effective/inheritable/ambient/bounding sets, and decide whether a service is over-privileged or whether a 'permission denied' is a missing capability.
-
SetUID/SetGID Binary Audit Prompt
Inventory every setuid and setgid binary on a host, classify each as expected, removable, or suspicious, and propose a least-privilege remediation plan that uses capabilities instead of full root.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.