Platform teams are often pressured to run setenforce 0 or to disable application controls to unblock software deployments. To measure the exact security cost of that compromise, we tested 4 post-exploitation attacks against default Red Hat Enterprise Linux 9.8 (RHEL) configurations. One host maintained RHEL's default security posture, with SELinux enforcing, fapolicyd, and kernel defaults on, and the other host had those controls turned off. To evaluate RHEL's application allowlisting capabilities, we also installed fapolicyd. On the other host, we turned those controls off. The first host blocked all 4 attacks, and the second host stopped none of them.
Key findings
Our testing revealed a stark contrast between a fully hardened RHEL 9.8 system and one with security controls disabled:
- 100% block rate on the hardened host: The hardened RHEL 9.8 host successfully blocked all 4 post-exploitation attack vectors tested.
- 0% block rate on permissive host: The permissive host failed to stop any of the 4 attack vectors, allowing full exfiltration and execution.
- Effective layered enforcement: SELinux and
fapolicydeffectively enforced mandatory access control (MAC) and application allowlisting at the system level, stopping file reads, network pivots, and untrusted binary execution.
Methodology and test environment
We provisioned 2 identical RHEL 9.8.0 virtual machines with these specifications:
- Kernel:
5.14.0-687.5.1.el9_8.x86_64 - Architecture: x86_64 KVM guests
- Base image: The same RHEL 9.8.0 compose
One system kept SELinux enforcing and the kernel defaults, and we installed fapolicyd ("hardened"). The other was deliberately weakened ("permissive") to simulate a host where an administrator has disabled security controls, a common pattern when administrators disable controls to quickly bypass application errors during deployment.
We ran our tests on RHEL 9.8.0 (kernel 5.14.0-687.5.1.el9_8.x86_64) in October 2026. Our lab included KVM guests and bare metal, using the same compose. Our test scripts are available from github.com/Amy-Ra-lph/defense-in-depth-tte.
Hardened host (SELinux enforcing, kernel defaults, fapolicyd added)
- SELinux: Enforcing
- fapolicyd: Active (default policy,
permissive=0) - LSM stack:
lockdown,capability,landlock,yama,selinux,bpf - kptr_restrict: 1 (kernel pointers hidden)
- ASLR: Full (
randomize_va_space=2) - Slab hardening: Kernel defaults (randomized freelists,
init_on_alloc) - auditd: Active
Permissive host (deliberately weakened)
- SELinux: Permissive (
setenforce 0 + /etc/selinux/config) - fapolicyd: Disabled (
systemctl disable --now fapolicyd) - Slab hardening: Disabled (
grubby --args="slab_nomerge init_on_alloc=0 init_on_free=0") - Firewall: Trusted zone (
firewall-cmd --set-default-zone=trusted)
We rebooted the permissive host so the kernel parameters took effect. Both hosts were running the same kernel.
Attack simulation
Each attack assumes the attacker already has a foothold, for example from a web application vulnerability, and is trying to expand it. The 4 vectors each aim at a specific control.
Shell scripts connected to both hosts over SSH, ran each attack, and recorded the result and the script's "wall time" (how long the harness took to finish). Wall time here is dominated by SSH round-trip overhead, not the speed of the security decision itself. The actual allow or deny happens at the syscall level in microseconds. The meaningful result in the tables below is pass or fail, not the millisecond delta.
Attack 1: Confined file read (SELinux)
Scenario: An attacker compromises a web application (httpd) and uses a CGI web shell to read sensitive files outside the web root — specifically, user home directories containing credentials or personal identifiable information (PII).
Method: We deployed a CGI script to /var/www/cgi-bin/ that attempts to cat /home/attacker/secrets.txt. The file has permissions 644, making it world-readable with discretionary access control (DAC), and the parent directory is 755. On a system without mandatory access control (MAC) controls, the apache user (running as httpd) can read this file.
What's at risk: Web application compromises are the most common initial access vector. If httpd can read arbitrary files, then a single web vulnerability becomes a full data breach.
Audit evidence (hardened host)
- Result: Blocked
- Wall time: 728ms
- Defense layer: SELinux MAC (
httpd_sys_script_t)
type=AVC msg=audit(...): avc: denied { search }
pid=24205 comm="cat" name="attacker"
scontext=system_u:system_r:httpd_sys_script_t:s0
tcontext=unconfined_u:object_r:user_home_dir_t:s0
tclass=dir permissive=0Audit evidence (permissive host)
- Result: Data leaked
- Wall time: 673ms
- Defense layer: None (DAC allows with 644 permissions)
type=AVC msg=audit(...): avc: denied { read }
name="secrets.txt"
scontext=system_u:system_r:httpd_sys_script_t:s0
tcontext=unconfined_u:object_r:user_home_t:s0
tclass=file permissive=1
type=SYSCALL: syscall=257 success=yes exit=3Analysis: The permissive=0 over permissive=1 flag is the critical difference. On the hardened host, SELinux enforced the policy and blocked the syscall. On the permissive host, SELinux logged the violation but allowed the read to succeed (success=yes). The sensitive data was exfiltrated. The audit2why output confirms this is a deliberate policy decision. The Boolean httpd_enable_homedirs is off by default and prevents httpd processes from accessing user home directories regardless of DAC permissions.
Attack 2: Network escape (SELinux)
Scenario: Following the file access attempt, an attacker uses httpd to connect to SSH (port 22) for lateral movement. SELinux blocked the network connection due to the httpd_can_network_connect policy being disabled by default, while the permissive host allowed the SSH banner to be retrieved.
Key takeaway: SELinux blocks both file access and network escape attempts. This demonstrates that even when attackers attempt to chain multiple CVEs or launch simultaneous exploits, the attack path is fully mitigated with SELinux enabled.
Audit evidence (hardened host)
- Result: Blocked
- Wall time: 864ms
- Defense layer: SELinux network policy (
name_connect)
Audit evidence (permissive host)
- Result: Blocked
- Wall time: 674ms
- Defense layer: None
Attack 3: Untrusted binary execution from /tmp (fapolicyd)
Scenario: The attacker downloads or compiles a payload binary and attempts to execute it. This is the most common post-exploitation pattern: Drop a tool in a writable directory and run it. Method: We compiled a small C program on the target host (simulating an attacker building a payload), placed it in /tmp, and executed it as an unprivileged user. The binary is not in any RPM package database — it is "untrusted" from the perspective of fapolicyd.
Audit evidence (hardened host)
- Result: Blocked
- Wall time: 837ms
- Defense layer:
fapolicyd(FANOTIFYpermission event)
type=FANOTIFY msg=audit(...): resp=2 fan_type=1
fan_info=D subj_trust=2 obj_trust=0
type=SYSCALL: syscall=59 success=no exit=-1
comm="bash" exe="/usr/bin/bash"Audit evidence (permissive host)
- Result: EXECUTED (
uid=1001) - Wall time: 690ms
- Defense layer: None
Analysis: fapolicyd uses the kernel's FANOTIFY framework to intercept execve() system calls. When the binary's hash does not match any entry in the RPM trust database (obj_trust=0), fapolicyd returns resp=2 (deny). The kernel then fails the execve() with EPERM. The fapolicyd policy uses a trust-based model: Only binaries installed as an RPM (tracked in a database of ~15,000 entries on a standard RHEL 9 install) are allowed to execute. Everything else, including attacker tools compiled on the system, is blocked.
Attack 4: Memory-resident payload via /dev/shm (fapolicyd)
Scenario: The attacker attempts to evade filesystem-based controls by placing a payload in shared memory (/dev/shm) — a tmpfs mount that exists only in RAM. This is a common evasion technique against traditional antivirus and file integrity monitoring tools. Method: We compiled a separate small C program directly in /dev/shm/ and executed it as an unprivileged user.
| Hardened | Permissive | |
|---|---|---|
| Result | BLOCKED (Operation not permitted) | EXECUTED |
| Wall time | 775ms | 777ms |
| Defense layer | fapolicyd (FANOTIFY) | None |
Analysis: fapolicyd intercepts at the execve() syscall level, not at the filesystem level. It doesn't matter whether the binary is on disk, in /tmp, or in shared memory. If the binary is not in the RPM trust database, then execution is denied. This makes fapolicyd effective against in-memory evasion techniques that bypass traditional file-based security tools.
Audit evidence (hardened host)
- Result: Blocked (operation not permitted)
- Wall time: 775ms
- Defense layer:
fapolicyd(FANOTIFY)
Audit evidence (permissive host)
- Result: Permissive
- Wall time: 777ms
- Defense layer: None
Recommendations
From our experiments here, there emerges several best practices to keep in mind for your own systems:
- Never disable SELinux. Our testing showed that SELinux's MAC controls blocked 2 of 4 attack vectors that succeeded on a permissive system. The file confinement and network confinement operate at the kernel level and cannot be bypassed by userspace attackers without a kernel exploit.
- Deploy
fapolicyd. Application allowlisting blocked 2 of 4 vectors, including the memory-resident payload in/dev/shm. Becausefapolicydoperates at theexecve()syscall level, it's effective against evasion techniques that bypass file-based security tools. Runfapolicyd-cli --updateafter installation. - Keep kernel defaults. The
slab_nomergeandinit_on_alloc=0kernel parameters that some guides recommend for "performance tuning" remove heap protections that make exploit development significantly harder. Do not disable them unless you have measured a performance impact in your specific workload. - Set
dmesg_restrict=1. Both our test hosts allowed unprivilegeddmesgaccess, which can leak kernel addresses. Addkernel.dmesg_restrict=1to/etc/sysctl.d/99-hardening.conf. - Monitor audit logs. Even on the permissive host, SELinux logged the policy violations (with
permissive=1). If your organization is running SELinux in permissive mode as a stepping stone to enforcing, these logs tell you exactly what would break — and what you're currently exposed to. - Complement runtime controls with live patching: Mandatory access controls and allowlisting contain attackers after initial access, but pairing them with
kpatchhelps mitigate known vulnerabilities without requiring system reboots.
Want to see this for yourself?
Everything here ran on paired KVM guests built from the same compose. In the next article, we repeat the hardened-host results on bare metal to rule out virtualization artifacts, dig into what RHEL's kernel defaults protect against (beyond SELinux and fapolicyd), and walk through the exact steps to reproduce every attack on your own two RHEL 9 systems, with audit commands included.
Ready to evaluate your own systems? Review our step-by-step RHEL 9 security hardening guide to audit your default configurations.