Most Linux servers will run any binary an attacker manages to write to disk, which is why a web shell can so easily become a cryptominer, a scanner or a privilege escalation tool. fapolicyd, the file access policy daemon shipped with Red Hat Enterprise Linux and its derivatives, changes that default: it allows execution only of files the system already trusts, with trust coming mainly from the RPM database. The RHEL 9 DISA STIG requires it, configured as deny-all and permit-by-exception. This guide explains how fapolicyd decides, how to write rules and trust entries, how to roll it out without freezing servers, how to monitor it and where its limits are. It is for Linux engineers and security teams; Windows allowlisting (App Control for Business, AppLocker) and general allowlisting strategy are covered in the Application Allowlisting Guide.
Key takeaways
- Trust is the package database. Anything installed by DNF or RPM is trusted automatically through the RPM plugin; everything else needs an explicit trust entry or rule, so software deployed by tarball, pip, npm or a vendor installer is blocked by default.
- Rules are first match wins. Rule files in
/etc/fapolicyd/rules.d/are merged in lexical order byfagenrules, so a custom allow must sort before90-deny-execute.rules. - Integrity checking is off by default. With
integrity = none, a trusted path is trusted whatever its contents; setsha256orimafor real protection against replaced binaries. - Permissive first, always. The upstream project warns that it is not hard to deadlock a system; run
permissive = 1andfapolicyd --debug-denyuntil the denial list is understood. - It does not stop root. fapolicyd is designed to stop users and exploited services running unknown code; root can change the rules or stop the daemon, so monitor for exactly that.
How fapolicyd decides
fapolicyd uses the kernel fanotify interface (kernel 4.20 or later, which added the open-for-execute permission event) to receive a permission request whenever a watched file is opened or executed. It looks up the subject (the process) and the object (the file), evaluates the compiled rules from top to bottom, and returns allow or deny before the access completes.
| Element | Where it lives | What it does |
|---|---|---|
| Daemon configuration | /etc/fapolicyd/fapolicyd.conf | Permissive mode, integrity mode, trust back-ends, watched file systems, log format, performance options |
| Rule units | /etc/fapolicyd/rules.d/*.rules | Merged by fagenrules into /etc/fapolicyd/compiled.rules |
| File trust | /etc/fapolicyd/fapolicyd.trust and /etc/fapolicyd/trust.d/ | Paths (with size and hash) trusted in addition to the RPM database |
| Trust database | /var/lib/fapolicyd/ | Built from the trust back-ends (default rpmdb,file); do not delete the directory |
| RPM plugin | Installed with the package | Tells the daemon about package installs and updates so trust stays current |
| Administration | fapolicyd-cli, fagenrules | Trust management, rule listing and reload, configuration checks |
Default policies
Upstream ships rule units that combine into two policies. The default known-libs policy blocks execution through the dynamic loader (ld.so), requires anything executed to be trusted, and requires libraries and interpreted applications and modules to be trusted. The restrictive policy allows only ELF binaries, Python and shell scripts for trusted applications, with other languages (Perl, PHP, Ruby, Lua, OCaml) disabled unless their optional units are added. The shipped policy prevents execution from /tmp, /var/tmp and home directories because no package installs software there.
| Prefix | Rule unit purpose (RHEL 9) |
|---|---|
| 10 | Language definitions (MIME types treated as code) |
| 20 and 21 | Dracut and updater rules so the system can still be maintained |
| 30 | Patterns, such as denying execution through the runtime linker (pattern=ld_so) |
| 40, 41, 42 | ELF rules, shared object rules, trusted ELF rules |
| 70 and 72 | Trusted language rules and shell rules |
| 80 (your own) | Site-specific allow rules, placed before the deny rules |
| 90 | Deny execute rules (90-deny-execute.rules) |
| 95 | Allow open rules for non-executable access |
Writing rules and trust entries
Rules take the form decision perm=<execute|open|any> <subject> : <object>, where the decision is allow, deny or an auditing variant such as deny_audit or deny_log. Subject attributes include exe, uid, auid, comm, pid, trust and pattern; object attributes include path, dir (a trailing slash makes it recursive), ftype (MIME type), trust, device and sha256hash. Paths can use glob: patterns for variable components.
Trust entry or rule?
| Need | Use | Why |
|---|---|---|
A vendor application installed outside RPM in /opt/vendor | fapolicyd-cli --file add /opt/vendor/ --trust-file vendor then fapolicyd-cli --update | Red Hat states trust entries perform better than custom rules, and the entry records size and hash |
| An in-house build pipeline that deploys new binaries weekly | Package the software as RPM where possible | The RPM plugin keeps trust current with no manual step |
| Allow one interpreter to run scripts from one directory | A rule in 80-myapps.rules, for example allowing a named exe to open ftype=text/x-python in a specific dir | Trust alone does not express "only this program may run these files" |
| Block a specific trusted but unwanted binary | A deny rule with path= or sha256hash= placed early | Removes execution without removing the package |
| Container runtimes | A 25-runc.rules unit allowing runc and the loader, as Red Hat documents | Container layers are not in the host RPM database |
- After any rule change: run
fagenrules --checkto see whetherrules.ddiffers from the compiled policy, thenfagenrules --load(orfapolicyd-cli --reload-rules), and confirm the order withfapolicyd-cli --list. - After a trusted file changes: it loses trust until refreshed with
fapolicyd-cli --file update <path>. Usefapolicyd-cli --check-trustdbto find mismatches between trust entries and files on disk. - Configuration hygiene:
fapolicyd-cli --check-configfinds syntax errors and--check-watch_fsfinds file systems holding executables that are not watched. - Keep trust narrow: trusting a whole writable directory (for example a shared application data folder) means anything written there becomes executable. Trust the binaries, not the data paths.
Integrity modes and hardening options
integrity = | Check | Strength | Cost and prerequisites |
|---|---|---|---|
none (default) | None: trusted path and identity are enough | Weak against a replaced trusted file | None |
size | File size against the trust database | Catches accidental overwrites; upstream notes an attacker can match the size | Effectively free |
sha256 | fapolicyd computes SHA-256 and compares it with the trust database, plus size | Strong | CPU cost on first access to each file |
ima | Uses the hash the kernel IMA subsystem stores in extended attributes, plus size | Strong and cheap at run time | IMA must be configured; every file system holding code needs extended attributes and i_version support (default on XFS, iversion mount option elsewhere) |
rpm_sha256_only = 1: forces RPM trust entries to use SHA-256 or stronger and ignores older SHA-1 or MD5 package digests. Use it withsha256orimaintegrity; the default is 0.watch_fs: defaults to ext4, xfs and tmpfs. Add any other file system that can hold executables. Red Hat notes that removing tmpfs to help containers lowers security.ignore_mounts(fapolicyd 1.3.8 and later): removes busy mount points from monitoring for performance; each must be mountednoexec, and upstream warns that trusted interpreters can still read and act on files there. Use it sparingly.syslog_format: controls the fields in each decision log line, for examplerule,dec,perm,auid,pid,exe,:,path,ftype,trust; events are limited to 512 bytes and more fields cost performance.report_interval: writes daemon state and metrics files at a fixed interval, useful for health monitoring.
The ima integrity mode ties fapolicyd to the kernel integrity subsystem. See the Linux File Integrity Monitoring Guide.
Rolling out fapolicyd safely
- Inventory software sources: on each server role, list what runs from outside RPM: vendor agents in
/opt, Python virtual environments, Node.js applications, Java application servers, scripts in home directories and container runtimes. These are the denials you will see. - Install in permissive mode: deploy with configuration management (the
redhat.rhel_system_roles.fapolicydrole exposesfapolicyd_setup_permissive,fapolicyd_setup_integrity,fapolicyd_setup_trustandfapolicyd_add_trusted_file) withpermissive = 1. - Collect denials for a full business cycle: include month-end jobs, backups and patching. Review with
ausearch -ts recent -m fanotifyor a summary such asausearch --start today -m fanotify --raw | aureport --file --summary, and in a test window withfapolicyd --debug-deny --permissive. - Fix by packaging, then trust, then rules: convert in-house software to RPM where you can, add trust files for vendor software, and write narrow
80-rules only for what trust cannot express. - Turn on integrity: move to
integrity = sha256(orimaif IMA is already deployed) andrpm_sha256_only = 1while still permissive, and check for new denials. - Enforce in rings: set
permissive = 0on a pilot ring, then internet-facing servers, then the rest. Confirm the last rule is the catch-all deny (the STIG check expects a rule such asdeny perm=any all : all, and acceptsdeny_auditordeny_logforms). - Update deployment pipelines: any install done with
rpm -ioutside DNF needsfapolicyd-cli --updateafterwards; Red Hat warns that skipping this can freeze the system. Non-RPM deployments must update trust in the same job. - Rollback: set
permissive = 1and restart the service, or stop the service from the console. If the daemon locks up, Red Hat documents removing/var/run/fapolicyd/fapolicyd.fifo; for a corrupt trust database, stop the service, runfapolicyd-cli --delete-dband restart. Never strace the daemon: upstream warns it will deadlock the system.
Decision guidance
- Which servers first: internet-facing web and application servers, jump hosts and servers that run few non-RPM components get the most value for the least tuning.
- known-libs or restrictive: keep the default known-libs policy for general servers; use restrictive on appliance-like systems where you can enumerate every interpreter.
- Developer and build hosts: pip, npm and compiler output make strict enforcement painful. Keep them permissive with alerting, and enforce on the production hosts the builds deploy to.
- Small vs large estates: a small team can enforce on a handful of internet-facing servers with hand-maintained trust files; a large estate needs RPM packaging of internal software and trust updates built into deployment tooling, or the exception list will grow without control.
Monitoring and detection
| Signal | Source | Why it matters |
|---|---|---|
| Denied execution in enforcing mode | fanotify audit events, or syslog lines with dec=deny | Either a deployment that skipped trust or an intruder's tool, for example a downloaded miner (T1105 Ingress Tool Transfer) or a script dropped by a web shell |
Denied ld.so execution | Rule hits on pattern=ld_so | Attempt to run an untrusted binary through the loader to bypass the check |
Changes to /etc/fapolicyd/ | auditd watch, for example -w /etc/fapolicyd/ -p wa -k fapolicyd_changes | New trust entries or rules are the quiet way to allow a tool |
| Service stopped or set permissive | systemd journal, configuration management drift reports | Maps to ATT&CK T1685 Disable or Modify Tools |
| Trust database mismatches | fapolicyd-cli --check-trustdb run on a schedule | Trusted files changed on disk outside the package manager |
See the Linux Logging and auditd for Defenders Guide.
Metrics
- Enforcement coverage: percentage of in-scope servers with fapolicyd running and
permissive = 0(target 100 percent for internet-facing servers). - Integrity coverage: percentage of enforcing servers with
integrityset tosha256orima. - Denials investigated: percentage of production denials triaged within one working day (target 100 percent).
- Exception growth: number of trust entries and custom rules outside the RPM database per server role, tracked month on month.
- Drift: number of servers where configuration management found fapolicyd stopped, permissive or with unmanaged rule files (target zero).
Limits, identity and framework mapping
- Root and service accounts: upstream is explicit that fapolicyd does not stop root, who can change rules or stop the daemon. It is most effective at containing exploited services that run as unprivileged service accounts, which is another reason to keep services off root. See the Linux Service Accounts and Keytab Management Guide and the Linux Privilege Escalation Techniques Guide.
- Interpreters: a trusted interpreter can still run commands typed into it, and upstream notes that interpreters which read scripts lazily can run content added after the check if file permissions allow modification. Keep trusted scripts non-writable by service accounts. ATT&CK T1059.004 Unix Shell and T1059.006 Python remain relevant.
- Complements, not replaces, SELinux: upstream describes SELinux as modelling how an application behaves, and fapolicyd as deciding whether the application is known. Run both. See the SELinux Guide.
- Supply chain: a malicious package installed through the trusted repository is trusted by design. Repository and signing controls cover that gap. See the Linux Package Signing and Repository Trust Guide.
| Framework | Reference | How fapolicyd meets it |
|---|---|---|
| DISA RHEL 9 STIG (V2R9 as tracked by ComplianceAsCode) | RHEL-09-433010 installed, RHEL-09-433015 enabled, RHEL-09-433016 deny-all, permit-by-exception | Package, service and a final catch-all deny rule |
| NIST SP 800-53 Rev 5 | CM-7(2) Prevent Program Execution, CM-7(5) Authorized Software: Allow-by-exception, CM-6 Configuration Settings | Trust database plus deny rules |
| NIST CSF 2.0 | PR.PS-05 Installation and execution of unauthorized software are prevented | Enforcing mode |
| CIS Controls v8.1 | Safeguards 2.5 Allowlist Authorized Software, 2.6 Allowlist Authorized Libraries, 2.7 Allowlist Authorized Scripts | ELF, shared object and language rules |
| ISO/IEC 27001:2022 Annex A | A.8.19 Installation of software on operational systems | Only packaged or explicitly trusted software runs |
| MITRE D3FEND | D3-EAL Executable Allowlisting | The core function |
| NIST SP 800-167 | Guide to Application Whitelisting | Planning and lifecycle guidance |
Common failure patterns
- Enforcing on day one: switching straight to enforcing breaks vendor agents, backup clients and monitoring tools, and the next incident call ends with fapolicyd disabled fleet-wide.
- Leaving integrity at none: teams believe trusted binaries are protected, but a replaced file at a trusted path still runs. Use
sha256orima. - Allow rules after the deny: a rule file named
99-myapp.rulesnever matches because90-deny-execute.ruleswins first; check withfapolicyd-cli --list. - Trusting writable directories: adding an upload, cache or home directory to the trust file makes every file dropped there executable, recreating the gap fapolicyd was meant to close.
- Manual RPM installs without a trust update:
rpm -ioutside DNF withoutfapolicyd-cli --updateleaves the database stale and, as Red Hat warns, can freeze the system. - No alerting on denials or on the daemon itself: enforcement without monitoring blocks tools silently and misses the attacker who simply stops the service.
Lessons from incidents
Commodity Linux intrusions very often end in a downloaded binary, and supply chain incidents can deliver one too: the malicious Ultralytics PyPI releases downloaded and ran the XMRig miner on machines that installed them. On a server enforcing the default fapolicyd policy, a freshly downloaded binary that is not in the RPM database or a trust file would be denied execution unless it landed in a trusted location, and the denial would be the alert. The same incident also shows the limit: the Python package itself came through a legitimate channel, and if a team had trusted its virtual environment directory wholesale, any binary written there would run. Trust installed code by package and hash, not by directory.
Practitioner checklist
- Install fapolicyd on all RHEL-family servers in scope and enable the service (RHEL-09-433010 and RHEL-09-433015).
- Run in permissive mode for a full business cycle and review every denial.
- Package in-house software as RPM, add trust files for vendor software, and keep custom rules in an
80-unit. - Set
integrity = sha256orimaandrpm_sha256_only = 1before enforcing. - Confirm the final rule is a catch-all deny and enforce in rings, starting with internet-facing servers.
- Add
fapolicyd-cli --updateor trust updates to every deployment path outside DNF. - Audit
/etc/fapolicyd/with auditd and alert on service stops and permissive mode. - Forward denials to the SIEM with a
syslog_formatthat includes rule, decision, user, executable and path. - Run
fapolicyd-cli --check-trustdband--check-watch_fson a schedule. - Document the rollback steps and test them on a pilot server.
Standards and references
- Red Hat: Blocking and allowing applications by using fapolicyd (RHEL 9 Security Hardening)
- fapolicyd project: README and design notes
- fapolicyd project: fapolicyd.conf manual
- fapolicyd project: fapolicyd.rules manual
- ComplianceAsCode: RHEL 9 STIG control mapping
- NIST: SP 800-167 Guide to Application Whitelisting
- NIST: SP 800-53 Rev. 5
- MITRE D3FEND: Executable Allowlisting
Related NHI Mgmt Group resources: Application Allowlisting Guide · Red Hat Enterprise Linux Security Hardening Guide · Linux Server Hardening Guide · Linux File Integrity Monitoring Guide